47 ACCELERATION = 1 << 13,
50 FOLLOW_PATH = 1 << 16,
51 AVOID_COLLISIONS = 1 << 17,
53const int ObjectAttributeMax = 18;
251 virtual int serialize(std::stringstream *p_ss,
unsigned int attr=0);
257 virtual int deserialize(std::stringstream *p_ss,
unsigned int *p_a=NULL);
298 bool operator!=(
const Object &o);
Definition: Animation.h:17
virtual int deserialize(std::stringstream *p_ss, unsigned int *p_a=NULL)
Deserialize stream to attributes and apply.
Vector getPosition() const
Get position of Object.
unsigned int m_modified
Mod. attributes mask since last serialize().
Definition: Object.h:78
bool operator==(const Object &o)
Compare two Objects.
int getAltitude() const
Return altitude of Object.
int m_altitude
0 to MAX_ALTITUDE (higher drawn on top).
Definition: Object.h:72
virtual bool isVisible() const
Return visibility of Object. Objects not visible are not drawn.
void doPathFollowing()
If following a path, update path progress.
bool isModified() const
Return true if any attribute modified since last serialize.
void setSpeed(float speed)
Set speed of Object.
virtual int setActive(bool new_active=true)
Set activeness of Object.
std::string m_type
Game programmer defined type.
Definition: Object.h:64
int setVisible(bool new_visible=true)
Set visibility of Object.
Vector m_direction
Direction vector.
Definition: Object.h:69
bool m_avoid_collisions
True if should avoid collisions with HARD.
Definition: Object.h:83
int unregisterInterest(std::string event_type)
Unregister for interest in event.
std::string getType() const
Get type identifier of Object.
bool isActive() const
Return activeness of Object.
Vector m_acceleration
Acceleration vector.
Definition: Object.h:71
Shape getShape() const
Get drawing shape.
void accelerate()
Add acceleration to Object velocity.
Vector getDirection() const
Get direction of Object.
virtual void setDirection(Vector new_direction)
Set direction of Object.
static int max_id
Monotonically increasing identifier.
Definition: Object.h:60
bool getFollowPath() const
Returns true if following a path (note: is set in pathTo() method).
virtual void setAnimation(Animation new_animation, bool set_box=true)
Set Animation for this Object to new one.
float m_speed
Object speed in direction.
Definition: Object.h:70
virtual int draw()
Draw Object: Animation and/or Shape.
virtual void setBox(Box new_box)
Set bounding box of Object.
void setPath(Path new_path)
Set Path (note: is also set in pathTo() method).
virtual int setSprite(std::string sprite_label)
Set Sprite for this Object to animate.
virtual int serialize(std::stringstream *p_ss, unsigned int attr=0)
Serialize attributes to stream.
bool isSolid() const
Return True if Object is HARD or SOFT, else false.
bool isModified(enum ObjectAttribute attribute) const
Return true if attribute modified since last serialize.
Solidness m_solidness
Solidness state of Object.
Definition: Object.h:73
Object()
Construct Object.
Animation m_animation
Animation associated with Object.
Definition: Object.h:74
bool m_follow_path
True if following path.
Definition: Object.h:82
virtual int setSolidness(Solidness new_solid)
Set solidness of Object, with checks for consistency.
void moveTo(Vector new_position)
Set direction of Object towards position.
Shape m_shape
Basic geometric shape to draw.
Definition: Object.h:79
virtual ~Object()
Destroy Object.
bool getAvoidCollisions() const
Get "avoid collisions" (true - avoid collisions with HARD when moving).
int m_id
Unique game engine defined identifier.
Definition: Object.h:63
virtual void setAvoidCollisions(bool new_avoid_collisions=true)
Set "avoid collisions" (true - avoid collisions with HARD when moving).
virtual void setFollowPath(bool new_follow_path=true)
Set follow_path (note: is also set in pathTo() method).
std::string m_event_name[MAX_OBJ_EVENTS]
Names of events interested in.
Definition: Object.h:77
bool m_is_active
If false, Object not acted upon.
Definition: Object.h:65
int getEventCount() const
Get registered interest event count.
virtual void setShape(Shape new_shape)
Set drawing shape.
PathFind * getPathFind()
Get object doing pathfinding.
int getId() const
Get Object id.
float getSpeed() const
Get speed of Object.
void pathTo(Vector position)
Navigate Object from current position to target position using pathfinding.
Animation getAnimation() const
Get Animation for this Object.
Vector getVelocity() const
Get velocity of Object based on direction and speed.
virtual int setAltitude(int new_altitude)
Set altitude of Object, with checks for range [0, MAX_ALTITUDE].
bool getNoSoft() const
Get "no soft" setting of Object (true - cannot move onto SOFT Objects).
Path getPath() const
Get Path (note: is set in pathTo() method).
Solidness getSolidness() const
Return solidness of Object.
virtual int setPosition(Vector new_position)
Set position of Object.
Path m_path
If following path, holds path information.
Definition: Object.h:81
virtual unsigned int getModified() const
Return modified attribute mask.
void setNoSoft(bool new_no_soft=true)
Set "no soft" setting of Object (true - cannot move onto SOFT Objects).
bool m_no_soft
True if won't move on SOFT Objects.
Definition: Object.h:75
bool m_is_visible
If true, Object gets drawn.
Definition: Object.h:66
virtual int eventHandler(const Event *p_event)
Handle event (default only handles pathfinding).
virtual void setType(std::string new_type)
Set type identifier of Object.
void pathTo(Object *p_o_target)
Navigate Object from current position to current position of target Object using pathfinding.
int registerInterest(std::string event_type)
Register for interest in event.
std::string toString() const
Return base attributes as string.
PathFind * m_p_path_find
Object performing pathfinding.
Definition: Object.h:80
Vector m_position
Position in game world.
Definition: Object.h:68
Vector getAcceleration() const
Get acceleration of Object.
virtual void setVelocity(Vector velocity)
Set direction and speed of Object.
Box getBox() const
Get bounding box of Object.
virtual void setAcceleration(Vector new_acceleration)
Set acceleration of Object.
int m_event_count
Number of events of interest.
Definition: Object.h:76
virtual void setModified(unsigned int new_modified)
Set modified attribute mask.
void setId(int new_id)
Set Object id.
Vector predictPosition()
Predict Object position based on speed and direction.
Box m_box
Box for sprite boundary & collisions.
Definition: Object.h:67
Definition: PathFind.h:31
An animation for a sprite.
Definition: Animation.h:15
ObjectAttribute
Categories of Object attributes that indicate modification.
Definition: Object.h:33
const int MAX_OBJ_EVENTS
Max number of events Object can be interested in.
Definition: Object.h:23
Solidness
Types of solidness of Object.
Definition: Object.h:26
@ SOFT
Object causes collision, but doesn't impede.
Definition: Object.h:28
@ HARD
Object causes collisions and impedes.
Definition: Object.h:27
@ SPECTRAL
Object doesn't cause collisions.
Definition: Object.h:29