Update trivial components to use auto comp states (#20539)
This commit is contained in:
@@ -1,20 +1,18 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Doors.Systems;
|
||||
using Content.Shared.Tools;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
using Robust.Shared.Timing;
|
||||
using DrawDepthTag = Robust.Shared.GameObjects.DrawDepth;
|
||||
|
||||
namespace Content.Shared.Doors.Components;
|
||||
|
||||
[NetworkedComponent]
|
||||
[RegisterComponent]
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
|
||||
public sealed partial class DoorComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
@@ -24,7 +22,7 @@ public sealed partial class DoorComponent : Component
|
||||
/// This should never be set directly, use <see cref="SharedDoorSystem.SetState(EntityUid, DoorState, DoorComponent?)"/> instead.
|
||||
/// </remarks>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("state")]
|
||||
[DataField, AutoNetworkedField]
|
||||
[Access(typeof(SharedDoorSystem))]
|
||||
public DoorState State = DoorState.Closed;
|
||||
|
||||
@@ -35,46 +33,47 @@ public sealed partial class DoorComponent : Component
|
||||
/// <summary>
|
||||
/// Closing time until impassable. Total time is this plus <see cref="CloseTimeTwo"/>.
|
||||
/// </summary>
|
||||
[DataField("closeTimeOne")]
|
||||
[DataField]
|
||||
public TimeSpan CloseTimeOne = TimeSpan.FromSeconds(0.4f);
|
||||
|
||||
/// <summary>
|
||||
/// Closing time until fully closed. Total time is this plus <see cref="CloseTimeOne"/>.
|
||||
/// </summary>
|
||||
[DataField("closeTimeTwo")]
|
||||
[DataField]
|
||||
public TimeSpan CloseTimeTwo = TimeSpan.FromSeconds(0.2f);
|
||||
|
||||
/// <summary>
|
||||
/// Opening time until passable. Total time is this plus <see cref="OpenTimeTwo"/>.
|
||||
/// </summary>
|
||||
[DataField("openTimeOne")]
|
||||
[DataField]
|
||||
public TimeSpan OpenTimeOne = TimeSpan.FromSeconds(0.4f);
|
||||
|
||||
/// <summary>
|
||||
/// Opening time until fully open. Total time is this plus <see cref="OpenTimeOne"/>.
|
||||
/// </summary>
|
||||
[DataField("openTimeTwo")]
|
||||
[DataField]
|
||||
public TimeSpan OpenTimeTwo = TimeSpan.FromSeconds(0.2f);
|
||||
|
||||
/// <summary>
|
||||
/// Interval between deny sounds & visuals;
|
||||
/// </summary>
|
||||
[DataField("denyDuration")]
|
||||
[DataField]
|
||||
public TimeSpan DenyDuration = TimeSpan.FromSeconds(0.45f);
|
||||
|
||||
[DataField("emagDuration")]
|
||||
[DataField]
|
||||
public TimeSpan EmagDuration = TimeSpan.FromSeconds(0.8f);
|
||||
|
||||
/// <summary>
|
||||
/// When the door is active, this is the time when the state will next update.
|
||||
/// </summary>
|
||||
[AutoNetworkedField]
|
||||
public TimeSpan? NextStateChange;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the door is currently partially closed or open. I.e., when the door is "closing" and is already opaque,
|
||||
/// but not yet actually closed.
|
||||
/// </summary>
|
||||
[DataField("partial")]
|
||||
[DataField, AutoNetworkedField]
|
||||
public bool Partial;
|
||||
#endregion
|
||||
|
||||
@@ -115,30 +114,30 @@ public sealed partial class DoorComponent : Component
|
||||
/// This is how long a door-crush will stun you. This also determines how long it takes the door to open up
|
||||
/// again. Total stun time is actually given by this plus <see cref="OpenTimeOne"/>.
|
||||
/// </summary>
|
||||
[DataField("doorStunTime")]
|
||||
[DataField]
|
||||
public TimeSpan DoorStunTime = TimeSpan.FromSeconds(2f);
|
||||
|
||||
[DataField("crushDamage")]
|
||||
[DataField]
|
||||
public DamageSpecifier? CrushDamage;
|
||||
|
||||
/// <summary>
|
||||
/// If false, this door is incapable of crushing entities. This just determines whether it will apply damage and
|
||||
/// stun, not whether it can close despite entities being in the way.
|
||||
/// </summary>
|
||||
[DataField("canCrush")]
|
||||
[DataField]
|
||||
public bool CanCrush = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to check for colliding entities before closing. This may be overridden by other system by subscribing to
|
||||
/// <see cref="BeforeDoorClosedEvent"/>. For example, hacked airlocks will set this to false.
|
||||
/// </summary>
|
||||
[DataField("performCollisionCheck")]
|
||||
[DataField]
|
||||
public bool PerformCollisionCheck = true;
|
||||
|
||||
/// <summary>
|
||||
/// List of EntityUids of entities we're currently crushing. Cleared in OnPartialOpen().
|
||||
/// </summary>
|
||||
[DataField("currentlyCrushing")]
|
||||
[DataField, AutoNetworkedField]
|
||||
public HashSet<EntityUid> CurrentlyCrushing = new();
|
||||
#endregion
|
||||
|
||||
@@ -152,7 +151,7 @@ public sealed partial class DoorComponent : Component
|
||||
/// <summary>
|
||||
/// The sprite state used for the door when it's open.
|
||||
/// </summary>
|
||||
[DataField("openSpriteState")]
|
||||
[DataField]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public string OpenSpriteState = "open";
|
||||
|
||||
@@ -165,7 +164,7 @@ public sealed partial class DoorComponent : Component
|
||||
/// <summary>
|
||||
/// The sprite state used for the door when it's closed.
|
||||
/// </summary>
|
||||
[DataField("closedSpriteState")]
|
||||
[DataField]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public string ClosedSpriteState = "closed";
|
||||
|
||||
@@ -178,37 +177,37 @@ public sealed partial class DoorComponent : Component
|
||||
/// <summary>
|
||||
/// The sprite state used for the door when it's opening.
|
||||
/// </summary>
|
||||
[DataField("openingSpriteState")]
|
||||
[DataField]
|
||||
public string OpeningSpriteState = "opening";
|
||||
|
||||
/// <summary>
|
||||
/// The sprite state used for the door when it's closing.
|
||||
/// </summary>
|
||||
[DataField("closingSpriteState")]
|
||||
[DataField]
|
||||
public string ClosingSpriteState = "closing";
|
||||
|
||||
/// <summary>
|
||||
/// The sprite state used for the door when it's being emagged.
|
||||
/// </summary>
|
||||
[DataField("emaggingSpriteState")]
|
||||
[DataField]
|
||||
public string EmaggingSpriteState = "emagging";
|
||||
|
||||
/// <summary>
|
||||
/// The sprite state used for the door when it's open.
|
||||
/// </summary>
|
||||
[DataField("openingAnimationTime")]
|
||||
[DataField]
|
||||
public float OpeningAnimationTime = 0.8f;
|
||||
|
||||
/// <summary>
|
||||
/// The sprite state used for the door when it's open.
|
||||
/// </summary>
|
||||
[DataField("closingAnimationTime")]
|
||||
[DataField]
|
||||
public float ClosingAnimationTime = 0.8f;
|
||||
|
||||
/// <summary>
|
||||
/// The sprite state used for the door when it's open.
|
||||
/// </summary>
|
||||
[DataField("emaggingAnimationTime")]
|
||||
[DataField]
|
||||
public float EmaggingAnimationTime = 1.5f;
|
||||
|
||||
/// <summary>
|
||||
@@ -237,7 +236,7 @@ public sealed partial class DoorComponent : Component
|
||||
/// <summary>
|
||||
/// Time until next state change. Because apparently <see cref="IGameTiming.CurTime"/> might not get saved/restored.
|
||||
/// </summary>
|
||||
[DataField("SecondsUntilStateChange")]
|
||||
[DataField]
|
||||
private float? SecondsUntilStateChange
|
||||
{
|
||||
[UsedImplicitly]
|
||||
@@ -262,47 +261,47 @@ public sealed partial class DoorComponent : Component
|
||||
}
|
||||
#endregion
|
||||
|
||||
[DataField("canPry"), ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool CanPry = true;
|
||||
|
||||
[DataField("pryingQuality", customTypeSerializer: typeof(PrototypeIdSerializer<ToolQualityPrototype>))]
|
||||
public string PryingQuality = "Prying";
|
||||
[DataField]
|
||||
public ProtoId<ToolQualityPrototype> PryingQuality = "Prying";
|
||||
|
||||
/// <summary>
|
||||
/// Default time that the door should take to pry open.
|
||||
/// </summary>
|
||||
[DataField("pryTime"), ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public float PryTime = 1.5f;
|
||||
|
||||
[DataField("changeAirtight")]
|
||||
[DataField]
|
||||
public bool ChangeAirtight = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the door blocks light.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("occludes")]
|
||||
[DataField]
|
||||
public bool Occludes = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the door will open when it is bumped into.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("bumpOpen")]
|
||||
[DataField]
|
||||
public bool BumpOpen = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the door will open when it is activated or clicked.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("clickOpen")]
|
||||
[DataField]
|
||||
public bool ClickOpen = true;
|
||||
|
||||
[DataField("openDrawDepth", customTypeSerializer: typeof(ConstantSerializer<DrawDepthTag>))]
|
||||
public int OpenDrawDepth = (int)DrawDepth.DrawDepth.Doors;
|
||||
[DataField(customTypeSerializer: typeof(ConstantSerializer<DrawDepthTag>))]
|
||||
public int OpenDrawDepth = (int) DrawDepth.DrawDepth.Doors;
|
||||
|
||||
[DataField("closedDrawDepth", customTypeSerializer: typeof(ConstantSerializer<DrawDepthTag>))]
|
||||
public int ClosedDrawDepth = (int)DrawDepth.DrawDepth.Doors;
|
||||
[DataField(customTypeSerializer: typeof(ConstantSerializer<DrawDepthTag>))]
|
||||
public int ClosedDrawDepth = (int) DrawDepth.DrawDepth.Doors;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
@@ -335,20 +334,3 @@ public enum DoorVisualLayers : byte
|
||||
BaseBolted,
|
||||
BaseEmergencyAccess,
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class DoorComponentState : ComponentState
|
||||
{
|
||||
public readonly DoorState DoorState;
|
||||
public readonly HashSet<NetEntity> CurrentlyCrushing;
|
||||
public readonly TimeSpan? NextStateChange;
|
||||
public readonly bool Partial;
|
||||
|
||||
public DoorComponentState(DoorComponent door, HashSet<NetEntity> currentlyCrushing)
|
||||
{
|
||||
DoorState = door.State;
|
||||
CurrentlyCrushing = currentlyCrushing;
|
||||
NextStateChange = door.NextStateChange;
|
||||
Partial = door.Partial;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user