Mega Antag Refactor (#25786)

* Mega Antag Refactor

* last minute delta save

* more workshopping

* more shit

* ok tested this for once

* okkkkk sure

* generic delays for starting rules

* well darn

* nukies partially

* ouagh

* ballin' faded and smonkin wed

* obliterated the diff

* Spread my arms and soak up congratulations

* I've got plenty of love, but nothing to show for it

* but there’s too much sunlight
Shining on my laptop monitor, so I
Can’t see anything with any amount of clarity

* ok this junk

* OOK!

* fubar

* most of sloth's review

* oh boy

* eek

* hell yea!

* ASDFJASDJFvsakcvjkzjnhhhyh
This commit is contained in:
Nemanja
2024-04-24 21:31:45 -04:00
committed by GitHub
parent 771661f478
commit 161fd6c83c
99 changed files with 1931 additions and 2310 deletions

View File

@@ -1,6 +1,6 @@
using System.Linq;
using Content.Server.Administration;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.GameTicking.Components;
using Content.Shared.Administration;
using Content.Shared.Database;
using Content.Shared.Prototypes;
@@ -102,6 +102,22 @@ public sealed partial class GameTicker
if (MetaData(ruleEntity).EntityPrototype?.ID is not { } id) // you really fucked up
return false;
// If we already have it, then we just skip the delay as it has already happened.
if (!RemComp<DelayedStartRuleComponent>(ruleEntity) && ruleData.Delay != null)
{
var delayTime = TimeSpan.FromSeconds(ruleData.Delay.Value.Next(_robustRandom));
if (delayTime > TimeSpan.Zero)
{
_sawmill.Info($"Queued start for game rule {ToPrettyString(ruleEntity)} with delay {delayTime}");
_adminLogger.Add(LogType.EventStarted, $"Queued start for game rule {ToPrettyString(ruleEntity)} with delay {delayTime}");
var delayed = EnsureComp<DelayedStartRuleComponent>(ruleEntity);
delayed.RuleStartTime = _gameTiming.CurTime + (delayTime);
return true;
}
}
_allPreviousGameRules.Add((RoundDuration(), id));
_sawmill.Info($"Started game rule {ToPrettyString(ruleEntity)}");
_adminLogger.Add(LogType.EventStarted, $"Started game rule {ToPrettyString(ruleEntity)}");
@@ -255,6 +271,18 @@ public sealed partial class GameTicker
}
}
private void UpdateGameRules()
{
var query = EntityQueryEnumerator<DelayedStartRuleComponent, GameRuleComponent>();
while (query.MoveNext(out var uid, out var delay, out var rule))
{
if (_gameTiming.CurTime < delay.RuleStartTime)
continue;
StartGameRule(uid, rule);
}
}
#region Command Implementations
[AdminCommand(AdminFlags.Fun)]
@@ -323,38 +351,3 @@ public sealed partial class GameTicker
#endregion
}
/*
/// <summary>
/// Raised broadcast when a game rule is selected, but not started yet.
/// </summary>
public sealed class GameRuleAddedEvent
{
public GameRulePrototype Rule { get; }
public GameRuleAddedEvent(GameRulePrototype rule)
{
Rule = rule;
}
}
public sealed class GameRuleStartedEvent
{
public GameRulePrototype Rule { get; }
public GameRuleStartedEvent(GameRulePrototype rule)
{
Rule = rule;
}
}
public sealed class GameRuleEndedEvent
{
public GameRulePrototype Rule { get; }
public GameRuleEndedEvent(GameRulePrototype rule)
{
Rule = rule;
}
}
*/