Fixed system reregistration issue and added funtion to allocate EntityTEmplate as copy of different teamplte
This commit is contained in:
parent
9580ee9af9
commit
dd491302af
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);
|
ushort sys_id = systems_map.get(cast(char[]) Sys.stringof, ushort.max);
|
||||||
if (sys_id < systems.length)
|
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)
|
if (system.m_create)
|
||||||
(cast(void function(void*)) system.m_create)(system.m_system_pointer);
|
(cast(void function(void*)) system.m_create)(system.m_system_pointer);
|
||||||
|
|
||||||
|
system.enable();
|
||||||
|
|
||||||
system.m_id = sys_id;
|
system.m_id = sys_id;
|
||||||
|
system.m_name = systems[sys_id].m_name;
|
||||||
systems[sys_id] = system;
|
systems[sys_id] = system;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
system.m_name = Mallocator.makeArray(cast(char[]) Sys.stringof);
|
system.m_name = Mallocator.makeArray(cast(char[]) Sys.stringof);
|
||||||
|
|
||||||
systems_map.add(system.m_name, cast(ushort) systems.length);
|
systems_map.add(system.m_name, cast(ushort) systems.length);
|
||||||
|
|
||||||
system.m_id = cast(ushort)(systems.length);
|
system.m_id = cast(ushort)(systems.length);
|
||||||
|
|
@ -1723,6 +1728,20 @@ export struct EntityManager
|
||||||
return temp;
|
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.
|
Returns entity type info.
|
||||||
|
|
||||||
|
|
@ -2344,7 +2363,7 @@ export struct EntityManager
|
||||||
Params:
|
Params:
|
||||||
template_ = pointer entity template allocated by EntityManager.
|
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_.entity_data);
|
||||||
Mallocator.dispose(template_);
|
Mallocator.dispose(template_);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue