Fix firelock door init (#6384)
This commit is contained in:
@@ -34,15 +34,18 @@ namespace Content.Server.Doors.Systems
|
|||||||
appearanceComponent.SetData(DoorVisuals.Powered, args.Powered);
|
appearanceComponent.SetData(DoorVisuals.Powered, args.Powered);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!TryComp(uid, out DoorComponent? door))
|
||||||
|
return;
|
||||||
|
|
||||||
if (!args.Powered)
|
if (!args.Powered)
|
||||||
{
|
{
|
||||||
// stop any scheduled auto-closing
|
// stop any scheduled auto-closing
|
||||||
DoorSystem.SetNextStateChange(uid, null);
|
if (door.State == DoorState.Open)
|
||||||
|
DoorSystem.SetNextStateChange(uid, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// door received power. Lets "wake" the door up, in case it is currently open and needs to auto-close.
|
UpdateAutoClose(uid, door: door);
|
||||||
DoorSystem.SetNextStateChange(uid, TimeSpan.FromSeconds(1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// BoltLights also got out
|
// BoltLights also got out
|
||||||
|
|||||||
@@ -28,11 +28,9 @@ public sealed class DoorComponent : Component
|
|||||||
/// This should never be set directly.
|
/// This should never be set directly.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("state")]
|
||||||
public DoorState State = DoorState.Closed;
|
public DoorState State = DoorState.Closed;
|
||||||
|
|
||||||
[DataField("startOpen")]
|
|
||||||
public readonly bool StartOpen = false;
|
|
||||||
|
|
||||||
#region Timing
|
#region Timing
|
||||||
// if you want do dynamically adjust these times, you need to add networking for them. So for now, they are all
|
// if you want do dynamically adjust these times, you need to add networking for them. So for now, they are all
|
||||||
// read-only.
|
// read-only.
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ public abstract class SharedDoorSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<DoorComponent, ComponentStartup>(OnStartup);
|
SubscribeLocalEvent<DoorComponent, ComponentInit>(OnInit);
|
||||||
SubscribeLocalEvent<DoorComponent, ComponentShutdown>(OnShutdown);
|
SubscribeLocalEvent<DoorComponent, ComponentRemove>(OnRemove);
|
||||||
|
|
||||||
SubscribeLocalEvent<DoorComponent, ComponentGetState>(OnGetState);
|
SubscribeLocalEvent<DoorComponent, ComponentGetState>(OnGetState);
|
||||||
SubscribeLocalEvent<DoorComponent, ComponentHandleState>(OnHandleState);
|
SubscribeLocalEvent<DoorComponent, ComponentHandleState>(OnHandleState);
|
||||||
@@ -59,26 +59,22 @@ public abstract class SharedDoorSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<DoorComponent, PreventCollideEvent>(PreventCollision);
|
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 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
|
if (TryComp(uid, out PhysicsComponent? physics))
|
||||||
OnPartialOpen(uid, door);
|
physics.CanCollide = false;
|
||||||
|
|
||||||
// THEN set the correct state, inc disabling partial = true
|
if (door.Occludes && TryComp(uid, out OccluderComponent? occluder))
|
||||||
SetState(uid, DoorState.Open, door);
|
occluder.Enabled = false;
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateAppearance(uid, door);
|
UpdateAppearance(uid, door);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnShutdown(EntityUid uid, DoorComponent door, ComponentShutdown args)
|
private void OnRemove(EntityUid uid, DoorComponent door, ComponentRemove args)
|
||||||
{
|
{
|
||||||
_activeDoors.Remove(door);
|
_activeDoors.Remove(door);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
closeTimeTwo: 0.6
|
closeTimeTwo: 0.6
|
||||||
openTimeOne: 0.1
|
openTimeOne: 0.1
|
||||||
openTimeTwo: 0.6
|
openTimeTwo: 0.6
|
||||||
startOpen: true
|
state: Open
|
||||||
bumpOpen: false
|
bumpOpen: false
|
||||||
clickOpen: false
|
clickOpen: false
|
||||||
crushDamage:
|
crushDamage:
|
||||||
|
|||||||
@@ -31,4 +31,4 @@
|
|||||||
suffix: Open
|
suffix: Open
|
||||||
components:
|
components:
|
||||||
- type: Door
|
- type: Door
|
||||||
startOpen: true
|
state: Open
|
||||||
|
|||||||
@@ -86,7 +86,7 @@
|
|||||||
suffix: Open
|
suffix: Open
|
||||||
components:
|
components:
|
||||||
- type: Door
|
- type: Door
|
||||||
startOpen: true
|
state: Open
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: ShuttersRadiation
|
id: ShuttersRadiation
|
||||||
@@ -108,7 +108,7 @@
|
|||||||
suffix: Open
|
suffix: Open
|
||||||
components:
|
components:
|
||||||
- type: Door
|
- type: Door
|
||||||
startOpen: true
|
state: Open
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: ShuttersWindow
|
id: ShuttersWindow
|
||||||
@@ -129,4 +129,4 @@
|
|||||||
suffix: Open
|
suffix: Open
|
||||||
components:
|
components:
|
||||||
- type: Door
|
- type: Door
|
||||||
startOpen: true
|
state: Open
|
||||||
|
|||||||
Reference in New Issue
Block a user