2024-07-15 23:18:14 +03:00
|
|
|
using Content.Shared.Random.Rules;
|
2025-03-19 12:52:37 +03:00
|
|
|
using Robust.Shared.Map.Components;
|
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
|
|
|
{
|
2025-03-19 12:52:37 +03:00
|
|
|
[DataField]
|
|
|
|
|
public float Threshold = 100f;
|
2024-10-06 18:04:18 +03:00
|
|
|
|
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);
|
2025-03-19 12:52:37 +03:00
|
|
|
if (!entManager.TryGetComponent<MapLightComponent>(map, out var light))
|
2025-01-05 19:08:35 +03:00
|
|
|
return false;
|
|
|
|
|
|
2025-03-19 12:52:37 +03:00
|
|
|
var lightColor = light.AmbientLightColor;
|
|
|
|
|
var medium = lightColor.R + lightColor.G + lightColor.B / 3f;
|
|
|
|
|
|
|
|
|
|
return medium > Threshold;
|
2024-07-15 23:18:14 +03:00
|
|
|
}
|
|
|
|
|
}
|