xoreos  0.0.5
creature.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef ENGINES_KOTOR_CREATURE_H
26 #define ENGINES_KOTOR_CREATURE_H
27 
28 #include "src/common/types.h"
29 #include "src/common/scopedptr.h"
30 #include "src/common/ustring.h"
31 #include "src/common/ptrmap.h"
32 
33 #include "src/aurora/types.h"
34 
36 
40 
41 namespace Engines {
42 
43 namespace KotOR {
44 
45 class CharacterGenerationInfo;
46 class Item;
47 
48 class Creature : public Object {
49 public:
51  Creature();
53  Creature(const Aurora::GFF3Struct &creature);
55  Creature(const Common::UString &resRef);
56  ~Creature();
57 
59  void createFakePC();
62 
63  // Basic visuals
64 
65  void show();
66  void hide();
67  bool isVisible() const;
68 
69  // Basic properties
70 
71  bool isPC() const;
72  bool isPartyMember() const;
73 
74  Gender getGender() const;
75  int getLevel(const Class &c) const;
76 
77  Race getRace() const;
78  SubRace getSubRace() const;
79 
80  int getLevelByPosition(int position) const;
81  Class getClassByPosition(int position) const;
82 
83  float getWalkRate() const;
84  float getRunRate() const;
85 
86  // Positioning
87 
89  void setPosition(float x, float y, float z);
91  void setOrientation(float x, float y, float z, float angle);
92 
93  // Object/Cursor interactions
94 
95  void enter();
96  void leave();
97 
99  void highlight(bool enabled);
100 
102  bool click(Object *triggerer = 0);
103 
104  const Common::UString &getConversation() const;
105 
106  float getCameraHeight() const;
107 
108  // Inventory and equipment
109 
110  void equipItem(Common::UString tag, EquipmentSlot slot);
111 
113  Item *getEquipedItem(EquipmentSlot slot) const;
114 
115  // Animation
116 
117  void playDefaultAnimation();
119 
120  void playAnimation(const Common::UString &anim,
121  bool restart = true,
122  float length = 0.0f,
123  float speed = 1.0f);
124 
125  void playHeadAnimation(const Common::UString &anim,
126  bool restart = true,
127  float length = 0.0f,
128  float speed = 1.0f);
129 
130  // PC Mesh string generation
131 
133  static Common::UString getBodyMeshString(Gender gender, Class charClass, char state = 'b');
135  static Common::UString getHeadMeshString(Gender gender, Skin skin, uint32 faceId);
136 
137  // Action queue
138 
139  void clearActionQueue();
140 
142  void enqueueAction(const Action &action);
143 
144  const Action *peekAction() const;
145  const Action *dequeueAction();
146 
147 private:
149  struct PartModels {
151 
154 
157  };
158 
160  struct ClassLevel {
162  int level;
163  };
164 
165  bool _isPC;
166 
168 
171 
173  std::vector<ClassLevel> _levels;
176 
180  bool _visible;
181 
183 
186 
187  std::vector<Action> _actionQueue;
188 
189  float _walkRate;
190  float _runRate;
191 
192 
193  void init();
194 
195  void load(const Aurora::GFF3Struct &creature);
196  void load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint);
197 
198  void loadProperties(const Aurora::GFF3Struct &gff);
199  void loadPortrait(const Aurora::GFF3Struct &gff);
200  void loadAppearance();
201 
202  void getPartModels(PartModels &parts, uint32 state = 'a');
203  void getPartModelsPC(PartModels &parts, uint32 state, uint8 textureVariation);
204  void loadBody(PartModels &parts);
205  void loadHead(PartModels &parts);
206  void loadMovementRate(const Common::UString &name);
207 
208  void changeBody();
209  void changeWeapon(EquipmentSlot slot);
210 
211  void setDefaultAnimations();
212 };
213 
214 } // End of namespace KotOR
215 
216 } // End of namespace Engines
217 
218 #endif // ENGINES_KOTOR_CREATURE_H
void show()
Show the creature&#39;s model.
Definition: creature.cpp:101
void createPC(const CharacterGenerationInfo &info)
Create a player character creature from a character info class.
Definition: creature.cpp:535
void loadBody(PartModels &parts)
Definition: creature.cpp:425
A map storing pointer to objects, with automatic deletion.
A class holding an UTF-8 string.
Definition: ustring.h:48
uint8 _face
The face of the creature.
Definition: creature.h:175
void equipItem(Common::UString tag, EquipmentSlot slot)
Definition: creature.cpp:614
void enqueueAction(const Action &action)
Append action to the character&#39;s action queue.
Definition: creature.cpp:772
uint8_t uint8
Definition: types.h:200
bool isPartyMember() const
Definition: creature.cpp:129
const Common::UString & getConversation() const
Definition: creature.cpp:597
std::vector< Action > _actionQueue
Definition: creature.h:187
Skin _skin
The skin type of the creature.
Definition: creature.h:174
Common::ScopedPtr< Graphics::Aurora::Model > _model
The creature&#39;s model.
Definition: creature.h:178
bool isPC() const
Is the creature a player character?
Definition: creature.cpp:125
Common::UString _modelType
Definition: creature.h:177
void loadPortrait(const Aurora::GFF3Struct &gff)
Definition: creature.cpp:292
const Action * peekAction() const
Definition: creature.cpp:776
void changeWeapon(EquipmentSlot slot)
Definition: creature.cpp:501
Inventory & getInventory()
Definition: creature.cpp:643
Class getClassByPosition(int position) const
Get the class by its position in the level vector.
Definition: creature.cpp:153
uint32 _appearance
The creature&#39;s general appearance.
Definition: creature.h:167
bool _isPC
Is the creature a PC?
Definition: creature.h:165
void playHeadAnimation(const Common::UString &anim, bool restart=true, float length=0.0f, float speed=1.0f)
Definition: creature.cpp:679
Collection of items.
A simple scoped smart pointer template.
bool click(Object *triggerer=0)
The creature was clicked.
Definition: creature.cpp:585
Race getRace() const
Get the race of the creature.
Definition: creature.cpp:160
void load(const Aurora::GFF3Struct &creature)
Definition: creature.cpp:192
Basic Aurora graphics types.
void leave()
The cursor left the creature.
Definition: creature.cpp:576
Creature action in Star Wars: Knights of the Old Republic.
void getPartModelsPC(PartModels &parts, uint32 state, uint8 textureVariation)
Definition: creature.cpp:358
void loadProperties(const Aurora::GFF3Struct &gff)
Definition: creature.cpp:234
void info(const char *s,...)
Definition: util.cpp:69
SubRace _subRace
The subrace of the creature.
Definition: creature.h:170
void loadMovementRate(const Common::UString &name)
Definition: creature.cpp:456
Gender getGender() const
Get the gender of the creature.
Definition: creature.cpp:133
Low-level type definitions to handle fixed width types portably.
Graphics::Aurora::Model * _headModel
The creature&#39;s head model.
Definition: creature.h:179
void playAnimation(const Common::UString &anim, bool restart=true, float length=0.0f, float speed=1.0f)
Definition: creature.cpp:674
int getLevelByPosition(int position) const
Get the level by its position in the level vector.
Definition: creature.cpp:146
static Common::UString getBodyMeshString(Gender gender, Class charClass, char state='b')
Generate a string for the body mesh.
Definition: creature.cpp:696
Creature()
Create a dummy creature instance.
Definition: creature.cpp:75
float getWalkRate() const
Definition: creature.cpp:168
Unicode string handling.
Basic type definitions to handle files used in BioWare&#39;s Aurora engine.
Common::PtrMap< EquipmentSlot, Item > _equipment
Definition: creature.h:185
float getRunRate() const
Definition: creature.cpp:172
const Action * dequeueAction()
Definition: creature.cpp:783
void hide()
Hide the creature&#39;s model.
Definition: creature.cpp:111
A struct within a GFF3.
Definition: gff3file.h:164
uint32_t uint32
Definition: types.h:204
void highlight(bool enabled)
(Un)Highlight the creature.
Definition: creature.cpp:581
Parts of a creature&#39;s body.
Definition: creature.h:149
void loadHead(PartModels &parts)
Definition: creature.cpp:445
void getPartModels(PartModels &parts, uint32 state='a')
Definition: creature.cpp:326
void setPosition(float x, float y, float z)
Set the creature&#39;s position.
Definition: creature.cpp:176
Item * getEquipedItem(EquipmentSlot slot) const
Definition: creature.cpp:647
An object in a Star Wars: Knights of the Old Republic area.
SubRace getSubRace() const
Get the subrace of the creature.
Definition: creature.cpp:164
float getCameraHeight() const
Definition: creature.cpp:601
A map of pointer to objects, with automatic deletion.
Definition: ptrmap.h:42
std::vector< ClassLevel > _levels
The levels of the creature.
Definition: creature.h:173
static Common::UString getHeadMeshString(Gender gender, Skin skin, uint32 faceId)
Generate a string for the head mesh.
Definition: creature.cpp:731
bool isVisible() const
Is the creature&#39;s model visible?
Definition: creature.cpp:121
int getLevel(const Class &c) const
Get the level of the creature regarding a specific class.
Definition: creature.cpp:137
Race _race
The race of the creature.
Definition: creature.h:169
Common::UString _conversation
Definition: creature.h:182
void createFakePC()
Create a fake player character creature for testing purposes.
Definition: creature.cpp:528
void enter()
The cursor entered the creature.
Definition: creature.cpp:571
void setOrientation(float x, float y, float z, float angle)
Set the creature&#39;s orientation.
Definition: creature.cpp:184