Fix unregisterSystem function
and add function to get m_system_pointer from System
This commit is contained in:
parent
9bf6f84d45
commit
0702b007d1
3 changed files with 78 additions and 16 deletions
|
|
@ -97,38 +97,92 @@ struct System
|
|||
return m_system_pointer != null;
|
||||
}
|
||||
|
||||
/************************************************************************************************************************
|
||||
Return pointer to user side system object
|
||||
*/
|
||||
export void* ptr() nothrow @nogc
|
||||
{
|
||||
return m_system_pointer;
|
||||
}
|
||||
|
||||
package:
|
||||
|
||||
void destroy()
|
||||
///destory system. Dispose all data
|
||||
void destroy() nothrow @nogc
|
||||
{
|
||||
import bubel.ecs.std : Mallocator;
|
||||
|
||||
destroySystemData();
|
||||
|
||||
if (m_name)
|
||||
{
|
||||
Mallocator.dispose(m_name);
|
||||
m_name = null;
|
||||
}
|
||||
}
|
||||
|
||||
///destroy all system data but keeps name which is used for case of system re-registration
|
||||
void destroySystemData() nothrow @nogc
|
||||
{
|
||||
import bubel.ecs.std : Mallocator;
|
||||
disable();
|
||||
if (m_destroy)
|
||||
(cast(void function(void*)) m_destroy)(m_system_pointer);
|
||||
{
|
||||
(cast(void function(void*) nothrow @nogc) m_destroy)(m_system_pointer);
|
||||
m_destroy = null;
|
||||
}
|
||||
|
||||
if (m_name)
|
||||
Mallocator.dispose(m_name);
|
||||
if (m_components)
|
||||
{
|
||||
Mallocator.dispose(m_components);
|
||||
m_components = null;
|
||||
}
|
||||
if (m_excluded_components)
|
||||
{
|
||||
Mallocator.dispose(m_excluded_components);
|
||||
m_excluded_components = null;
|
||||
}
|
||||
if (m_optional_components)
|
||||
{
|
||||
Mallocator.dispose(m_optional_components);
|
||||
m_optional_components = null;
|
||||
}
|
||||
if (jobs)
|
||||
{
|
||||
Mallocator.dispose(jobs);
|
||||
jobs = null;
|
||||
}
|
||||
if (m_read_only_components)
|
||||
{
|
||||
Mallocator.dispose(m_read_only_components);
|
||||
m_read_only_components = null;
|
||||
}
|
||||
if (m_writable_components)
|
||||
{
|
||||
Mallocator.dispose(m_writable_components);
|
||||
m_writable_components = null;
|
||||
}
|
||||
if (m_readonly_dependencies)
|
||||
{
|
||||
Mallocator.dispose(m_readonly_dependencies);
|
||||
m_readonly_dependencies = null;
|
||||
}
|
||||
if (m_writable_dependencies)
|
||||
{
|
||||
Mallocator.dispose(m_writable_dependencies);
|
||||
m_writable_dependencies = null;
|
||||
}
|
||||
if (m_event_callers)
|
||||
{
|
||||
Mallocator.dispose(m_event_callers);
|
||||
m_event_callers = null;
|
||||
}
|
||||
|
||||
if (m_system_pointer)
|
||||
{
|
||||
Mallocator.dispose(m_system_pointer);
|
||||
m_system_pointer = null;
|
||||
}
|
||||
}
|
||||
|
||||
struct EventCaller
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue