diff --git a/Content.Server/Doors/Systems/AirlockSystem.cs b/Content.Server/Doors/Systems/AirlockSystem.cs index 6d3af798d1..9dd46ceafb 100644 --- a/Content.Server/Doors/Systems/AirlockSystem.cs +++ b/Content.Server/Doors/Systems/AirlockSystem.cs @@ -34,15 +34,18 @@ namespace Content.Server.Doors.Systems appearanceComponent.SetData(DoorVisuals.Powered, args.Powered); } + if (!TryComp(uid, out DoorComponent? door)) + return; + if (!args.Powered) { // stop any scheduled auto-closing - DoorSystem.SetNextStateChange(uid, null); + if (door.State == DoorState.Open) + DoorSystem.SetNextStateChange(uid, null); } else { - // door received power. Lets "wake" the door up, in case it is currently open and needs to auto-close. - DoorSystem.SetNextStateChange(uid, TimeSpan.FromSeconds(1)); + UpdateAutoClose(uid, door: door); } // BoltLights also got out diff --git a/Content.Shared/Doors/Components/DoorComponent.cs b/Content.Shared/Doors/Components/DoorComponent.cs index 7fc65fa8e0..5091502444 100644 --- a/Content.Shared/Doors/Components/DoorComponent.cs +++ b/Content.Shared/Doors/Components/DoorComponent.cs @@ -28,11 +28,9 @@ public sealed class DoorComponent : Component /// This should never be set directly. /// [ViewVariables(VVAccess.ReadWrite)] + [DataField("state")] public DoorState State = DoorState.Closed; - [DataField("startOpen")] - public readonly bool StartOpen = false; - #region Timing // if you want do dynamically adjust these times, you need to add networking for them. So for now, they are all // read-only. diff --git a/Content.Shared/Doors/Systems/SharedDoorSystem.cs b/Content.Shared/Doors/Systems/SharedDoorSystem.cs index 1fe8b40953..fb9f95decc 100644 --- a/Content.Shared/Doors/Systems/SharedDoorSystem.cs +++ b/Content.Shared/Doors/Systems/SharedDoorSystem.cs @@ -46,8 +46,8 @@ public abstract class SharedDoorSystem : EntitySystem { base.Initialize(); - SubscribeLocalEvent(OnStartup); - SubscribeLocalEvent(OnShutdown); + SubscribeLocalEvent(OnInit); + SubscribeLocalEvent(OnRemove); SubscribeLocalEvent(OnGetState); SubscribeLocalEvent(OnHandleState); @@ -59,26 +59,22 @@ public abstract class SharedDoorSystem : EntitySystem SubscribeLocalEvent(PreventCollision); } - private void OnStartup(EntityUid uid, DoorComponent door, ComponentStartup args) + private void OnInit(EntityUid uid, DoorComponent door, ComponentInit args) { // if the door state is not standard (i.e., door starts open), make sure collision & occlusion are properly set. - if (door.StartOpen) + if (door.State == DoorState.Open) { - // disable occluder & physics - OnPartialOpen(uid, door); - - // THEN set the correct state, inc disabling partial = true - SetState(uid, DoorState.Open, door); - - // The airlock component may schedule an auto-close for this door during the SetState. - // Give the door is supposed to start open, let's prevent any auto-closing that might occur. - door.NextStateChange = null; + if (TryComp(uid, out PhysicsComponent? physics)) + physics.CanCollide = false; + + if (door.Occludes && TryComp(uid, out OccluderComponent? occluder)) + occluder.Enabled = false; } UpdateAppearance(uid, door); } - private void OnShutdown(EntityUid uid, DoorComponent door, ComponentShutdown args) + private void OnRemove(EntityUid uid, DoorComponent door, ComponentRemove args) { _activeDoors.Remove(door); } diff --git a/Resources/Prototypes/Entities/Structures/Doors/Firelocks/firelock.yml b/Resources/Prototypes/Entities/Structures/Doors/Firelocks/firelock.yml index 9a34713969..9dd961e31f 100644 --- a/Resources/Prototypes/Entities/Structures/Doors/Firelocks/firelock.yml +++ b/Resources/Prototypes/Entities/Structures/Doors/Firelocks/firelock.yml @@ -61,7 +61,7 @@ closeTimeTwo: 0.6 openTimeOne: 0.1 openTimeTwo: 0.6 - startOpen: true + state: Open bumpOpen: false clickOpen: false crushDamage: diff --git a/Resources/Prototypes/Entities/Structures/Doors/Shutter/blast_door.yml b/Resources/Prototypes/Entities/Structures/Doors/Shutter/blast_door.yml index d723241b78..5f9b3a7cf2 100644 --- a/Resources/Prototypes/Entities/Structures/Doors/Shutter/blast_door.yml +++ b/Resources/Prototypes/Entities/Structures/Doors/Shutter/blast_door.yml @@ -31,4 +31,4 @@ suffix: Open components: - type: Door - startOpen: true + state: Open diff --git a/Resources/Prototypes/Entities/Structures/Doors/Shutter/shutters.yml b/Resources/Prototypes/Entities/Structures/Doors/Shutter/shutters.yml index 0b3caf3990..5f1440d3bc 100644 --- a/Resources/Prototypes/Entities/Structures/Doors/Shutter/shutters.yml +++ b/Resources/Prototypes/Entities/Structures/Doors/Shutter/shutters.yml @@ -86,7 +86,7 @@ suffix: Open components: - type: Door - startOpen: true + state: Open - type: entity id: ShuttersRadiation @@ -108,7 +108,7 @@ suffix: Open components: - type: Door - startOpen: true + state: Open - type: entity id: ShuttersWindow @@ -129,4 +129,4 @@ suffix: Open components: - type: Door - startOpen: true + state: Open