Update trivial components to use auto comp states (#20539)

This commit is contained in:
DrSmugleaf
2023-09-28 16:20:29 -07:00
committed by GitHub
parent 14cfe44ece
commit a44fa86b68
158 changed files with 806 additions and 2866 deletions

View File

@@ -1,6 +1,4 @@
using System.Threading;
using Content.Shared.Cooldown;
using Robust.Shared.GameStates;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
@@ -16,8 +14,7 @@ public sealed class UseDelaySystem : EntitySystem
{
base.Initialize();
SubscribeLocalEvent<UseDelayComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<UseDelayComponent, ComponentHandleState>(OnHandleState);
SubscribeLocalEvent<UseDelayComponent, AfterAutoHandleStateEvent>(OnHandleState);
SubscribeLocalEvent<UseDelayComponent, EntityPausedEvent>(OnPaused);
SubscribeLocalEvent<UseDelayComponent, EntityUnpausedEvent>(OnUnpaused);
@@ -45,26 +42,14 @@ public sealed class UseDelaySystem : EntitySystem
_activeDelays.Add(component);
}
private void OnHandleState(EntityUid uid, UseDelayComponent component, ref ComponentHandleState args)
private void OnHandleState(EntityUid uid, UseDelayComponent component, ref AfterAutoHandleStateEvent args)
{
if (args.Current is not UseDelayComponentState state)
return;
component.LastUseTime = state.LastUseTime;
component.Delay = state.Delay;
component.DelayEndTime = state.DelayEndTime;
if (component.DelayEndTime == null)
_activeDelays.Remove(component);
else
_activeDelays.Add(component);
}
private void OnGetState(EntityUid uid, UseDelayComponent component, ref ComponentGetState args)
{
args.State = new UseDelayComponentState(component.LastUseTime, component.Delay, component.DelayEndTime);
}
public override void Update(float frameTime)
{
base.Update(frameTime);