Predict helmet toggles (#22089)

This commit is contained in:
metalgearsloth
2023-12-06 17:59:31 +11:00
committed by GitHub
parent 7cd5bf33aa
commit 8583f0d565
4 changed files with 40 additions and 64 deletions

View File

@@ -1,17 +1,17 @@
using Content.Shared.Clothing.EntitySystems;
using Content.Shared.Inventory;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Shared.Clothing.Components;
/// <summary>
/// This component gives an item an action that will equip or un-equip some clothing. Intended for use with
/// hardsuits and hardsuit helmets.
/// This component gives an item an action that will equip or un-equip some clothing e.g. hardsuits and hardsuit helmets.
/// </summary>
[Access(typeof(ToggleableClothingSystem))]
[RegisterComponent]
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class ToggleableClothingComponent : Component
{
public const string DefaultClothingContainerId = "toggleable-clothing";
@@ -19,35 +19,35 @@ public sealed partial class ToggleableClothingComponent : Component
/// <summary>
/// Action used to toggle the clothing on or off.
/// </summary>
[DataField("action", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string Action = "ActionToggleSuitPiece";
[DataField, AutoNetworkedField]
public EntProtoId Action = "ActionToggleSuitPiece";
[DataField("actionEntity")]
[DataField, AutoNetworkedField]
public EntityUid? ActionEntity;
/// <summary>
/// Default clothing entity prototype to spawn into the clothing container.
/// </summary>
[DataField("clothingPrototype", required: true, customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
public string ClothingPrototype = default!;
[DataField(required: true), AutoNetworkedField]
public EntProtoId ClothingPrototype = default!;
/// <summary>
/// The inventory slot that the clothing is equipped to.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("slot")]
[DataField, AutoNetworkedField]
public string Slot = "head";
/// <summary>
/// The inventory slot flags required for this component to function.
/// </summary>
[DataField("requiredSlot")]
[DataField("requiredSlot"), AutoNetworkedField]
public SlotFlags RequiredFlags = SlotFlags.OUTERCLOTHING;
/// <summary>
/// The container that the clothing is stored in when not equipped.
/// </summary>
[DataField("containerId")]
[DataField, AutoNetworkedField]
public string ContainerId = DefaultClothingContainerId;
[ViewVariables]
@@ -57,18 +57,18 @@ public sealed partial class ToggleableClothingComponent : Component
/// The Id of the piece of clothing that belongs to this component. Required for map-saving if the clothing is
/// currently not inside of the container.
/// </summary>
[DataField("clothingUid")]
[DataField, AutoNetworkedField]
public EntityUid? ClothingUid;
/// <summary>
/// Time it takes for this clothing to be toggled via the stripping menu verbs. Null prevents the verb from even showing up.
/// </summary>
[DataField("stripDelay")]
[DataField, AutoNetworkedField]
public TimeSpan? StripDelay = TimeSpan.FromSeconds(3);
/// <summary>
/// Text shown in the toggle-clothing verb. Defaults to using the name of the <see cref="ActionEntity"/> action.
/// </summary>
[DataField("verbText")]
[DataField, AutoNetworkedField]
public string? VerbText;
}