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,5 @@
using Content.Shared.Doors.Components;
using Content.Shared.Popups;
using Robust.Shared.GameStates;
namespace Content.Shared.Doors.Systems;
@@ -14,32 +13,15 @@ public abstract class SharedAirlockSystem : EntitySystem
{
base.Initialize();
SubscribeLocalEvent<AirlockComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<AirlockComponent, ComponentHandleState>(OnHandleState);
SubscribeLocalEvent<AirlockComponent, BeforeDoorClosedEvent>(OnBeforeDoorClosed);
}
private void OnGetState(EntityUid uid, AirlockComponent airlock, ref ComponentGetState args)
{
// Need to network airlock safety state to avoid mis-predicts when a door auto-closes as the client walks through the door.
args.State = new AirlockComponentState(airlock.Safety);
}
private void OnHandleState(EntityUid uid, AirlockComponent airlock, ref ComponentHandleState args)
{
if (args.Current is not AirlockComponentState state)
return;
airlock.Safety = state.Safety;
}
protected virtual void OnBeforeDoorClosed(EntityUid uid, AirlockComponent airlock, BeforeDoorClosedEvent args)
{
if (!airlock.Safety)
args.PerformCollisionCheck = false;
}
public void UpdateEmergencyLightStatus(EntityUid uid, AirlockComponent component)
{
Appearance.SetData(uid, DoorVisuals.EmergencyLights, component.EmergencyAccess);