Demos #10
1 changed files with 21 additions and 2 deletions
|
|
@ -1150,17 +1150,22 @@ export struct EntityManager
|
|||
ushort sys_id = systems_map.get(cast(char[]) Sys.stringof, ushort.max);
|
||||
if (sys_id < systems.length)
|
||||
{
|
||||
system.enable();
|
||||
systems[sys_id].disable();
|
||||
if(systems[sys_id].m_destroy)(cast(void function(void*)) systems[sys_id].m_destroy)(systems[sys_id].m_system_pointer);
|
||||
|
||||
if (system.m_create)
|
||||
(cast(void function(void*)) system.m_create)(system.m_system_pointer);
|
||||
|
||||
system.enable();
|
||||
|
||||
system.m_id = sys_id;
|
||||
system.m_name = systems[sys_id].m_name;
|
||||
systems[sys_id] = system;
|
||||
}
|
||||
else
|
||||
{
|
||||
system.m_name = Mallocator.makeArray(cast(char[]) Sys.stringof);
|
||||
|
||||
systems_map.add(system.m_name, cast(ushort) systems.length);
|
||||
|
||||
system.m_id = cast(ushort)(systems.length);
|
||||
|
|
@ -1723,6 +1728,20 @@ export struct EntityManager
|
|||
return temp;
|
||||
}
|
||||
|
||||
/************************************************************************************************************************
|
||||
Allocate EntityTemplate copy.
|
||||
|
||||
Params:
|
||||
copy_tmpl = template which should be copied
|
||||
*/
|
||||
export EntityTemplate* allocateTemplate(EntityTemplate* copy_tmpl)
|
||||
{
|
||||
EntityTemplate* tmpl = Mallocator.make!EntityTemplate;
|
||||
tmpl.info = copy_tmpl.info;
|
||||
tmpl.entity_data = Mallocator.makeArray(copy_tmpl.entity_data);
|
||||
return tmpl;
|
||||
}
|
||||
|
||||
/************************************************************************************************************************
|
||||
Returns entity type info.
|
||||
|
||||
|
|
@ -2344,7 +2363,7 @@ export struct EntityManager
|
|||
Params:
|
||||
template_ = pointer entity template allocated by EntityManager.
|
||||
*/
|
||||
export void freeTemplate(EntityTemplate* template_)
|
||||
export void freeTemplate(EntityTemplate* template_) @nogc nothrow
|
||||
{
|
||||
Mallocator.dispose(template_.entity_data);
|
||||
Mallocator.dispose(template_);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue