step trigger fix + optimization (#8503)

This commit is contained in:
Leon Friedrich
2022-05-29 11:31:43 +12:00
committed by GitHub
parent 0d17626e22
commit 55565ea22a
2 changed files with 32 additions and 26 deletions

View File

@@ -1,4 +1,4 @@
using Robust.Shared.GameStates;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.StepTrigger;
@@ -11,12 +11,14 @@ public sealed class StepTriggerComponent : Component
/// <summary>
/// List of entities that are currently colliding with the entity.
/// </summary>
[ViewVariables]
public readonly HashSet<EntityUid> Colliding = new();
/// <summary>
/// The list of entities that are standing on this entity,
/// which shouldn't be able to trigger it again until stepping off.
/// </summary>
[ViewVariables]
public readonly HashSet<EntityUid> CurrentlySteppedOn = new();
/// <summary>
@@ -50,13 +52,17 @@ public sealed class StepTriggerComponentState : ComponentState
{
public float IntersectRatio { get; }
public float RequiredTriggerSpeed { get; }
public readonly EntityUid[] CurrentlySteppedOn;
public readonly HashSet<EntityUid> CurrentlySteppedOn;
public readonly HashSet<EntityUid> Colliding;
public readonly bool Active;
public StepTriggerComponentState(float intersectRatio, EntityUid[] currentlySteppedOn, float requiredTriggerSpeed)
public StepTriggerComponentState(float intersectRatio, HashSet<EntityUid> currentlySteppedOn, HashSet<EntityUid> colliding, float requiredTriggerSpeed, bool active)
{
IntersectRatio = intersectRatio;
CurrentlySteppedOn = currentlySteppedOn;
RequiredTriggerSpeed = requiredTriggerSpeed;
Active = active;
Colliding = colliding;
}
}