2022-01-30 13:49:56 +13:00
|
|
|
using Content.Shared.Doors.Components;
|
|
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
using Robust.Shared.GameStates;
|
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace Content.Shared.Doors.Systems;
|
|
|
|
|
|
|
|
|
|
public abstract class SharedAirlockSystem : EntitySystem
|
|
|
|
|
{
|
|
|
|
|
[Dependency] protected readonly SharedDoorSystem DoorSystem = default!;
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<SharedAirlockComponent, ComponentGetState>(OnGetState);
|
|
|
|
|
SubscribeLocalEvent<SharedAirlockComponent, ComponentHandleState>(OnHandleState);
|
|
|
|
|
SubscribeLocalEvent<SharedAirlockComponent, BeforeDoorClosedEvent>(OnBeforeDoorClosed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnGetState(EntityUid uid, SharedAirlockComponent 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, SharedAirlockComponent airlock, ref ComponentHandleState args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Current is not AirlockComponentState state)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
airlock.Safety = state.Safety;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void OnBeforeDoorClosed(EntityUid uid, SharedAirlockComponent airlock, BeforeDoorClosedEvent args)
|
|
|
|
|
{
|
2022-02-25 19:32:35 +13:00
|
|
|
if (!airlock.Safety)
|
|
|
|
|
args.PerformCollisionCheck = false;
|
2022-01-30 13:49:56 +13:00
|
|
|
}
|
2022-02-09 03:13:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
public void UpdateEmergencyLightStatus(SharedAirlockComponent component)
|
|
|
|
|
{
|
|
|
|
|
if (TryComp<AppearanceComponent>(component.Owner, out var appearanceComponent))
|
|
|
|
|
{
|
|
|
|
|
appearanceComponent.SetData(DoorVisuals.EmergencyLights, component.EmergencyAccess);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ToggleEmergencyAccess(SharedAirlockComponent component)
|
|
|
|
|
{
|
|
|
|
|
component.EmergencyAccess = !component.EmergencyAccess;
|
|
|
|
|
UpdateEmergencyLightStatus(component);
|
|
|
|
|
}
|
2022-01-30 13:49:56 +13:00
|
|
|
}
|