77 TS_ASSERT(
m_Cmp == NULL);
93 TS_ASSERT(
m_Cmp != NULL);
94 return static_cast<T*
> (
m_Cmp);
124 std::stringstream dbgstr1;
129 std::cout <<
"--------\n" << dbgstr1.str() <<
"--------\n";
134 std::stringstream stdstr1;
149 TS_ASSERT(stdstr1.peek() == EOF);
151 std::stringstream dbgstr2;
153 cmp2->Serialize(dbg2);
156 std::cout <<
"--------\n" << dbgstr2.str() <<
"--------\n";
159 cmp2->Serialize(hash2);
161 std::stringstream stdstr2;
163 cmp2->Serialize(std2);
165 TS_ASSERT_EQUALS(dbgstr1.str(), dbgstr2.str());
167 TS_ASSERT_EQUALS(hash1.
GetHashLength(), hash2.GetHashLength());
170 TS_ASSERT_EQUALS(stdstr1.str(), stdstr2.str());
An entity initialisation parameter node.
A simple fixed-point number class.
virtual CTerrain * GetCTerrain()
#define UNUSED(param)
mark a function parameter as unused and avoid the corresponding compiler warning. ...
void AddMockComponent(CEntityHandle ent, InterfaceId iid, IComponent &component)
Adds an externally-created component, so that it is returned by QueryInterface but does not get destr...
void Roundtrip(bool verbose=false)
Checks that the object roundtrips through its serialize/deserialize functions correctly.
const PSRETURN PSRETURN_OK
virtual void Serialize(ISerializer &serialize)=0
IComponent * QueryInterface(entity_id_t ent, InterfaceId iid) const
Object wrapping an entity_id_t, with a SEntityComponentCache to support fast QueryInterface() / CmpPt...
virtual float GetExactGroundLevel(float x, float z)
CComponentManager m_ComponentManager
ScriptInterface & GetScriptInterface()
T * Add(EComponentTypeId cid, const std::string &xml, entity_id_t ent=10)
Call this once to initialise the test helper with a component.
Serialize to a human-readable YAML-like format.
virtual void ReloadTerrain()
Call when the underlying CTerrain has been modified behind our backs.
Contains pointers to various 'global' objects that are needed by the simulation code, to allow easy access without using real (evil) global variables.
void LoadComponentTypes()
const entity_id_t SYSTEM_ENTITY
Entity ID for singleton 'system' components.
CEntityHandle LookupEntityHandle(entity_id_t ent, bool allowCreate=false)
Returns a CEntityHandle with id ent.
void AddMock(entity_id_t ent, EInterfaceId iid, IComponent &component)
const CParamNode & GetChild(const char *name) const
Returns the (unique) child node with the given name, or a node with IsOk() == false if there is none...
Simple terrain implementation with constant height of 50.
#define DEFAULT_MOCK_COMPONENT()
static PSRETURN LoadXMLString(CParamNode &ret, const char *xml, const wchar_t *sourceIdentifier=NULL)
See LoadXML, but parses the XML string xml.
virtual u16 GetVerticesPerSide()
Returns number of vertices per side on the terrain.
#define T(string_literal)
void InitSystemEntity()
Set up an empty SYSTEM_ENTITY.
static CFixed FromInt(int n)
virtual void Deserialize(const CParamNode ¶mNode, IDeserializer &deserialize)=0
virtual CVector3D CalcExactNormal(float x, float z)
bool AddComponent(CEntityHandle ent, ComponentTypeId cid, const CParamNode ¶mNode)
Constructs a component of type 'cid', initialised with data 'paramNode', and attaches it to entity 'e...
IComponent * ConstructComponent(CEntityHandle ent, ComponentTypeId cid)
Allocates a component object of type 'cid', and attaches it to entity 'ent'.
void SetSystemEntity(CEntityHandle ent)
virtual void HandleMessage(const CMessage &msg, bool global)
CEntityHandle GetSystemEntity()
Returns a CEntityHandle with id SYSTEM_ENTITY.
static Handle handle(size_t idx, u64 tag)
ScriptInterface & GetScriptInterface()
Abstraction around a SpiderMonkey JSContext.
void HandleMessage(IComponent *cmp, const CMessage &msg, bool global)
virtual void MakeDirty(i32 i0, i32 j0, i32 i1, i32 j1)
Indicate that terrain tiles within the given region (inclusive lower bound, exclusive upper bound) ha...
CSimContext & GetSimContext()
Class to test a single component.
virtual CFixedVector3D CalcNormal(entity_pos_t x, entity_pos_t z)
u32 entity_id_t
Entity ID type.
virtual u16 GetTilesPerSide()
Returns number of tiles per side on the terrain.
virtual entity_pos_t GetGroundLevel(entity_pos_t x, entity_pos_t z)