Skip to content

Commit

Permalink
throw what you see and see what sticks
Browse files Browse the repository at this point in the history
  • Loading branch information
Acensti committed Jul 7, 2024
1 parent 597ac32 commit 847461e
Show file tree
Hide file tree
Showing 3 changed files with 248 additions and 96 deletions.
78 changes: 36 additions & 42 deletions Content.Shared/Buckle/Components/BuckleComponent.cs
Original file line number Diff line number Diff line change
@@ -1,87 +1,81 @@
using Content.Shared.Interaction;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;

using Content.Shared.Whitelist;
namespace Content.Shared.Buckle.Components;

[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]

[Access(typeof(SharedBuckleSystem))]

public sealed partial class BuckleComponent : Component

{
/// <summary>
/// The range from which this entity can buckle to a <see cref="StrapComponent"/>.
/// Separated from normal interaction range to fix the "someone buckled to a strap
/// across a table two tiles away" problem.
/// </summary>
[DataField]
[ViewVariables(VVAccess.ReadWrite)]

[DataField, ViewVariables(VVAccess.ReadWrite)]

public float Range = SharedInteractionSystem.InteractionRange / 1.4f;

/// <summary>
/// True if the entity is buckled, false otherwise.
/// </summary>

[ViewVariables(VVAccess.ReadWrite)]

[AutoNetworkedField]

public bool Buckled;

/// <summary>
/// The last entity this component was buckled to.
/// </summary>

[ViewVariables]

[AutoNetworkedField]

public EntityUid? LastEntityBuckledTo;

/// <summary>
/// Whether or not collisions should be possible with the entity we are strapped to.
/// </summary>

[ViewVariables(VVAccess.ReadWrite)]

[DataField, AutoNetworkedField]

public bool DontCollide;

/// <summary>
/// Whether or not we should be allowed to pull the entity we are strapped to.
/// </summary>

[ViewVariables(VVAccess.ReadWrite)]

[DataField]

public bool PullStrap;

/// <summary>
/// The delay before the buckle/unbuckle action is completed.
/// </summary>
[DataField]
[ViewVariables(VVAccess.ReadWrite)]

[DataField, ViewVariables(VVAccess.ReadWrite)]

public TimeSpan Delay = TimeSpan.FromSeconds(0.25f);

/// <summary>
/// The time when the buckle/unbuckle action was initiated.
/// </summary>

[ViewVariables]

public TimeSpan BuckleTime;

/// <summary>
/// The entity this component is currently buckled to.
/// </summary>

[ViewVariables]

[AutoNetworkedField]

public EntityUid? BuckledTo;

/// <summary>
/// The maximum size of entities that can be buckled to this component.
/// </summary>
[DataField]
[ViewVariables(VVAccess.ReadWrite)]

[DataField, ViewVariables(VVAccess.ReadWrite)]

public int Size = 100;

/// <summary>
/// The original draw depth of the entity before it was buckled.
/// </summary>
[ViewVariables] public int? OriginalDrawDepth;

[DataField]
[ViewVariables]

public int? OriginalDrawDepth;

[ViewVariables(VVAccess.ReadWrite)]

[DataField, ViewVariables(VVAccess.ReadWrite)]

public EntityWhitelist? AllowedBuckleTypes;

}

[ByRefEvent]
Expand Down
18 changes: 18 additions & 0 deletions Content.Shared/Buckle/Components/StrapComponent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
using Content.Shared.AlertLevel;
using Robust.Shared.Audio;
using System.Numerics;
using Content.Shared.Alert;
using Content.Shared.Whitelist;

namespace Content.Shared.Buckle.Components;

Expand Down Expand Up @@ -83,6 +88,19 @@ public sealed partial class StrapComponent : Component
[ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public SoundSpecifier UnbuckleSound = new SoundPathSpecifier("/Audio/Effects/unbuckle.ogg");

/// <summary>
/// The allowed entities that can be buckled to this strap.
/// </summary>
[DataField]
[ViewVariables(VVAccess.ReadWrite)]
public EntityWhitelist? AllowedEntities;

/// <summary>
/// The clamped buckle offset for this strap.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public Vector2 BuckleOffsetClamped => Vector2.Clamp(BuckleOffset, Vector2.One * -0.5f, Vector2.One * 0.5f);
}

public enum StrapPosition
Expand Down
Loading

0 comments on commit 847461e

Please sign in to comment.