using Content.Shared.EntityTable.EntitySelectors;
using Content.Shared.GameTicking;
using Robust.Shared.Prototypes;
namespace Content.Shared.EntityTable.Conditions;
///
/// Condition that passes only if the current round time falls between the minimum and maximum time values.
///
public sealed partial class RoundDurationCondition : EntityTableCondition
{
///
/// Minimum time the round must have gone on for this condition to pass.
///
[DataField]
public TimeSpan Min = TimeSpan.Zero;
///
/// Maximum amount of time the round could go on for this condition to pass.
///
[DataField]
public TimeSpan Max = TimeSpan.MaxValue;
protected override bool EvaluateImplementation(EntityTableSelector root,
IEntityManager entMan,
IPrototypeManager proto,
EntityTableContext ctx)
{
var gameTicker = entMan.System();
var duration = gameTicker.RoundDuration();
return duration >= Min && duration <= Max;
}
}