Update trivial components to use auto comp states (#20539)
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user