Compare commits
1 commit
| Author | SHA1 | Date | |
|---|---|---|---|
| 01da5f9315 |
2 changed files with 37 additions and 0 deletions
|
|
@ -172,6 +172,8 @@ export struct EntityManager
|
||||||
|
|
||||||
foreach (ref system; systems)
|
foreach (ref system; systems)
|
||||||
{
|
{
|
||||||
|
if (system.isAlive() == false)
|
||||||
|
continue;
|
||||||
if (system.m_empty)
|
if (system.m_empty)
|
||||||
{
|
{
|
||||||
if (system.m_update)
|
if (system.m_update)
|
||||||
|
|
@ -236,6 +238,8 @@ export struct EntityManager
|
||||||
|
|
||||||
foreach (ref system; systems)
|
foreach (ref system; systems)
|
||||||
{
|
{
|
||||||
|
if (system.isAlive() == false)
|
||||||
|
continue;
|
||||||
foreach (caller; system.m_event_callers)
|
foreach (caller; system.m_event_callers)
|
||||||
{
|
{
|
||||||
event_callers[caller.id]++;
|
event_callers[caller.id]++;
|
||||||
|
|
@ -252,6 +256,8 @@ export struct EntityManager
|
||||||
|
|
||||||
foreach (ref system; systems)
|
foreach (ref system; systems)
|
||||||
{
|
{
|
||||||
|
if (system.isAlive() == false)
|
||||||
|
continue;
|
||||||
foreach (caller; system.m_event_callers)
|
foreach (caller; system.m_event_callers)
|
||||||
{
|
{
|
||||||
events[caller.id].callers[event_callers[caller.id]].callback = caller.callback;
|
events[caller.id].callers[event_callers[caller.id]].callback = caller.callback;
|
||||||
|
|
@ -328,6 +334,21 @@ export struct EntityManager
|
||||||
allocator.freeMemory();
|
allocator.freeMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************************************************************************
|
||||||
|
Unregister given system form EntityManager.
|
||||||
|
*/
|
||||||
|
void unregisterSystem(Sys)()
|
||||||
|
{
|
||||||
|
assert(register_state, "unregisterSystem must be called between beginRegister() and endRegister().");
|
||||||
|
ushort system_id = becsID!Sys;
|
||||||
|
System* system = getSystem(system_id);
|
||||||
|
assert(system, "System was not registered");
|
||||||
|
assert(system.isAlive, "System already unregistered");
|
||||||
|
system.destroy();
|
||||||
|
*system = System.init;
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
Same as "void registerSystem(Sys)(int priority, int pass = 0)" but use pass name instead of id.
|
Same as "void registerSystem(Sys)(int priority, int pass = 0)" but use pass name instead of id.
|
||||||
*/
|
*/
|
||||||
|
|
@ -1887,6 +1908,8 @@ export struct EntityManager
|
||||||
|
|
||||||
foreach (i, ref system; systems)
|
foreach (i, ref system; systems)
|
||||||
{
|
{
|
||||||
|
if (system.isAlive() == false)
|
||||||
|
continue;
|
||||||
if (system.m_empty)
|
if (system.m_empty)
|
||||||
continue;
|
continue;
|
||||||
if (system.m_update is null)
|
if (system.m_update is null)
|
||||||
|
|
@ -3095,6 +3118,8 @@ export struct EntityManager
|
||||||
|
|
||||||
foreach (ref system; systems)
|
foreach (ref system; systems)
|
||||||
{
|
{
|
||||||
|
if (system.isAlive() == false)
|
||||||
|
continue;
|
||||||
if (system.enabled && system.m_begin)
|
if (system.enabled && system.m_begin)
|
||||||
system.m_execute = (cast(bool function(void*)) system.m_begin)(
|
system.m_execute = (cast(bool function(void*)) system.m_begin)(
|
||||||
system.m_system_pointer);
|
system.m_system_pointer);
|
||||||
|
|
@ -3109,6 +3134,10 @@ export struct EntityManager
|
||||||
|
|
||||||
foreach (ref system; systems)
|
foreach (ref system; systems)
|
||||||
{
|
{
|
||||||
|
if (system.isAlive() == false)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (system.enabled && system.m_end)
|
if (system.enabled && system.m_end)
|
||||||
(cast(void function(void*)) system.m_end)(system.m_system_pointer);
|
(cast(void function(void*)) system.m_end)(system.m_system_pointer);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,14 @@ struct System
|
||||||
return cast(const(char)[]) m_name;
|
return cast(const(char)[]) m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/************************************************************************************************************************
|
||||||
|
Return false if system was unregistered, true otherwise.
|
||||||
|
*/
|
||||||
|
export bool isAlive() nothrow @nogc
|
||||||
|
{
|
||||||
|
return m_system_pointer != null;
|
||||||
|
}
|
||||||
|
|
||||||
package:
|
package:
|
||||||
|
|
||||||
void destroy()
|
void destroy()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue