Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/simulation2/system/ComponentTest.h
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | class ComponentTestHelper | ||||
CSimContext m_Context; | CSimContext m_Context; | ||||
CComponentManager m_ComponentManager; | CComponentManager m_ComponentManager; | ||||
CParamNode m_Param; | CParamNode m_Param; | ||||
IComponent* m_Cmp; | IComponent* m_Cmp; | ||||
EComponentTypeId m_Cid; | EComponentTypeId m_Cid; | ||||
bool m_isSystemEntityInit = false; | bool m_isSystemEntityInit = false; | ||||
public: | public: | ||||
ComponentTestHelper(shared_ptr<ScriptRuntime> runtime) : | ComponentTestHelper(shared_ptr<ScriptContext> scriptContext) : | ||||
m_Context(), m_ComponentManager(m_Context, runtime), m_Cmp(NULL) | m_Context(), m_ComponentManager(m_Context, scriptContext), m_Cmp(NULL) | ||||
{ | { | ||||
m_ComponentManager.LoadComponentTypes(); | m_ComponentManager.LoadComponentTypes(); | ||||
} | } | ||||
const ScriptInterface& GetScriptInterface() | const ScriptInterface& GetScriptInterface() | ||||
{ | { | ||||
return m_ComponentManager.GetScriptInterface(); | return m_ComponentManager.GetScriptInterface(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | void Roundtrip(bool verbose = false) | ||||
CHashSerializer hash1(GetScriptInterface()); | CHashSerializer hash1(GetScriptInterface()); | ||||
m_Cmp->Serialize(hash1); | m_Cmp->Serialize(hash1); | ||||
std::stringstream stdstr1; | std::stringstream stdstr1; | ||||
CStdSerializer std1(GetScriptInterface(), stdstr1); | CStdSerializer std1(GetScriptInterface(), stdstr1); | ||||
m_Cmp->Serialize(std1); | m_Cmp->Serialize(std1); | ||||
ComponentTestHelper test2(GetScriptInterface().GetRuntime()); | ComponentTestHelper test2(GetScriptInterface().GetContext()); | ||||
// (We should never need to add any mock objects etc to test2, since deserialization | // (We should never need to add any mock objects etc to test2, since deserialization | ||||
// mustn't depend on other components already existing) | // mustn't depend on other components already existing) | ||||
CEntityHandle ent = test2.m_ComponentManager.LookupEntityHandle(10, true); | CEntityHandle ent = test2.m_ComponentManager.LookupEntityHandle(10, true); | ||||
CStdDeserializer stdde2(test2.GetScriptInterface(), stdstr1); | CStdDeserializer stdde2(test2.GetScriptInterface(), stdstr1); | ||||
IComponent* cmp2 = test2.m_ComponentManager.ConstructComponent(ent, m_Cid); | IComponent* cmp2 = test2.m_ComponentManager.ConstructComponent(ent, m_Cid); | ||||
▲ Show 20 Lines • Show All 93 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator