2004-05-22 02:57:54 +02:00
|
|
|
// Entity.h
|
|
|
|
//
|
|
|
|
// Last modified: 22 May 04, Mark Thompson mot20@cam.ac.uk / mark@wildfiregames.com
|
|
|
|
//
|
|
|
|
// Entity class.
|
|
|
|
//
|
|
|
|
// Usage: Do not attempt to instantiate this class directly. (See EntityManager.h)
|
|
|
|
// Most of the members are trivially obvious; some highlights are:
|
|
|
|
//
|
|
|
|
// HEntity me: is a reference to this entity. Use instead of the address-of operator for
|
|
|
|
// non-temporary references. See EntityHandles.h
|
|
|
|
// When an entity dies, this should be set to refer to the bad-handle handle.
|
|
|
|
// CUnit* m_actor: is the visible representation of this entity.
|
|
|
|
// std::hash_map m_properties: isn't yet used, is capable of storing properties defined by script.
|
|
|
|
//
|
|
|
|
// snapToGround(): Called every frame, this will ensure the entity never takes flight.
|
|
|
|
// updateActorTransforms(): Must be called every time the position of this entity changes.
|
|
|
|
//
|
|
|
|
// Some notes: update() and dispatch() /can/ be called directly without ill effects,
|
|
|
|
// but it's preferable to go through the Entity manager and the Scheduler, respectively.
|
|
|
|
//
|
2004-05-22 01:46:16 +02:00
|
|
|
|
|
|
|
#ifndef ENTITY_INCLUDED
|
|
|
|
#define ENTITY_INCLUDED
|
|
|
|
|
|
|
|
#include <deque>
|
|
|
|
#include "EntityProperties.h"
|
|
|
|
|
|
|
|
#include "BaseEntity.h"
|
|
|
|
#include "Vector3D.h"
|
|
|
|
#include "Unit.h"
|
|
|
|
#include "UnitManager.h"
|
|
|
|
#include "EntityOrders.h"
|
|
|
|
#include "EntityHandles.h"
|
|
|
|
#include "EntityMessage.h"
|
|
|
|
|
|
|
|
class CEntityManager;
|
|
|
|
|
|
|
|
class CEntity
|
|
|
|
{
|
|
|
|
friend CEntityManager;
|
|
|
|
private:
|
|
|
|
// Intrinsic properties
|
|
|
|
public:
|
|
|
|
CStr m_name;
|
|
|
|
float m_speed;
|
|
|
|
CVector3D m_position;
|
|
|
|
float m_targetorientation;
|
|
|
|
float m_orientation;
|
|
|
|
CBaseEntity* m_base;
|
|
|
|
CUnit* m_actor;
|
|
|
|
|
|
|
|
std::deque<CEntityOrder> m_orderQueue;
|
|
|
|
|
|
|
|
// Extended properties table
|
|
|
|
|
2004-05-24 23:01:50 +02:00
|
|
|
STL_HASH_MAP<CStr,CGenericProperty,CStr_hash_compare> m_properties;
|
2004-05-22 01:46:16 +02:00
|
|
|
|
2004-05-22 02:57:54 +02:00
|
|
|
private:
|
2004-05-22 01:46:16 +02:00
|
|
|
CEntity( CBaseEntity* base, CVector3D position, float orientation );
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Handle-to-self.
|
|
|
|
HEntity me;
|
|
|
|
void dispatch( CMessage* msg );
|
|
|
|
void update( float timestep );
|
|
|
|
void updateActorTransforms();
|
|
|
|
float getExactGroundLevel( float x, float y );
|
|
|
|
void snapToGround();
|
|
|
|
void pushOrder( CEntityOrder& order );
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|