Fix firelock door init (#6384)

This commit is contained in:
Leon Friedrich
2022-01-30 17:47:24 +13:00
committed by GitHub
parent c30e4b36db
commit 1914560773
6 changed files with 22 additions and 25 deletions

View File

@@ -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

View File

@@ -28,11 +28,9 @@ public sealed class DoorComponent : Component
/// This should never be set directly.
/// </remarks>
[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.

View File

@@ -46,8 +46,8 @@ public abstract class SharedDoorSystem : EntitySystem
{
base.Initialize();
SubscribeLocalEvent<DoorComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<DoorComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<DoorComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<DoorComponent, ComponentRemove>(OnRemove);
SubscribeLocalEvent<DoorComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<DoorComponent, ComponentHandleState>(OnHandleState);
@@ -59,26 +59,22 @@ public abstract class SharedDoorSystem : EntitySystem
SubscribeLocalEvent<DoorComponent, PreventCollideEvent>(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);
if (TryComp(uid, out PhysicsComponent? physics))
physics.CanCollide = false;
// 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 (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);
}

View File

@@ -61,7 +61,7 @@
closeTimeTwo: 0.6
openTimeOne: 0.1
openTimeTwo: 0.6
startOpen: true
state: Open
bumpOpen: false
clickOpen: false
crushDamage:

View File

@@ -31,4 +31,4 @@
suffix: Open
components:
- type: Door
startOpen: true
state: Open

View File

@@ -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