Add blacklist support for steptriggers (#14354)
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using Content.Shared.StepTrigger.Systems;
|
using Content.Shared.StepTrigger.Systems;
|
||||||
|
using Content.Shared.Whitelist;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
@@ -39,6 +40,12 @@ public sealed class StepTriggerComponent : Component
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("requiredTriggeredSpeed")]
|
[DataField("requiredTriggeredSpeed")]
|
||||||
public float RequiredTriggerSpeed = 3.5f;
|
public float RequiredTriggerSpeed = 3.5f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If any entities occupy the blacklist on the same tile then steptrigger won't work.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("blacklist")]
|
||||||
|
public EntityWhitelist? Blacklist;
|
||||||
}
|
}
|
||||||
|
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using Content.Shared.StepTrigger.Components;
|
using Content.Shared.StepTrigger.Components;
|
||||||
|
using Content.Shared.Tag;
|
||||||
using Robust.Shared.Collections;
|
using Robust.Shared.Collections;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
|
using Robust.Shared.Map.Components;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Physics.Components;
|
using Robust.Shared.Physics.Components;
|
||||||
using Robust.Shared.Physics.Events;
|
using Robust.Shared.Physics.Events;
|
||||||
@@ -37,20 +39,38 @@ public sealed class StepTriggerSystem : EntitySystem
|
|||||||
var query = GetEntityQuery<PhysicsComponent>();
|
var query = GetEntityQuery<PhysicsComponent>();
|
||||||
var enumerator = EntityQueryEnumerator<StepTriggerActiveComponent, StepTriggerComponent, TransformComponent>();
|
var enumerator = EntityQueryEnumerator<StepTriggerActiveComponent, StepTriggerComponent, TransformComponent>();
|
||||||
|
|
||||||
while (enumerator.MoveNext(out var active, out var trigger, out var transform))
|
while (enumerator.MoveNext(out var uid, out var active, out var trigger, out var transform))
|
||||||
{
|
{
|
||||||
if (!Update(trigger, transform, query))
|
if (!Update(uid, trigger, transform, query))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
RemCompDeferred(trigger.Owner, active);
|
RemCompDeferred(uid, active);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool Update(StepTriggerComponent component, TransformComponent transform, EntityQuery<PhysicsComponent> query)
|
private bool Update(EntityUid uid, StepTriggerComponent component, TransformComponent transform, EntityQuery<PhysicsComponent> query)
|
||||||
{
|
{
|
||||||
if (!component.Active ||
|
if (!component.Active ||
|
||||||
component.Colliding.Count == 0)
|
component.Colliding.Count == 0)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (component.Blacklist != null && TryComp<MapGridComponent>(transform.GridUid, out var grid))
|
||||||
|
{
|
||||||
|
var anch = grid.GetAnchoredEntitiesEnumerator(grid.LocalToTile(transform.Coordinates));
|
||||||
|
|
||||||
|
while (anch.MoveNext(out var ent))
|
||||||
|
{
|
||||||
|
if (ent == uid)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (component.Blacklist.IsValid(ent.Value, EntityManager) == true)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var otherUid in component.Colliding)
|
foreach (var otherUid in component.Colliding)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,6 +22,9 @@
|
|||||||
- type: FootstepModifier
|
- type: FootstepModifier
|
||||||
footstepSoundCollection:
|
footstepSoundCollection:
|
||||||
collection: FootstepCatwalk
|
collection: FootstepCatwalk
|
||||||
|
- type: Tag
|
||||||
|
tags:
|
||||||
|
- Catwalk
|
||||||
- type: Construction
|
- type: Construction
|
||||||
graph: Catwalk
|
graph: Catwalk
|
||||||
node: Catwalk
|
node: Catwalk
|
||||||
|
|||||||
@@ -9,6 +9,9 @@
|
|||||||
- type: StepTrigger
|
- type: StepTrigger
|
||||||
requiredTriggeredSpeed: 0
|
requiredTriggeredSpeed: 0
|
||||||
intersectRatio: 0.1
|
intersectRatio: 0.1
|
||||||
|
blacklist:
|
||||||
|
tags:
|
||||||
|
- Catwalk
|
||||||
- type: Lava
|
- type: Lava
|
||||||
- type: Transform
|
- type: Transform
|
||||||
anchored: true
|
anchored: true
|
||||||
|
|||||||
@@ -111,6 +111,10 @@
|
|||||||
- type: Tag
|
- type: Tag
|
||||||
id: CartridgeRocket
|
id: CartridgeRocket
|
||||||
|
|
||||||
|
# Allows you to walk over tile entities such as lava without steptrigger
|
||||||
|
- type: Tag
|
||||||
|
id: Catwalk
|
||||||
|
|
||||||
- type: Tag
|
- type: Tag
|
||||||
id: Cigarette
|
id: Cigarette
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user