Update trivial components to use auto comp states (#20539)

This commit is contained in:
DrSmugleaf
2023-09-28 16:20:29 -07:00
committed by GitHub
parent 14cfe44ece
commit a44fa86b68
158 changed files with 806 additions and 2866 deletions

View File

@@ -8,28 +8,29 @@ using Robust.Shared.Serialization;
namespace Content.Shared.Buckle.Components;
[RegisterComponent, NetworkedComponent]
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
[Access(typeof(SharedBuckleSystem), typeof(SharedVehicleSystem))]
public sealed partial class StrapComponent : Component
{
/// <summary>
/// The entities that are currently buckled
/// </summary>
[AutoNetworkedField(true)]
[ViewVariables] // TODO serialization
public readonly HashSet<EntityUid> BuckledEntities = new();
public HashSet<EntityUid> BuckledEntities = new();
/// <summary>
/// Entities that this strap accepts and can buckle
/// If null it accepts any entity
/// </summary>
[DataField("allowedEntities")]
[DataField]
[ViewVariables]
public EntityWhitelist? AllowedEntities;
/// <summary>
/// The change in position to the strapped mob
/// </summary>
[DataField("position")]
[DataField, AutoNetworkedField]
[ViewVariables(VVAccess.ReadWrite)]
public StrapPosition Position = StrapPosition.None;
@@ -43,7 +44,7 @@ public sealed partial class StrapComponent : Component
/// whereas the server doesnt, thus the client tries to unbuckle like 15 times because it passes the strap null check
/// This is why this needs to be above 0.1 to make the InRange check fail in both client and server.
/// </remarks>
[DataField("maxBuckleDistance", required: false)]
[DataField, AutoNetworkedField]
[ViewVariables(VVAccess.ReadWrite)]
public float MaxBuckleDistance = 0.2f;
@@ -51,8 +52,8 @@ public sealed partial class StrapComponent : Component
/// Gets and clamps the buckle offset to MaxBuckleDistance
/// </summary>
[ViewVariables]
public Vector2 BuckleOffset => Vector2.Clamp(
BuckleOffsetUnclamped,
public Vector2 BuckleOffsetClamped => Vector2.Clamp(
BuckleOffset,
Vector2.One * -MaxBuckleDistance,
Vector2.One * MaxBuckleDistance);
@@ -60,21 +61,21 @@ public sealed partial class StrapComponent : Component
/// The buckled entity will be offset by this amount from the center of the strap object.
/// If this offset it too big, it will be clamped to <see cref="MaxBuckleDistance"/>
/// </summary>
[DataField("buckleOffset", required: false)]
[DataField, AutoNetworkedField]
[ViewVariables(VVAccess.ReadWrite)]
public Vector2 BuckleOffsetUnclamped = Vector2.Zero;
public Vector2 BuckleOffset = Vector2.Zero;
/// <summary>
/// The angle in degrees to rotate the player by when they get strapped
/// </summary>
[DataField("rotation")]
[DataField]
[ViewVariables(VVAccess.ReadWrite)]
public int Rotation;
/// <summary>
/// The size of the strap which is compared against when buckling entities
/// </summary>
[DataField("size")]
[DataField]
[ViewVariables(VVAccess.ReadWrite)]
public int Size = 100;
@@ -87,58 +88,39 @@ public sealed partial class StrapComponent : Component
/// <summary>
/// You can specify the offset the entity will have after unbuckling.
/// </summary>
[DataField("unbuckleOffset", required: false)]
[DataField]
[ViewVariables(VVAccess.ReadWrite)]
public Vector2 UnbuckleOffset = Vector2.Zero;
/// <summary>
/// The sound to be played when a mob is buckled
/// </summary>
[DataField("buckleSound")]
[DataField]
[ViewVariables(VVAccess.ReadWrite)]
public SoundSpecifier BuckleSound = new SoundPathSpecifier("/Audio/Effects/buckle.ogg");
/// <summary>
/// The sound to be played when a mob is unbuckled
/// </summary>
[DataField("unbuckleSound")]
[DataField]
[ViewVariables(VVAccess.ReadWrite)]
public SoundSpecifier UnbuckleSound = new SoundPathSpecifier("/Audio/Effects/unbuckle.ogg");
/// <summary>
/// ID of the alert to show when buckled
/// </summary>
[DataField("buckledAlertType")]
[DataField]
[ViewVariables(VVAccess.ReadWrite)]
public AlertType BuckledAlertType = AlertType.Buckled;
/// <summary>
/// The sum of the sizes of all the buckled entities in this strap
/// </summary>
[AutoNetworkedField]
[ViewVariables]
public int OccupiedSize;
}
[Serializable, NetSerializable]
public sealed class StrapComponentState : ComponentState
{
public readonly StrapPosition Position;
public readonly float MaxBuckleDistance;
public readonly Vector2 BuckleOffsetClamped;
public readonly HashSet<NetEntity> BuckledEntities;
public readonly int OccupiedSize;
public StrapComponentState(StrapPosition position, Vector2 offset, HashSet<NetEntity> buckled,
float maxBuckleDistance, int occupiedSize)
{
Position = position;
BuckleOffsetClamped = offset;
BuckledEntities = buckled;
MaxBuckleDistance = maxBuckleDistance;
OccupiedSize = occupiedSize;
}
}
public enum StrapPosition
{
/// <summary>