check activateable() before allowing clicks (oops)
[openc2e.git] / SkeletalCreature.h
blob8da185b1f6e68bda0b7da12f7de3101d1dbad86f
1 /*
2 * SkeletalCreature.h
3 * openc2e
5 * Created by Alyssa Milburn on Thu 10 Mar 2005.
6 * Copyright (c) 2005-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.
19 #include "attFile.h"
21 // for enum lifestage (0 to 6)
22 #include "genome.h"
24 #include "openc2e.h"
25 #include "CreatureAgent.h"
27 class creaturesImage;
29 class SkeletalCreature : public CreatureAgent {
30 protected:
31 class SkeletonPart *skeleton;
33 unsigned int ticks; // TODO: unnecessary?
35 unsigned int posedirection;
36 unsigned int pose[17];
37 unsigned int facialexpression;
38 unsigned int pregnancy;
39 bool eyesclosed;
41 bool calculated;
42 int oldfootx, oldfooty;
43 int lastgoodfootx, lastgoodfooty; // TODO: sucky code
44 bool downfoot_left;
45 shared_ptr<class Room> downfootroom;
47 creatureAppearanceGene *appearancegenes[6];
48 std::map<unsigned int, creaturePoseGene *> posegenes;
49 std::map<unsigned int, creatureGaitGene *> gaitgenes;
51 shared_ptr<creaturesImage> images[17];
52 attFile att[17];
54 int width, height, adjustx, adjusty;
55 int partx[17], party[17];
57 std::string dataString(unsigned int _stage, bool sprite, unsigned int dataspecies, unsigned int databreed);
59 unsigned int gaiti;
60 creatureGaitGene *gaitgene;
62 std::pair<int, int> getCarryPoint();
64 void physicsTick();
65 void snapDownFoot();
67 void gaitTick();
69 void processGenes();
71 creatureAppearanceGene *appearanceGeneForPart(char p);
72 shared_ptr<creaturesImage> tintBodySprite(shared_ptr<creaturesImage>);
74 public:
75 SkeletalCreature(unsigned char _family);
76 virtual ~SkeletalCreature();
78 void render(Surface *renderer, int xoffset, int yoffset);
79 virtual int handleClick(float, float);
81 void skeletonInit();
82 void recalculateSkeleton();
84 unsigned int getPose(unsigned int i) { return pose[i]; }
85 void setPose(unsigned int p);
86 void setPose(std::string s);
87 void setPoseGene(unsigned int p);
88 void setGaitGene(unsigned int g);
90 void tick();
92 unsigned int getPregnancy() { return pregnancy; }
93 void setPregnancy(unsigned int p) { assert(p < 4); pregnancy = p; }
94 bool getEyesClosed() { return eyesclosed; }
95 void setEyesClosed(bool e) { eyesclosed = e; }
96 unsigned int getFacialExpression() { return facialexpression; }
97 void setFacialExpression(unsigned int f) { assert (f < 6); facialexpression = f; }
98 unsigned int getSkelWidth() { return width; }
99 unsigned int getSkelHeight() { return height; }
101 int attachmentX(unsigned int part, unsigned int id);
102 int attachmentY(unsigned int part, unsigned int id);
103 bool isLeftFootDown() { return downfoot_left; }
105 CompoundPart *part(unsigned int id);
106 void setZOrder(unsigned int plane);
108 void finishInit();
109 void creatureAged();
111 std::string getFaceSpriteName();
112 unsigned int getFaceSpriteFrame();
115 class SkeletonPart : public AnimatablePart {
116 friend class SkeletalCreature;
118 protected:
119 SkeletonPart(SkeletalCreature *p);
121 public:
122 void tick();
123 void partRender(class Surface *renderer, int xoffset, int yoffset);
124 unsigned int getWidth() { return ((SkeletalCreature *)parent)->getSkelWidth(); }
125 unsigned int getHeight() { return ((SkeletalCreature *)parent)->getSkelHeight(); }
126 void setPose(unsigned int p);
127 void setFrameNo(unsigned int f);
130 /* vim: set noet: */