Refactor IDoorCheck into entity events (#4366)

* IDoorCheck refactored to events

# Conflicts:
#	Content.Server/Atmos/TileAtmosphere.cs
#	Content.Server/Doors/Components/AirlockComponent.cs
#	Content.Server/Doors/Components/FirelockComponent.cs
#	Content.Server/Doors/Components/ServerDoorComponent.cs
#	Content.Server/Doors/IDoorCheck.cs

* namespaces

* Fix mapinit bug with refreshautoclose

* ok i guess these just didnt feel like staging today
This commit is contained in:
mirrorcult
2021-08-02 04:57:06 -07:00
committed by GitHub
parent 7e3d5f6cf1
commit af2e21c355
14 changed files with 545 additions and 338 deletions

View File

@@ -0,0 +1,69 @@
using Content.Server.Doors.Components;
using Content.Shared.Doors;
using Content.Shared.Notification.Managers;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
namespace Content.Server.Doors.Systems
{
public class FirelockSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<FirelockComponent, BeforeDoorOpenedEvent>(OnBeforeDoorOpened);
SubscribeLocalEvent<FirelockComponent, BeforeDoorDeniedEvent>(OnBeforeDoorDenied);
SubscribeLocalEvent<FirelockComponent, DoorGetPryTimeModifierEvent>(OnDoorGetPryTimeModifier);
SubscribeLocalEvent<FirelockComponent, DoorClickShouldActivateEvent>(OnDoorClickShouldActivate);
SubscribeLocalEvent<FirelockComponent, BeforeDoorPryEvent>(OnBeforeDoorPry);
SubscribeLocalEvent<FirelockComponent, BeforeDoorAutoCloseEvent>(OnBeforeDoorAutoclose);
}
private void OnBeforeDoorOpened(EntityUid uid, FirelockComponent component, BeforeDoorOpenedEvent args)
{
if (component.IsHoldingFire() || component.IsHoldingPressure())
args.Cancel();
}
private void OnBeforeDoorDenied(EntityUid uid, FirelockComponent component, BeforeDoorDeniedEvent args)
{
args.Cancel();
}
private void OnDoorGetPryTimeModifier(EntityUid uid, FirelockComponent component, DoorGetPryTimeModifierEvent args)
{
if (component.IsHoldingFire() || component.IsHoldingPressure())
args.PryTimeModifier *= component.LockedPryTimeModifier;
}
private void OnDoorClickShouldActivate(EntityUid uid, FirelockComponent component, DoorClickShouldActivateEvent args)
{
// We're a firelock, you can't click to open it
args.Handled = true;
}
private void OnBeforeDoorPry(EntityUid uid, FirelockComponent component, BeforeDoorPryEvent args)
{
if (component.DoorComponent == null || component.DoorComponent.State != SharedDoorComponent.DoorState.Closed)
{
return;
}
if (component.IsHoldingPressure())
{
component.Owner.PopupMessage(args.Args.User, Loc.GetString("firelock-component-is-holding-pressure-message"));
}
else if (component.IsHoldingFire())
{
component.Owner.PopupMessage(args.Args.User, Loc.GetString("firelock-component-is-holding-fire-message"));
}
}
private void OnBeforeDoorAutoclose(EntityUid uid, FirelockComponent component, BeforeDoorAutoCloseEvent args)
{
// Firelocks can't autoclose, they must be manually closed
args.Cancel();
}
}
}