Multiantag Gamemode (#37783)

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Co-authored-by: Southbridge <7013162+southbridge-fur@users.noreply.github.com>
Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com>
This commit is contained in:
Nemanja
2025-08-15 10:06:51 -04:00
committed by GitHub
parent b2c505df6a
commit f23e8c2861
19 changed files with 787 additions and 5 deletions

View File

@@ -0,0 +1,49 @@
using System.ComponentModel.DataAnnotations;
using System.Linq;
using Content.Shared.EntityTable.EntitySelectors;
using Content.Shared.GameTicking;
using Robust.Shared.Prototypes;
namespace Content.Shared.EntityTable.Conditions;
public sealed partial class ReoccurrenceDelayCondition : EntityTableCondition
{
/// <summary>
/// The maximum amount of times this rule can have already be run.
/// </summary>
[DataField]
public TimeSpan Delay = TimeSpan.Zero;
/// <summary>
/// The rule that is being checked for occurrences.
/// If null, it will use the value on the attached selector.
/// </summary>
[DataField]
public EntProtoId? RuleOverride;
protected override bool EvaluateImplementation(EntityTableSelector root,
IEntityManager entMan,
IPrototypeManager proto,
EntityTableContext ctx)
{
string rule;
if (RuleOverride is { } ruleOverride)
{
rule = ruleOverride;
}
else
{
rule = root is EntSelector entSelector
? entSelector.Id
: string.Empty;
}
if (rule == string.Empty)
return false;
var gameTicker = entMan.System<SharedGameTicker>();
return gameTicker.AllPreviousGameRules.Any(
p => p.Item2 == rule && p.Item1 + Delay <= gameTicker.RoundDuration());
}
}