Resolves AirlockVisualizer is Obsolete (#13884)
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using System.Threading;
|
||||
using Content.Shared.Doors.Systems;
|
||||
using Content.Shared.MachineLinking;
|
||||
using Robust.Shared.Audio;
|
||||
@@ -56,8 +55,16 @@ public sealed class AirlockComponent : Component
|
||||
[DataField("keepOpenIfClicked")]
|
||||
public bool KeepOpenIfClicked = false;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the door bolts are currently deployed.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public bool BoltsDown;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the bolt lights are currently enabled.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public bool BoltLightsEnabled = true;
|
||||
|
||||
/// <summary>
|
||||
@@ -86,10 +93,80 @@ public sealed class AirlockComponent : Component
|
||||
public float AutoCloseDelayModifier = 1.0f;
|
||||
|
||||
/// <summary>
|
||||
/// The receiver port for turning off automatic closing.
|
||||
/// The receiver port for turning off automatic closing.
|
||||
/// </summary>
|
||||
[DataField("autoClosePort", customTypeSerializer: typeof(PrototypeIdSerializer<ReceiverPortPrototype>))]
|
||||
public string AutoClosePort = "AutoClose";
|
||||
|
||||
#region Graphics
|
||||
|
||||
/// <summary>
|
||||
/// Whether the door lights should be visible.
|
||||
/// </summary>
|
||||
[DataField("openUnlitVisible")]
|
||||
public bool OpenUnlitVisible = false;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the door should display emergency access lights.
|
||||
/// </summary>
|
||||
[DataField("emergencyAccessLayer")]
|
||||
public bool EmergencyAccessLayer = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not to animate the panel when the door opens or closes.
|
||||
/// </summary>
|
||||
[DataField("animatePanel")]
|
||||
public bool AnimatePanel = true;
|
||||
|
||||
/// <summary>
|
||||
/// The sprite state used to animate the airlock frame when the airlock opens.
|
||||
/// </summary>
|
||||
[DataField("openingSpriteState")]
|
||||
public string OpeningSpriteState = "opening_unlit";
|
||||
|
||||
/// <summary>
|
||||
/// The sprite state used to animate the airlock panel when the airlock opens.
|
||||
/// </summary>
|
||||
[DataField("openingPanelSpriteState")]
|
||||
public string OpeningPanelSpriteState = "panel_opening";
|
||||
|
||||
/// <summary>
|
||||
/// The sprite state used to animate the airlock frame when the airlock closes.
|
||||
/// </summary>
|
||||
[DataField("closingSpriteState")]
|
||||
public string ClosingSpriteState = "closing_unlit";
|
||||
|
||||
/// <summary>
|
||||
/// The sprite state used to animate the airlock panel when the airlock closes.
|
||||
/// </summary>
|
||||
[DataField("closingPanelSpriteState")]
|
||||
public string ClosingPanelSpriteState = "panel_closing";
|
||||
|
||||
/// <summary>
|
||||
/// The sprite state used for the open airlock lights.
|
||||
/// </summary>
|
||||
[DataField("openSpriteState")]
|
||||
public string OpenSpriteState = "open_unlit";
|
||||
|
||||
/// <summary>
|
||||
/// The sprite state used for the closed airlock lights.
|
||||
/// </summary>
|
||||
[DataField("closedSpriteState")]
|
||||
public string ClosedSpriteState = "closed_unlit";
|
||||
|
||||
/// <summary>
|
||||
/// The sprite state used for the 'access denied' lights animation.
|
||||
/// </summary>
|
||||
[DataField("denySpriteState")]
|
||||
public string DenySpriteState = "deny_unlit";
|
||||
|
||||
/// <summary>
|
||||
/// How long the animation played when the airlock denies access is in seconds.
|
||||
/// </summary>
|
||||
[DataField("denyAnimationTime")]
|
||||
public float DenyAnimationTime = 0.3f;
|
||||
|
||||
#endregion Graphics
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Doors.Systems;
|
||||
using Content.Shared.Tools;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Audio;
|
||||
@@ -13,16 +15,17 @@ namespace Content.Shared.Doors.Components;
|
||||
|
||||
[NetworkedComponent]
|
||||
[RegisterComponent]
|
||||
public sealed class DoorComponent : Component, ISerializationHooks
|
||||
public sealed class DoorComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The current state of the door -- whether it is open, closed, opening, or closing.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This should never be set directly.
|
||||
/// This should never be set directly, use <see cref="SharedDoorSystem.SetState(EntityUid, DoorState, DoorComponent?)"/> instead.
|
||||
/// </remarks>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("state")]
|
||||
[Access(typeof(SharedDoorSystem))]
|
||||
public DoorState State = DoorState.Closed;
|
||||
|
||||
#region Timing
|
||||
@@ -139,6 +142,97 @@ public sealed class DoorComponent : Component, ISerializationHooks
|
||||
public HashSet<EntityUid> CurrentlyCrushing = new();
|
||||
#endregion
|
||||
|
||||
#region Graphics
|
||||
|
||||
/// <summary>
|
||||
/// The key used when playing door opening/closing/emagging/deny animations.
|
||||
/// </summary>
|
||||
public const string AnimationKey = "door_animation";
|
||||
|
||||
/// <summary>
|
||||
/// The sprite state used for the door when it's open.
|
||||
/// </summary>
|
||||
[DataField("openSpriteState")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public string OpenSpriteState = "open";
|
||||
|
||||
/// <summary>
|
||||
/// The sprite states used for the door while it's open.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
public List<(DoorVisualLayers, string)> OpenSpriteStates = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The sprite state used for the door when it's closed.
|
||||
/// </summary>
|
||||
[DataField("closedSpriteState")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public string ClosedSpriteState = "closed";
|
||||
|
||||
/// <summary>
|
||||
/// The sprite states used for the door while it's closed.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
public List<(DoorVisualLayers, string)> ClosedSpriteStates = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The sprite state used for the door when it's opening.
|
||||
/// </summary>
|
||||
[DataField("openingSpriteState")]
|
||||
public string OpeningSpriteState = "opening";
|
||||
|
||||
/// <summary>
|
||||
/// The sprite state used for the door when it's closing.
|
||||
/// </summary>
|
||||
[DataField("closingSpriteState")]
|
||||
public string ClosingSpriteState = "closing";
|
||||
|
||||
/// <summary>
|
||||
/// The sprite state used for the door when it's being emagged.
|
||||
/// </summary>
|
||||
[DataField("emaggingSpriteState")]
|
||||
public string EmaggingSpriteState = "emagging";
|
||||
|
||||
/// <summary>
|
||||
/// The sprite state used for the door when it's open.
|
||||
/// </summary>
|
||||
[DataField("openingAnimationTime")]
|
||||
public float OpeningAnimationTime = 0.8f;
|
||||
|
||||
/// <summary>
|
||||
/// The sprite state used for the door when it's open.
|
||||
/// </summary>
|
||||
[DataField("closingAnimationTime")]
|
||||
public float ClosingAnimationTime = 0.8f;
|
||||
|
||||
/// <summary>
|
||||
/// The sprite state used for the door when it's open.
|
||||
/// </summary>
|
||||
[DataField("emaggingAnimationTime")]
|
||||
public float EmaggingAnimationTime = 1.5f;
|
||||
|
||||
/// <summary>
|
||||
/// The animation used when the door opens.
|
||||
/// </summary>
|
||||
public object OpeningAnimation = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The animation used when the door closes.
|
||||
/// </summary>
|
||||
public object ClosingAnimation = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The animation used when the door denies access.
|
||||
/// </summary>
|
||||
public object DenyingAnimation = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The animation used when the door is emagged.
|
||||
/// </summary>
|
||||
public object EmaggingAnimation = default!;
|
||||
|
||||
#endregion Graphics
|
||||
|
||||
#region Serialization
|
||||
/// <summary>
|
||||
/// Time until next state change. Because apparently <see cref="IGameTiming.CurTime"/> might not get saved/restored.
|
||||
@@ -209,7 +303,7 @@ public sealed class DoorComponent : Component, ISerializationHooks
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum DoorState
|
||||
public enum DoorState : byte
|
||||
{
|
||||
Closed,
|
||||
Closing,
|
||||
@@ -221,7 +315,7 @@ public enum DoorState
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum DoorVisuals
|
||||
public enum DoorVisuals : byte
|
||||
{
|
||||
State,
|
||||
Powered,
|
||||
@@ -231,6 +325,14 @@ public enum DoorVisuals
|
||||
BaseRSI,
|
||||
}
|
||||
|
||||
public enum DoorVisualLayers : byte
|
||||
{
|
||||
Base,
|
||||
BaseUnlit,
|
||||
BaseBolted,
|
||||
BaseEmergencyAccess,
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class DoorComponentState : ComponentState
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ public abstract class SharedDoorSystem : EntitySystem
|
||||
[Dependency] protected readonly TagSystem Tags = default!;
|
||||
[Dependency] protected readonly SharedAudioSystem Audio = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
[Dependency] protected readonly SharedAppearanceSystem AppearanceSystem = default!;
|
||||
[Dependency] private readonly OccluderSystem _occluder = default!;
|
||||
|
||||
/// <summary>
|
||||
@@ -49,7 +49,7 @@ public abstract class SharedDoorSystem : EntitySystem
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<DoorComponent, ComponentInit>(OnInit);
|
||||
SubscribeLocalEvent<DoorComponent, ComponentInit>(OnComponentInit);
|
||||
SubscribeLocalEvent<DoorComponent, ComponentRemove>(OnRemove);
|
||||
|
||||
SubscribeLocalEvent<DoorComponent, ComponentGetState>(OnGetState);
|
||||
@@ -61,7 +61,7 @@ public abstract class SharedDoorSystem : EntitySystem
|
||||
SubscribeLocalEvent<DoorComponent, PreventCollideEvent>(PreventCollision);
|
||||
}
|
||||
|
||||
private void OnInit(EntityUid uid, DoorComponent door, ComponentInit args)
|
||||
protected virtual void OnComponentInit(EntityUid uid, DoorComponent door, ComponentInit args)
|
||||
{
|
||||
if (door.NextStateChange != null)
|
||||
_activeDoors.Add(door);
|
||||
@@ -88,7 +88,7 @@ public abstract class SharedDoorSystem : EntitySystem
|
||||
|| door.State == DoorState.Opening && !door.Partial;
|
||||
|
||||
SetCollidable(uid, collidable, door);
|
||||
UpdateAppearance(uid, door);
|
||||
AppearanceSystem.SetData(uid, DoorVisuals.State, door.State);
|
||||
}
|
||||
|
||||
private void OnRemove(EntityUid uid, DoorComponent door, ComponentRemove args)
|
||||
@@ -123,7 +123,7 @@ public abstract class SharedDoorSystem : EntitySystem
|
||||
_activeDoors.Add(door);
|
||||
|
||||
RaiseLocalEvent(uid, new DoorStateChangedEvent(door.State), false);
|
||||
UpdateAppearance(uid, door);
|
||||
AppearanceSystem.SetData(uid, DoorVisuals.State, door.State);
|
||||
}
|
||||
|
||||
protected void SetState(EntityUid uid, DoorState state, DoorComponent? door = null)
|
||||
@@ -167,19 +167,9 @@ public abstract class SharedDoorSystem : EntitySystem
|
||||
door.State = state;
|
||||
Dirty(door);
|
||||
RaiseLocalEvent(uid, new DoorStateChangedEvent(state), false);
|
||||
UpdateAppearance(uid, door);
|
||||
AppearanceSystem.SetData(uid, DoorVisuals.State, door.State);
|
||||
}
|
||||
|
||||
protected virtual void UpdateAppearance(EntityUid uid, DoorComponent? door = null)
|
||||
{
|
||||
if (!Resolve(uid, ref door))
|
||||
return;
|
||||
|
||||
if (!TryComp(uid, out AppearanceComponent? appearance))
|
||||
return;
|
||||
|
||||
_appearance.SetData(uid, DoorVisuals.State, door.State);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Interactions
|
||||
@@ -365,7 +355,7 @@ public abstract class SharedDoorSystem : EntitySystem
|
||||
{
|
||||
door.NextStateChange = GameTiming.CurTime + door.OpenTimeTwo;
|
||||
door.State = DoorState.Opening;
|
||||
UpdateAppearance(uid, door);
|
||||
AppearanceSystem.SetData(uid, DoorVisuals.State, DoorState.Opening);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user