FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
object.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2006-2012 by the FIFE team *
3  * http://www.fifengine.net *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 #ifndef FIFE_PROTOTYPE_H
23 #define FIFE_PROTOTYPE_H
24 
25 // Standard C++ library includes
26 #include <string>
27 #include <map>
28 #include <list>
29 
30 // 3rd party library includes
31 
32 // FIFE includes
33 // These includes are split up in two parts, separated by one empty line
34 // First block: files included from the FIFE root src directory
35 // Second block: files included from the same folder
36 #include "util/resource/resource.h"
37 #include "util/math/angles.h"
38 
39 namespace FIFE {
40 
41  class Action;
42  class IPather;
43  class IVisual;
44 
51  class Object {
52  public:
62  Object(const std::string& identifier, const std::string& name_space, Object* inherited=NULL);
63 
66  ~Object();
67 
68  const std::string& getId() const { return m_id; }
69  const std::string& getNamespace() const { return m_namespace; }
70 
73  void setId(const std::string& id) { m_id = id; }
74 
85  Action* createAction(const std::string& identifier, bool is_default=false);
86 
89  Action* getAction(const std::string& identifier, bool deepsearch = true) const;
90 
93  std::list<std::string> getActionIds() const;
94 
97  void setDefaultAction(const std::string& identifier);
98 
101  Action* getDefaultAction() const;
102 
105  void setPather(IPather* pather);
106 
109  IPather* getPather() const;
110 
114  Object* getInherited() const;
115 
118  void adoptVisual(IVisual* visual);
119 
122  template<typename T> T* getVisual() const { return reinterpret_cast<T*>(m_visual); }
123 
126  void setBlocking(bool blocking);
127 
130  bool isBlocking() const;
131 
134  void setStatic(bool stat);
135 
138  bool isStatic() const;
139 
140  void setFilename(const std::string& file);
141  const std::string& getFilename() const;
142 
147  void setCellStackPosition(uint8_t position);
148 
153 
157  bool isSpecialCost() const;
158 
162  void setCostId(const std::string& cost);
163 
167  std::string getCostId() const;
168 
172  void setCost(double cost);
173 
177  double getCost() const;
178 
182  bool isSpecialSpeed() const;
183 
187  void setSpeed(double cost);
188 
192  double getSpeed() const;
193 
197  bool isMultiObject() const;
198 
202  void addMultiPartId(const std::string& partId);
203 
207  std::list<std::string> getMultiPartIds() const;
208 
212  void removeMultiPartId(const std::string& partId);
213 
216  void removeAllMultiPartIds();
217 
221  bool isMultiPart() const;
222 
226  void setMultiPart(bool part);
227 
231  void addMultiPart(Object* obj);
232 
236  std::set<Object*> getMultiParts() const;
237 
241  void removeMultiPart(Object* obj);
242 
245  void removeMultiParts();
246 
251  void addMultiPartCoordinate(int32_t rotation, ModelCoordinate coord);
252 
256  std::multimap<int32_t, ModelCoordinate> getMultiPartCoordinates() const;
257 
262  std::vector<ModelCoordinate> getMultiPartCoordinates(int32_t rotation) const;
263 
268  std::vector<ModelCoordinate> getMultiObjectCoordinates(int32_t rotation) const;
269 
275  void setRotationAnchor(const ExactModelCoordinate& anchor);
276 
281 
286  void setRestrictedRotation(bool restrict);
287 
291  bool isRestrictedRotation() const;
292 
297  int32_t getRestrictedRotation(int32_t rotation);
298 
303  void setZStepRange(int32_t zRange);
304 
308  int32_t getZStepRange() const;
309 
313  void setArea(const std::string& id);
314 
318  std::string getArea() const;
319 
324  void addWalkableArea(const std::string& id);
325 
329  void removeWalkableArea(const std::string& id);
330 
334  std::list<std::string> getWalkableAreas() const;
335 
338  bool operator==(const Object& obj) const;
339 
342  bool operator!=(const Object& obj) const;
343 
344  private:
346  std::string m_id;
347 
349  std::string m_namespace;
350 
352  std::string m_filename;
353 
356 
359 
361  public:
364 
367 
369  std::string m_area;
370 
372  std::map<std::string, Action*>* m_actions;
373 
376 
379 
380  //remove this with a if (MovableObjectProperty)
382  bool m_static;
383 
386  };
387 
389  public:
392 
395 
398 
400  std::string m_costId;
401 
403  double m_cost;
404 
406  double m_speed;
407 
409  int32_t m_zRange;
410 
412  std::list<std::string> m_walkableAreas;
413  };
414 
416  public:
419 
422 
425 
428 
430  std::list<std::string> m_multiPartIds;
431 
434 
436  std::set<Object*> m_multiParts;
437 
440 
443 
445  std::multimap<int32_t, ModelCoordinate> m_multiPartCoordinates;
446 
448  std::multimap<int32_t, ModelCoordinate> m_multiObjectCoordinates;
449  };
450 
454  };
455 
456 } //FIFE
457 #endif
458 
double m_speed
speed modifier, default 1.0
Definition: object.h:406
std::string getArea() const
Gets the area id that the instances of this object adds to their cells.
Definition: object.cpp:580
void setDefaultAction(const std::string &identifier)
Sets default action assigned to this object.
Definition: object.cpp:155
double getCost() const
Returns the cost.
Definition: object.cpp:309
void removeMultiPart(Object *obj)
Removes a multi part object.
Definition: object.cpp:427
~Object()
Destructor.
Definition: object.cpp:85
void removeWalkableArea(const std::string &id)
Removes an area id from walkable areas.
Definition: object.cpp:599
void setArea(const std::string &id)
Sets the area id that the instances of this object adds to their cells.
Definition: object.cpp:573
const std::string & getNamespace() const
Definition: object.h:69
void adoptVisual(IVisual *visual)
Sets visualization to be used.
Definition: object.cpp:209
Object class.
Definition: object.h:51
void setRotationAnchor(const ExactModelCoordinate &anchor)
Sets the rotation anchor for this multi object.
Definition: object.cpp:508
const std::string & getId() const
Definition: object.h:68
Action * m_defaultAction
pointer to default action
Definition: object.h:375
bool isMultiObject() const
Gets if object uses special cost.
Definition: object.cpp:346
bool isStatic() const
Gets if object moves.
Definition: object.cpp:240
IPather * m_pather
pointer to pathfinder
Definition: object.h:397
IPather * getPather() const
Gets associated pather.
Definition: object.cpp:195
void setCellStackPosition(uint8_t position)
Sets the cell stack position.
Definition: object.cpp:258
int32_t m_zRange
z range value
Definition: object.h:409
uint8_t m_cellStack
position on cellstack
Definition: object.h:385
~BasicObjectProperty()
Destructor.
Definition: object.cpp:46
void setZStepRange(int32_t zRange)
Sets z-step range for object.
Definition: object.cpp:556
std::string getCostId() const
Returns the cost id.
Definition: object.cpp:292
Object(const std::string &identifier, const std::string &name_space, Object *inherited=NULL)
Constructor An object may optionally inherit default attributes from another object.
Definition: object.cpp:74
void setFilename(const std::string &file)
Definition: object.cpp:250
bool operator!=(const Object &obj) const
Compares unequality of two objects.
Definition: object.cpp:620
bool isMultiPart() const
Gets if object is a part of a multi object.
Definition: object.cpp:393
std::list< std::string > m_multiPartIds
list with part identifiers
Definition: object.h:430
std::string m_namespace
namespace
Definition: object.h:349
type_angle2id m_multiAngleMap
multi object angles
Definition: object.h:442
std::list< std::string > getWalkableAreas() const
Returns a list that contains all walkable area ids.
Definition: object.cpp:606
std::string m_area
area id
Definition: object.h:369
const std::string & getFilename() const
Definition: object.cpp:254
bool m_blocking
indicates if object blocks
Definition: object.h:378
std::string m_costId
cost identifier
Definition: object.h:400
void removeAllMultiPartIds()
Removes all multi part identifiers.
Definition: object.cpp:386
void removeMultiPartId(const std::string &partId)
Removes a multi part identifier.
Definition: object.cpp:373
MovableObjectProperty * m_moveProperty
Definition: object.h:452
unsigned char uint8_t
Definition: core.h:38
void setMultiPart(bool part)
Sets the object as a part of a multi object.
Definition: object.cpp:403
std::string m_id
identifier
Definition: object.h:346
std::multimap< int32_t, ModelCoordinate > getMultiPartCoordinates() const
Returns all rotationally dependent coordinates from this object part.
Definition: object.cpp:450
std::set< Object * > m_multiParts
set contains part objects
Definition: object.h:436
T * getVisual() const
Gets used visualization.
Definition: object.h:122
void setId(const std::string &id)
Sets the identifier for this object.
Definition: object.h:73
void setRestrictedRotation(bool restrict)
Sets the rotation to restricted.
Definition: object.cpp:525
void addMultiPartCoordinate(int32_t rotation, ModelCoordinate coord)
Adds rotationally dependent coordinates for this object part.
Definition: object.cpp:442
std::multimap< int32_t, ModelCoordinate > m_multiObjectCoordinates
multi object coordinates
Definition: object.h:448
std::set< Object * > getMultiParts() const
Returns all multi part objects.
Definition: object.cpp:417
BasicObjectProperty * m_basicProperty
Definition: object.h:451
bool isRestrictedRotation() const
Gets if object uses restricted rotations.
Definition: object.cpp:532
type_angle2id m_partAngleMap
part object angles
Definition: object.h:439
Object * m_inherited
pointer to inherited object
Definition: object.h:355
void setCost(double cost)
Sets the cost.
Definition: object.cpp:302
ExactModelCoordinate getRotationAnchor() const
Returns the rotation anchor for this multi object.
Definition: object.cpp:515
void removeMultiParts()
Removes all multi part objects.
Definition: object.cpp:435
Action * createAction(const std::string &identifier, bool is_default=false)
Adds new action with given id.
Definition: object.cpp:92
MultiObjectProperty * m_multiProperty
Definition: object.h:453
std::vector< ModelCoordinate > getMultiObjectCoordinates(int32_t rotation) const
Returns all multi object coordinates for the given rotation.
Definition: object.cpp:478
std::string m_filename
filename
Definition: object.h:352
void addMultiPart(Object *obj)
Adds a object as a part of a multi object.
Definition: object.cpp:410
std::list< std::string > m_walkableAreas
list contains walkable area ids
Definition: object.h:412
double m_cost
cost value, default 1.0
Definition: object.h:403
void addMultiPartId(const std::string &partId)
Adds a multi part identifier.
Definition: object.cpp:356
std::multimap< int32_t, ModelCoordinate > m_multiPartCoordinates
part object coordinates
Definition: object.h:445
void setStatic(bool stat)
Set to true, if object is such that it doesn&#39;t move.
Definition: object.cpp:233
uint8_t getCellStackPosition() const
Returns cell stack position.
Definition: object.cpp:265
A 3D Point.
Definition: point.h:205
std::map< std::string, Action * > * m_actions
holds action ids and assigned actions
Definition: object.h:372
Object * getInherited() const
Gets an object where this object was inherited from.
Definition: object.cpp:205
bool m_multiPart
indicates if object is part of multi object
Definition: object.h:424
std::list< std::string > getMultiPartIds() const
Returns all multi part identifiers.
Definition: object.cpp:363
std::map< uint32_t, int32_t > type_angle2id
Definition: angles.h:37
bool isSpecialCost() const
Gets if object uses special cost.
Definition: object.cpp:275
bool operator==(const Object &obj) const
Compares equality of two objects.
Definition: object.cpp:616
void addWalkableArea(const std::string &id)
Adds an area id to walkable area.
Definition: object.cpp:590
int32_t getZStepRange() const
Returns z-step range from object.
Definition: object.cpp:563
Action * getAction(const std::string &identifier, bool deepsearch=true) const
Gets action with given id.
Definition: object.cpp:121
void setPather(IPather *pather)
Sets pather used by instances created out of this object.
Definition: object.cpp:188
bool m_restrictedRotation
indicates if object uses only restricted rotations
Definition: object.h:427
bool m_static
indicates if object is static
Definition: object.h:382
void setBlocking(bool blocking)
Sets if object blocks movement.
Definition: object.cpp:216
double getSpeed() const
Returns the speed modifier.
Definition: object.cpp:336
std::list< std::string > getActionIds() const
Gets all available action ids of the object and packs them into a list.
Definition: object.cpp:140
BasicObjectProperty()
Constructor.
Definition: object.cpp:38
void setSpeed(double cost)
Sets the speed modifier.
Definition: object.cpp:329
Action * getDefaultAction() const
Gets default action assigned to this object.
Definition: object.cpp:178
int32_t getRestrictedRotation(int32_t rotation)
Returns the most obvious rotation, based on multi coordinates.
Definition: object.cpp:542
bool isSpecialSpeed() const
Gets if object uses special speed modifier.
Definition: object.cpp:319
bool isBlocking() const
Gets if object blocks movement.
Definition: object.cpp:223
ExactModelCoordinate m_rotationAnchor
rotation anchor
Definition: object.h:433
void setCostId(const std::string &cost)
Sets the cost id.
Definition: object.cpp:285
IVisual * m_visual
pointer to object visual
Definition: object.h:358