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
|
|
|
|
|
|
|
|
#include "CStr.h"
|
|
|
|
#include "ObjectEntry.h"
|
|
|
|
|
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"
|
2005-08-15 01:50:37 +02:00
|
|
|
#include "XML/Xeromyces.h"
|
2004-05-22 01:46:16 +02:00
|
|
|
|
2005-04-22 09:12:55 +02:00
|
|
|
class CBaseEntity : public CJSComplex<CBaseEntity>, public IEventTarget
|
2004-05-22 01:46:16 +02:00
|
|
|
{
|
|
|
|
public:
|
2004-06-11 00:24:03 +02:00
|
|
|
CBaseEntity();
|
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
|
|
|
CStrW m_corpse;
|
|
|
|
bool m_extant;
|
|
|
|
|
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;
|
|
|
|
|
2005-09-14 21:43:16 +02:00
|
|
|
// HP properties
|
|
|
|
float m_healthCurr;
|
|
|
|
float m_healthMax;
|
|
|
|
float m_healthBarHeight;
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
2004-10-07 21:23:35 +02:00
|
|
|
float m_speed;
|
2005-05-01 21:09:13 +02:00
|
|
|
SEntityAction m_melee;
|
|
|
|
SEntityAction m_gather;
|
2004-11-11 08:09:32 +01: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);
|
2004-05-22 01:46:16 +02:00
|
|
|
};
|
|
|
|
|
2004-06-03 15:27:01 +02:00
|
|
|
#endif
|