Separate game rule enabling and game rule starting (#6168)

This commit is contained in:
mirrorcult
2022-02-15 20:06:28 -07:00
committed by GitHub
parent e427381be6
commit 3abc7a443e
13 changed files with 125 additions and 52 deletions

View File

@@ -27,8 +27,9 @@ public abstract class GameRuleSystem : EntitySystem
base.Initialize();
SubscribeLocalEvent<GameRuleAddedEvent>(OnGameRuleAdded);
SubscribeLocalEvent<GameRuleRemovedEvent>(OnGameRuleRemoved);
SubscribeLocalEvent<GameRuleStartedEvent>(OnGameRuleStarted);
SubscribeLocalEvent<GameRuleEndedEvent>(OnGameRuleEnded);
}
private void OnGameRuleAdded(GameRuleAddedEvent ev)
@@ -37,25 +38,32 @@ public abstract class GameRuleSystem : EntitySystem
return;
Enabled = true;
Added();
}
private void OnGameRuleRemoved(GameRuleRemovedEvent ev)
private void OnGameRuleStarted(GameRuleStartedEvent ev)
{
if (ev.Rule.ID != Prototype)
return;
Started();
}
private void OnGameRuleEnded(GameRuleEndedEvent ev)
{
if (ev.Rule.ID != Prototype)
return;
Enabled = false;
Removed();
Ended();
}
/// <summary>
/// Called when the game rule has been added and this system has been enabled.
/// Called when the game rule has been started..
/// </summary>
public abstract void Added();
public abstract void Started();
/// <summary>
/// Called when the game rule has been removed and this system has been disabled.
/// Called when the game rule has ended..
/// </summary>
public abstract void Removed();
public abstract void Ended();
}