2004-05-22 02:57:54 +02:00
|
|
|
// BaseEntity.h
|
|
|
|
//
|
2004-07-20 21:30:35 +02:00
|
|
|
// Mark Thompson mot20@cam.ac.uk / mark@wildfiregames.com
|
2004-05-22 02:57:54 +02:00
|
|
|
//
|
|
|
|
// Entity Templates
|
|
|
|
//
|
|
|
|
// Usage: These templates are used as the default values for entity properties.
|
2004-12-05 22:56:09 +01:00
|
|
|
// Due to Pyrogenesis' data-inheritance model for these properties,
|
2004-05-22 02:57:54 +02:00
|
|
|
// templates specify a base-template, then override only those properties
|
|
|
|
// in that template that need to change.
|
|
|
|
// Similarly, entities need only specify properties they possess that are
|
|
|
|
// different to the ones in their respective templates. Of course,
|
|
|
|
// properties such as position, current HP, etc. cannot be inherited from
|
|
|
|
// a template in this way.
|
|
|
|
//
|
|
|
|
|
2004-05-22 01:46:16 +02:00
|
|
|
#ifndef BASE_ENTITY_INCLUDED
|
|
|
|
#define BASE_ENTITY_INCLUDED
|
|
|
|
|
2006-06-02 04:10:27 +02:00
|
|
|
#include "ps/CStr.h"
|
|
|
|
#include "graphics/ObjectEntry.h"
|
2004-05-22 01:46:16 +02:00
|
|
|
|
2005-04-22 09:12:55 +02:00
|
|
|
#include "scripting/ScriptableComplex.h"
|
2004-05-26 22:57:25 +02:00
|
|
|
#include "BoundingObjects.h"
|
2004-10-07 21:23:35 +02:00
|
|
|
#include "EventHandlers.h"
|
2005-05-01 21:09:13 +02:00
|
|
|
#include "EntitySupport.h"
|
2004-10-07 21:23:35 +02:00
|
|
|
#include "ScriptObject.h"
|
2006-06-02 04:10:27 +02:00
|
|
|
#include "ps/XML/Xeromyces.h"
|
2004-05-22 01:46:16 +02:00
|
|
|
|
2006-05-14 00:11:46 +02:00
|
|
|
class CPlayer;
|
|
|
|
|
2005-04-22 09:12:55 +02:00
|
|
|
class CBaseEntity : public CJSComplex<CBaseEntity>, public IEventTarget
|
2004-05-22 01:46:16 +02:00
|
|
|
{
|
|
|
|
public:
|
2006-05-14 00:11:46 +02:00
|
|
|
CPlayer* m_player; // Which player this template is for, or null for the no-player template
|
|
|
|
// used to read unmodified values for upgrades and such.
|
|
|
|
|
|
|
|
CBaseEntity( CPlayer* player );
|
2004-05-30 03:57:26 +02:00
|
|
|
~CBaseEntity();
|
2004-05-22 01:46:16 +02:00
|
|
|
// Load from XML
|
|
|
|
bool loadXML( CStr filename );
|
2004-10-07 21:23:35 +02:00
|
|
|
// Load a tree of properties from an XML (XMB) node.
|
2004-10-07 22:49:35 +02:00
|
|
|
void XMLLoadProperty( const CXeromyces& XeroFile, const XMBElement& Source, CStrW BasePropertyName );
|
2004-05-22 01:46:16 +02:00
|
|
|
|
|
|
|
// Base stats
|
2004-10-07 21:23:35 +02:00
|
|
|
CBaseEntity* m_base;
|
2004-11-11 08:09:32 +01:00
|
|
|
bool m_extant;
|
|
|
|
|
2006-05-14 00:11:46 +02:00
|
|
|
// The unmodified, no-player version of this template
|
|
|
|
CBaseEntity* m_unmodified;
|
|
|
|
|
2005-05-01 21:09:13 +02:00
|
|
|
// The class types this entity has
|
|
|
|
SClassSet m_classes;
|
|
|
|
|
2004-10-07 21:23:35 +02:00
|
|
|
CStrW m_Base_Name; // <- We don't guarantee the order XML files will be loaded in, so we'll store the name of the
|
|
|
|
// parent entity referenced, then, after all files are loaded, attempt to match names to objects.
|
|
|
|
|
2005-03-19 12:55:27 +01:00
|
|
|
CStrW m_actorName;
|
2004-11-11 08:09:32 +01:00
|
|
|
|
2004-10-07 21:23:35 +02:00
|
|
|
CStrW m_Tag;
|
2004-05-26 22:57:25 +02:00
|
|
|
CBoundingCircle* m_bound_circle;
|
|
|
|
CBoundingBox* m_bound_box;
|
|
|
|
CBoundingObject::EBoundingType m_bound_type;
|
2006-01-16 11:56:47 +01:00
|
|
|
|
|
|
|
//SP properties
|
|
|
|
float m_staminaCurr;
|
|
|
|
float m_staminaMax;
|
|
|
|
float m_staminaBarHeight;
|
|
|
|
int m_staminaBarSize;
|
2006-04-09 00:34:54 +02:00
|
|
|
float m_staminaBarWidth;
|
|
|
|
|
|
|
|
int m_staminaBorderWidth;
|
|
|
|
int m_staminaBorderHeight;
|
|
|
|
CStr m_staminaBorderName;
|
|
|
|
|
2005-09-14 21:43:16 +02:00
|
|
|
// HP properties
|
|
|
|
float m_healthCurr;
|
|
|
|
float m_healthMax;
|
|
|
|
float m_healthBarHeight;
|
2006-01-16 11:56:47 +01:00
|
|
|
int m_healthBarSize;
|
2006-04-09 00:34:54 +02:00
|
|
|
float m_healthBarWidth;
|
2005-09-14 21:43:16 +02:00
|
|
|
|
2006-04-09 00:34:54 +02:00
|
|
|
int m_healthBorderWidth;
|
|
|
|
int m_healthBorderHeight;
|
|
|
|
CStr m_healthBorderName;
|
|
|
|
|
2006-01-21 12:17:15 +01:00
|
|
|
float m_healthRegenRate;
|
|
|
|
float m_healthRegenStart;
|
|
|
|
float m_healthDecayRate;
|
|
|
|
|
2006-03-31 05:30:34 +02:00
|
|
|
//Rank properties
|
2006-04-09 00:34:54 +02:00
|
|
|
float m_rankWidth;
|
2006-04-14 10:25:29 +02:00
|
|
|
float m_rankHeight;
|
2006-03-31 05:30:34 +02:00
|
|
|
CStr m_rankName;
|
2006-06-22 00:37:31 +02:00
|
|
|
//Rally name
|
|
|
|
CStr m_rallyName;
|
|
|
|
float m_rallyWidth;
|
|
|
|
float m_rallyHeight;
|
2006-03-31 05:30:34 +02:00
|
|
|
|
2005-09-14 21:43:16 +02:00
|
|
|
// Minimap properties
|
|
|
|
CStrW m_minimapType;
|
|
|
|
int m_minimapR;
|
|
|
|
int m_minimapG;
|
|
|
|
int m_minimapB;
|
|
|
|
|
2005-09-18 05:47:15 +02:00
|
|
|
// Y anchor
|
|
|
|
CStrW m_anchorType;
|
|
|
|
|
2005-10-09 05:43:03 +02:00
|
|
|
// LOS
|
|
|
|
int m_los;
|
|
|
|
bool m_permanent;
|
|
|
|
|
2006-07-09 00:40:01 +02:00
|
|
|
// Is this object a territory centre? (e.g. Settlements in 0AD)
|
|
|
|
bool m_isTerritoryCentre;
|
|
|
|
|
2006-02-26 10:55:20 +01:00
|
|
|
// Foundation entity, or "" for none
|
|
|
|
CStrW m_foundation;
|
|
|
|
|
2006-07-10 01:12:37 +02:00
|
|
|
// Socket entity that we can be built on, or "" for free placement
|
|
|
|
CStrW m_socket;
|
|
|
|
|
2004-10-07 21:23:35 +02:00
|
|
|
float m_speed;
|
2006-05-13 06:07:42 +02:00
|
|
|
float m_runSpeed;
|
2006-01-16 11:56:47 +01:00
|
|
|
float m_runRegenRate;
|
|
|
|
float m_runDecayRate;
|
2006-05-13 06:07:42 +02:00
|
|
|
bool m_passThroughAllies;
|
2006-01-16 11:56:47 +01:00
|
|
|
|
2006-01-05 07:13:31 +01:00
|
|
|
SEntityAction m_run;
|
2005-12-29 09:42:44 +01:00
|
|
|
SEntityAction m_generic;
|
2004-11-11 08:09:32 +01:00
|
|
|
|
2006-04-09 00:34:54 +02:00
|
|
|
int m_sectorDivs;
|
2006-05-04 06:14:48 +02:00
|
|
|
int m_pitchDivs;
|
|
|
|
float m_anchorConformX;
|
|
|
|
float m_anchorConformZ;
|
2006-04-22 07:52:23 +02:00
|
|
|
|
2004-10-07 21:23:35 +02:00
|
|
|
float m_turningRadius;
|
|
|
|
CScriptObject m_EventHandlers[EVENT_LAST];
|
|
|
|
|
|
|
|
void loadBase();
|
2005-05-01 21:09:13 +02:00
|
|
|
jsval getClassSet();
|
|
|
|
void setClassSet( jsval value );
|
|
|
|
void rebuildClassSet();
|
2004-10-07 21:23:35 +02:00
|
|
|
|
|
|
|
// Script-bound functions
|
|
|
|
|
2005-04-22 09:12:55 +02:00
|
|
|
// Get script execution contexts - always run in the context of the entity that fired it.
|
|
|
|
JSObject* GetScriptExecContext( IEventTarget* target );
|
|
|
|
|
2004-10-07 21:23:35 +02:00
|
|
|
jsval ToString( JSContext* cx, uintN argc, jsval* argv );
|
|
|
|
|
|
|
|
static void ScriptingInit();
|
2005-08-09 17:55:44 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
// squelch "unable to generate" warnings
|
|
|
|
CBaseEntity(const CBaseEntity& rhs);
|
|
|
|
const CBaseEntity& operator=(const CBaseEntity& rhs);
|
2005-12-29 09:42:44 +01:00
|
|
|
|
|
|
|
static STL_HASH_SET<CStr, CStr_hash_compare> scriptsLoaded;
|
2004-05-22 01:46:16 +02:00
|
|
|
};
|
|
|
|
|
2004-06-03 15:27:01 +02:00
|
|
|
#endif
|