2025-05-31 14:31:44 +03:00
|
|
|
using Content.Shared._CP14.DayCycle;
|
2024-07-15 23:18:14 +03:00
|
|
|
using Content.Shared.Random.Rules;
|
|
|
|
|
|
|
|
|
|
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>
|
2025-05-31 14:31:44 +03:00
|
|
|
public sealed partial class CP14IsNight : RulesRule
|
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>();
|
2025-05-31 14:31:44 +03:00
|
|
|
var dayCycle = entManager.System<CP14DayCycleSystem>();
|
2024-08-10 08:12:13 +10:00
|
|
|
|
2024-10-06 18:04:18 +03:00
|
|
|
var map = transform.GetMap(uid);
|
2025-05-31 14:31:44 +03:00
|
|
|
|
|
|
|
|
if (map is null)
|
2025-01-05 19:08:35 +03:00
|
|
|
return false;
|
|
|
|
|
|
2025-05-31 14:31:44 +03:00
|
|
|
var lightLevel = dayCycle.GetLightLevel(map.Value);
|
2025-03-19 12:52:37 +03:00
|
|
|
|
2025-05-31 14:31:44 +03:00
|
|
|
return Inverted ? lightLevel < 0.5 : lightLevel >= 0.5;
|
2024-07-15 23:18:14 +03:00
|
|
|
}
|
|
|
|
|
}
|