Revert "Gamerule Entities" (#15724)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Linq;
|
||||
using Content.Server.GameTicking.Presets;
|
||||
using Content.Server.GameTicking.Rules.Components;
|
||||
using Content.Server.GameTicking.Rules.Configurations;
|
||||
using Content.Shared.Random;
|
||||
using Content.Shared.Random.Helpers;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -7,28 +8,25 @@ using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.GameTicking.Rules;
|
||||
|
||||
public sealed class SecretRuleSystem : GameRuleSystem<SecretRuleComponent>
|
||||
public sealed class SecretRuleSystem : GameRuleSystem
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly GameTicker _ticker = default!;
|
||||
|
||||
protected override void Started(EntityUid uid, SecretRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
|
||||
public override string Prototype => "Secret";
|
||||
|
||||
public override void Started()
|
||||
{
|
||||
base.Started(uid, component, gameRule, args);
|
||||
PickRule(component);
|
||||
PickRule();
|
||||
}
|
||||
|
||||
protected override void Ended(EntityUid uid, SecretRuleComponent component, GameRuleComponent gameRule, GameRuleEndedEvent args)
|
||||
public override void Ended()
|
||||
{
|
||||
base.Ended(uid, component, gameRule, args);
|
||||
|
||||
foreach (var rule in component.AdditionalGameRules)
|
||||
{
|
||||
GameTicker.EndGameRule(rule);
|
||||
}
|
||||
// Preset should already handle it.
|
||||
}
|
||||
|
||||
private void PickRule(SecretRuleComponent component)
|
||||
private void PickRule()
|
||||
{
|
||||
// TODO: This doesn't consider what can't start due to minimum player count, but currently there's no way to know anyway.
|
||||
// as they use cvars.
|
||||
@@ -37,8 +35,7 @@ public sealed class SecretRuleSystem : GameRuleSystem<SecretRuleComponent>
|
||||
|
||||
foreach (var rule in _prototypeManager.Index<GamePresetPrototype>(preset).Rules)
|
||||
{
|
||||
GameTicker.StartGameRule(rule, out var ruleEnt);
|
||||
component.AdditionalGameRules.Add(ruleEnt);
|
||||
_ticker.StartGameRule(_prototypeManager.Index<GameRulePrototype>(rule));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user