check activateable() before allowing clicks (oops)
[openc2e.git] / CreatureAgent.cpp
blobd15ebe9f2695c1e086b36fa0aaa608ed920e4eee
1 /*
2 * CreatureAgent.cpp
3 * openc2e
5 * Created by Alyssa Milburn on Sat Dec 09 2006.
6 * Copyright (c) 2006 Alyssa Milburn. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
20 #include "CreatureAgent.h"
21 #include "Creature.h"
23 CreatureAgent::CreatureAgent(unsigned char _family) : Agent(_family, 0, 0, 0) {
24 creature = 0;
26 // TODO: set zorder randomly :) should be somewhere between 1000-2700, at a /guess/
27 zorder = 1500;
29 walking = false;
30 approaching = false;
31 direction = 0;
34 CreatureAgent::~CreatureAgent() {
35 if (creature)
36 delete creature;
39 void CreatureAgent::setCreature(Creature *c) {
40 assert(c);
41 creature = c;
43 slots[0] = creature->getGenome();
44 species = (creature->isFemale() ? 2 : 1);
46 // category needs to be set, so call setClassifier now
47 setClassifier(family, genus, species);
50 void CreatureAgent::tick() {
51 Agent::tick();
53 if (!paused)
54 creature->tick();
57 void CreatureAgent::startWalking() {
58 walking = true;
59 approaching = false;
62 void CreatureAgent::stopWalking() {
63 walking = false;
66 void CreatureAgent::approach(AgentRef it) {
67 assert(it);
69 walking = false;
70 approaching = true;
71 approachtarget = it;
74 /* vim: set noet: */