2024-09-01 18:14:56 +05:00
|
|
|
using Content.Shared._CP14.DayCycle;
|
2024-10-06 18:04:18 +03:00
|
|
|
using Content.Shared._CP14.DayCycle.Components;
|
2024-07-15 23:18:14 +03:00
|
|
|
using Content.Shared.Random.Rules;
|
2024-10-06 18:04:18 +03:00
|
|
|
using Robust.Shared.Prototypes;
|
2024-07-15 23:18:14 +03:00
|
|
|
|
|
|
|
|
namespace Content.Shared._CP14.Random.Rules;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-10-06 18:04:18 +03:00
|
|
|
/// Checks whether there is a time of day on the current map, and whether the current time of day corresponds to the specified periods.
|
2024-07-15 23:18:14 +03:00
|
|
|
/// </summary>
|
2024-10-06 18:04:18 +03:00
|
|
|
public sealed partial class CP14TimePeriod : RulesRule
|
2024-07-15 23:18:14 +03:00
|
|
|
{
|
2024-10-06 18:04:18 +03:00
|
|
|
[DataField] private List<ProtoId<CP14DayCyclePeriodPrototype>> Periods = new();
|
|
|
|
|
|
2024-07-15 23:18:14 +03:00
|
|
|
public override bool Check(EntityManager entManager, EntityUid uid)
|
|
|
|
|
{
|
2024-10-06 18:04:18 +03:00
|
|
|
var transform = entManager.System<SharedTransformSystem>();
|
2024-08-10 08:12:13 +10:00
|
|
|
|
2024-10-06 18:04:18 +03:00
|
|
|
var map = transform.GetMap(uid);
|
|
|
|
|
return entManager.TryGetComponent<CP14DayCycleComponent>(map, out var dayCycle) && Periods.Contains(dayCycle.CurrentPeriod);
|
2024-07-15 23:18:14 +03:00
|
|
|
}
|
|
|
|
|
}
|