Fixes Borgs and Syndicats getting hurt by glass shards and other things + honkbot slipping 2 (#31011)

* Lets do this again

* I noticed this way to late
This commit is contained in:
Verm
2024-09-10 21:12:08 -05:00
committed by GitHub
parent 4f7d3318b9
commit 14d5bbb8cb
15 changed files with 30 additions and 47 deletions

View File

@@ -4,7 +4,7 @@ using Robust.Shared.GameStates;
namespace Content.Shared.StepTrigger.Components;
/// <summary>
/// This is used for marking step trigger events that require the user to wear shoes, such as for glass shards.
/// This is used for marking step trigger events that require the user to wear shoes or have protection of some sort, such as for glass shards.
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class ClothingRequiredStepTriggerComponent : Component;
public sealed partial class PreventableStepTriggerComponent : Component;

View File

@@ -5,11 +5,11 @@ using Robust.Shared.GameStates;
namespace Content.Shared.StepTrigger.Components;
/// <summary>
/// This is used for cancelling step trigger events if the user is wearing clothing in a valid slot.
/// This is used for cancelling preventable step trigger events if the user is wearing clothing in a valid slot or if the user itself has the component.
/// </summary>
[RegisterComponent, NetworkedComponent]
[Access(typeof(StepTriggerImmuneSystem))]
public sealed partial class ClothingRequiredStepTriggerImmuneComponent : Component, IClothingSlots
public sealed partial class ProtectedFromStepTriggersComponent : Component, IClothingSlots
{
[DataField]
public SlotFlags Slots { get; set; } = SlotFlags.FEET;

View File

@@ -1,9 +0,0 @@
using Robust.Shared.GameStates;
namespace Content.Shared.StepTrigger.Components;
/// <summary>
/// Grants the attached entity to step triggers.
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class StepTriggerImmuneComponent : Component;

View File

@@ -1,7 +1,6 @@
using Content.Shared.Examine;
using Content.Shared.Inventory;
using Content.Shared.StepTrigger.Components;
using Content.Shared.Tag;
namespace Content.Shared.StepTrigger.Systems;
@@ -12,25 +11,19 @@ public sealed class StepTriggerImmuneSystem : EntitySystem
/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<StepTriggerImmuneComponent, StepTriggerAttemptEvent>(OnStepTriggerAttempt);
SubscribeLocalEvent<ClothingRequiredStepTriggerComponent, StepTriggerAttemptEvent>(OnStepTriggerClothingAttempt);
SubscribeLocalEvent<ClothingRequiredStepTriggerComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<PreventableStepTriggerComponent, StepTriggerAttemptEvent>(OnStepTriggerClothingAttempt);
SubscribeLocalEvent<PreventableStepTriggerComponent, ExaminedEvent>(OnExamined);
}
private void OnStepTriggerAttempt(Entity<StepTriggerImmuneComponent> ent, ref StepTriggerAttemptEvent args)
private void OnStepTriggerClothingAttempt(Entity<PreventableStepTriggerComponent> ent, ref StepTriggerAttemptEvent args)
{
args.Cancelled = true;
}
private void OnStepTriggerClothingAttempt(EntityUid uid, ClothingRequiredStepTriggerComponent component, ref StepTriggerAttemptEvent args)
{
if (_inventory.TryGetInventoryEntity<ClothingRequiredStepTriggerImmuneComponent>(args.Tripper, out _))
if (HasComp<ProtectedFromStepTriggersComponent>(args.Tripper) || _inventory.TryGetInventoryEntity<ProtectedFromStepTriggersComponent>(args.Tripper, out _))
{
args.Cancelled = true;
}
}
private void OnExamined(EntityUid uid, ClothingRequiredStepTriggerComponent component, ExaminedEvent args)
private void OnExamined(EntityUid uid, PreventableStepTriggerComponent component, ExaminedEvent args)
{
args.PushMarkup(Loc.GetString("clothing-required-step-trigger-examine"));
}