Demos #10

Merged
Mergul merged 39 commits from Demos into master 2020-05-28 18:48:45 +02:00
Showing only changes of commit dd491302af - Show all commits

View file

@ -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_);