Skip to content

Commit

Permalink
Allow systems to be immediately dismissed.
Browse files Browse the repository at this point in the history
  • Loading branch information
isadorasophia committed Nov 9, 2023
1 parent 4269651 commit 9c2ab47
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Bang/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -582,22 +582,22 @@ public bool ActivateSystem(Type t)
/// <summary>
/// Deactivate a system within our world.
/// </summary>
public bool DeactivateSystem<T>()
public bool DeactivateSystem<T>(bool immediately = false)
{
return DeactivateSystem(typeof(T));
return DeactivateSystem(typeof(T), immediately);
}

/// <summary>
/// Deactivate a system within our world.
/// </summary>
public bool DeactivateSystem(Type t)
public bool DeactivateSystem(Type t, bool immediately = false)
{
if (!_typeToSystems.TryGetValue(t, out int id))
{
return false;
}

return DeactivateSystem(id);
return DeactivateSystem(id, immediately);
}

/// <summary>
Expand Down Expand Up @@ -743,6 +743,7 @@ public bool DeactivateSystem(int id, bool immediately = false)
// We do not remove it from the list of startup systems, since it was already initialized.

ISystem system = IdToSystem[id];
if (system is IStartupSystem) _cachedStartupSystems.Remove(id);
if (system is IUpdateSystem) _cachedExecuteSystems.Remove(id);
if (system is IFixedUpdateSystem) _cachedFixedExecuteSystems.Remove(id);
if (system is IRenderSystem) _cachedRenderSystems.Remove(id);
Expand Down

0 comments on commit 9c2ab47

Please sign in to comment.