Refactor SeeingRainbows to new status effect system (#38620)

This commit is contained in:
Red
2025-06-27 21:19:04 +03:00
committed by GitHub
parent ad2616a53f
commit bb116e3219
14 changed files with 110 additions and 100 deletions

View File

@@ -1,7 +1,5 @@
using Content.Shared.Bed.Sleep;
using Content.Shared.Drowsiness;
using Content.Shared.StatusEffectNew;
using Content.Shared.StatusEffectNew.Components;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
@@ -23,8 +21,6 @@ public sealed class DrowsinessOverlay : Overlay
public override bool RequestScreenTexture => true;
private readonly ShaderInstance _drowsinessShader;
private EntityQuery<StatusEffectComponent> _statusQuery;
public float CurrentPower = 0.0f;
private const float PowerDivisor = 250.0f;
@@ -34,9 +30,9 @@ public sealed class DrowsinessOverlay : Overlay
public DrowsinessOverlay()
{
IoCManager.InjectDependencies(this);
_statusEffects = _sysMan.GetEntitySystem<SharedStatusEffectsSystem>();
_statusQuery = _entityManager.GetEntityQuery<StatusEffectComponent>();
_drowsinessShader = _prototypeManager.Index<ShaderPrototype>("Drowsiness").InstanceUnique();
}
@@ -47,22 +43,11 @@ public sealed class DrowsinessOverlay : Overlay
if (playerEntity == null)
return;
if (!_statusEffects.TryEffectsWithComp<DrowsinessStatusEffectComponent>(playerEntity, out var drowsinessEffects))
if (!_statusEffects.TryGetEffectsEndTimeWithComp<DrowsinessStatusEffectComponent>(playerEntity, out var endTime))
return;
TimeSpan? remainingTime = TimeSpan.Zero;
foreach (var (_, _, statusEffectComp) in drowsinessEffects)
{
if (statusEffectComp.EndEffectTime > remainingTime)
remainingTime = statusEffectComp.EndEffectTime;
}
if (remainingTime is null)
return;
var curTime = _timing.CurTime;
var timeLeft = (float)(remainingTime - curTime).Value.TotalSeconds;
endTime ??= TimeSpan.MaxValue;
var timeLeft = (float)(endTime - _timing.CurTime).Value.TotalSeconds;
CurrentPower += 8f * (0.5f * timeLeft - CurrentPower) * args.DeltaSeconds / (timeLeft + 1);
}