Hardsuits, EVA suits, Firesuits, and others now protect your feet from Glass Shards (#26764)

* Hardsuits and softsuits count as having shoes for step triggers

* Add softsuit tag prototype

* Change to suitEVA tag

* Get rid of softsuit tag, found suitEVA tag

* Full pass of ShoesRequiredStepTriggerImmune

* Adds check to outerClothing for ShoesRequiredStepTriggerImmune

* return

* fuck Dionas

* Convert to comp, space dragons immune as well

* Merge conflict

* Merge conflict

* fix leftover tags

* empty spaces

* turns out the dragon didn't need it

* minor optimization

* Add access for system, add comp to baseShoes, check slotflags for every slot besides pockets

* fix

* fuck it we ball

---------

Co-authored-by: Plykiya <plykiya@protonmail.com>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Plykiya
2024-04-28 00:11:46 -07:00
committed by GitHub
parent db200faf11
commit 0efcd30ac6
22 changed files with 164 additions and 86 deletions

View File

@@ -123,6 +123,11 @@ public sealed class InventoryRelayedEvent<TEvent> : EntityEventArgs
} }
} }
public interface IClothingSlots
{
SlotFlags Slots { get; }
}
/// <summary> /// <summary>
/// Events that should be relayed to inventory slots should implement this interface. /// Events that should be relayed to inventory slots should implement this interface.
/// </summary> /// </summary>

View File

@@ -27,6 +27,31 @@ public partial class InventorySystem : EntitySystem
.RemoveHandler(HandleViewVariablesSlots, ListViewVariablesSlots); .RemoveHandler(HandleViewVariablesSlots, ListViewVariablesSlots);
} }
/// <summary>
/// Tries to find an entity in the specified slot with the specified component.
/// </summary>
public bool TryGetInventoryEntity<T>(Entity<InventoryComponent?> entity, out EntityUid targetUid)
where T : IComponent, IClothingSlots
{
if (TryGetContainerSlotEnumerator(entity.Owner, out var containerSlotEnumerator))
{
while (containerSlotEnumerator.NextItem(out var item, out var slot))
{
if (!TryComp<T>(item, out var required))
continue;
if ((((IClothingSlots) required).Slots & slot.SlotFlags) == 0x0)
continue;
targetUid = item;
return true;
}
}
targetUid = EntityUid.Invalid;
return false;
}
protected virtual void OnInit(EntityUid uid, InventoryComponent component, ComponentInit args) protected virtual void OnInit(EntityUid uid, InventoryComponent component, ComponentInit args)
{ {
if (!_prototypeManager.TryIndex(component.TemplateId, out InventoryTemplatePrototype? invTemplate)) if (!_prototypeManager.TryIndex(component.TemplateId, out InventoryTemplatePrototype? invTemplate))

View File

@@ -27,4 +27,6 @@ public enum SlotFlags
FEET = 1 << 14, FEET = 1 << 14,
SUITSTORAGE = 1 << 15, SUITSTORAGE = 1 << 15,
All = ~NONE, All = ~NONE,
WITHOUT_POCKET = All & ~POCKET
} }

View File

@@ -0,0 +1,10 @@
using Content.Shared.Inventory;
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.
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class ClothingRequiredStepTriggerComponent : Component;

View File

@@ -0,0 +1,16 @@
using Content.Shared.Inventory;
using Content.Shared.StepTrigger.Systems;
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.
/// </summary>
[RegisterComponent, NetworkedComponent]
[Access(typeof(StepTriggerImmuneSystem))]
public sealed partial class ClothingRequiredStepTriggerImmuneComponent : Component, IClothingSlots
{
[DataField]
public SlotFlags Slots { get; set; } = SlotFlags.FEET;
}

View File

@@ -1,11 +0,0 @@
using Robust.Shared.GameStates;
namespace Content.Shared.StepTrigger.Components;
/// <summary>
/// This is used for cancelling step trigger events if the user is wearing shoes, such as for glass shards.
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class ShoesRequiredStepTriggerComponent : Component
{
}

View File

@@ -0,0 +1,9 @@
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,41 +0,0 @@
using Content.Shared.Examine;
using Content.Shared.Inventory;
using Content.Shared.StepTrigger.Components;
using Content.Shared.Tag;
namespace Content.Shared.StepTrigger.Systems;
public sealed class ShoesRequiredStepTriggerSystem : EntitySystem
{
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<ShoesRequiredStepTriggerComponent, StepTriggerAttemptEvent>(OnStepTriggerAttempt);
SubscribeLocalEvent<ShoesRequiredStepTriggerComponent, ExaminedEvent>(OnExamined);
}
private void OnStepTriggerAttempt(EntityUid uid, ShoesRequiredStepTriggerComponent component, ref StepTriggerAttemptEvent args)
{
if (_tagSystem.HasTag(args.Tripper, "ShoesRequiredStepTriggerImmune"))
{
args.Cancelled = true;
return;
}
if (!TryComp<InventoryComponent>(args.Tripper, out var inventory))
return;
if (_inventory.TryGetSlotEntity(args.Tripper, "shoes", out _, inventory))
{
args.Cancelled = true;
}
}
private void OnExamined(EntityUid uid, ShoesRequiredStepTriggerComponent component, ExaminedEvent args)
{
args.PushMarkup(Loc.GetString("shoes-required-step-trigger-examine"));
}
}

View File

@@ -0,0 +1,37 @@
using Content.Shared.Examine;
using Content.Shared.Inventory;
using Content.Shared.StepTrigger.Components;
using Content.Shared.Tag;
namespace Content.Shared.StepTrigger.Systems;
public sealed class StepTriggerImmuneSystem : EntitySystem
{
[Dependency] private readonly InventorySystem _inventory = default!;
/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<StepTriggerImmuneComponent, StepTriggerAttemptEvent>(OnStepTriggerAttempt);
SubscribeLocalEvent<ClothingRequiredStepTriggerComponent, StepTriggerAttemptEvent>(OnStepTriggerClothingAttempt);
SubscribeLocalEvent<ClothingRequiredStepTriggerComponent, ExaminedEvent>(OnExamined);
}
private void OnStepTriggerAttempt(Entity<StepTriggerImmuneComponent> ent, ref StepTriggerAttemptEvent args)
{
args.Cancelled = true;
}
private void OnStepTriggerClothingAttempt(EntityUid uid, ClothingRequiredStepTriggerComponent component, ref StepTriggerAttemptEvent args)
{
if (_inventory.TryGetInventoryEntity<ClothingRequiredStepTriggerImmuneComponent>(args.Tripper, out _))
{
args.Cancelled = true;
}
}
private void OnExamined(EntityUid uid, ClothingRequiredStepTriggerComponent component, ExaminedEvent args)
{
args.PushMarkup(Loc.GetString("clothing-required-step-trigger-examine"));
}
}

View File

@@ -57,7 +57,7 @@ public sealed class ReflectSystem : EntitySystem
if (args.Reflected) if (args.Reflected)
return; return;
foreach (var ent in _inventorySystem.GetHandOrInventoryEntities(uid, SlotFlags.All & ~SlotFlags.POCKET)) foreach (var ent in _inventorySystem.GetHandOrInventoryEntities(uid, SlotFlags.WITHOUT_POCKET))
{ {
if (!TryReflectHitscan(uid, ent, args.Shooter, args.SourceItem, args.Direction, out var dir)) if (!TryReflectHitscan(uid, ent, args.Shooter, args.SourceItem, args.Direction, out var dir))
continue; continue;
@@ -70,7 +70,7 @@ public sealed class ReflectSystem : EntitySystem
private void OnReflectUserCollide(EntityUid uid, ReflectUserComponent component, ref ProjectileReflectAttemptEvent args) private void OnReflectUserCollide(EntityUid uid, ReflectUserComponent component, ref ProjectileReflectAttemptEvent args)
{ {
foreach (var ent in _inventorySystem.GetHandOrInventoryEntities(uid, SlotFlags.All & ~SlotFlags.POCKET)) foreach (var ent in _inventorySystem.GetHandOrInventoryEntities(uid, SlotFlags.WITHOUT_POCKET))
{ {
if (!TryReflectProjectile(uid, ent, args.ProjUid)) if (!TryReflectProjectile(uid, ent, args.ProjUid))
continue; continue;
@@ -222,7 +222,7 @@ public sealed class ReflectSystem : EntitySystem
/// </summary> /// </summary>
private void RefreshReflectUser(EntityUid user) private void RefreshReflectUser(EntityUid user)
{ {
foreach (var ent in _inventorySystem.GetHandOrInventoryEntities(user, SlotFlags.All & ~SlotFlags.POCKET)) foreach (var ent in _inventorySystem.GetHandOrInventoryEntities(user, SlotFlags.WITHOUT_POCKET))
{ {
if (!HasComp<ReflectComponent>(ent)) if (!HasComp<ReflectComponent>(ent))
continue; continue;

View File

@@ -1 +1 @@
shoes-required-step-trigger-examine = You probably shouldn't step on this barefoot. clothing-required-step-trigger-examine = You probably shouldn't step on this barefoot.

View File

@@ -138,6 +138,8 @@
Radiation: 0 Radiation: 0
Caustic: 0.75 Caustic: 0.75
- type: GroupExamine - type: GroupExamine
- type: ClothingRequiredStepTriggerImmune
slots: WITHOUT_POCKET
- type: entity - type: entity
parent: ClothingOuterArmorHeavy parent: ClothingOuterArmorHeavy
@@ -234,6 +236,8 @@
- type: ExplosionResistance - type: ExplosionResistance
damageCoefficient: 0.5 damageCoefficient: 0.5
- type: GroupExamine - type: GroupExamine
- type: ClothingRequiredStepTriggerImmune
slots: WITHOUT_POCKET
- type: entity - type: entity
parent: ClothingOuterBaseLarge parent: ClothingOuterBaseLarge
@@ -260,6 +264,8 @@
- type: Construction - type: Construction
graph: BoneArmor graph: BoneArmor
node: armor node: armor
- type: ClothingRequiredStepTriggerImmune
slots: WITHOUT_POCKET
- type: entity - type: entity
parent: ClothingOuterBaseLarge parent: ClothingOuterBaseLarge
@@ -279,3 +285,6 @@
Piercing: 0.6 Piercing: 0.6
Heat: 0.5 Heat: 0.5
- type: GroupExamine - type: GroupExamine
- type: ClothingRequiredStepTriggerImmune
slots: WITHOUT_POCKET

View File

@@ -134,6 +134,8 @@
tags: tags:
- Hardsuit - Hardsuit
- WhitelistChameleon - WhitelistChameleon
- type: ClothingRequiredStepTriggerImmune
slots: WITHOUT_POCKET
- type: entity - type: entity
abstract: true abstract: true
@@ -152,6 +154,8 @@
- type: HeldSpeedModifier - type: HeldSpeedModifier
- type: Item - type: Item
size: Huge size: Huge
- type: ClothingRequiredStepTriggerImmune
slots: WITHOUT_POCKET
- type: entity - type: entity
parent: ClothingOuterBase parent: ClothingOuterBase

View File

@@ -25,6 +25,8 @@
tags: tags:
- Hardsuit - Hardsuit
- WhitelistChameleon - WhitelistChameleon
- type: ClothingRequiredStepTriggerImmune
slots: WITHOUT_POCKET
- type: entity - type: entity
parent: ClothingOuterSuitBomb parent: ClothingOuterSuitBomb
@@ -63,6 +65,8 @@
sprintModifier: 0.7 sprintModifier: 0.7
- type: HeldSpeedModifier - type: HeldSpeedModifier
- type: GroupExamine - type: GroupExamine
- type: ClothingRequiredStepTriggerImmune
slots: WITHOUT_POCKET
- type: entity - type: entity
parent: ClothingOuterBaseLarge parent: ClothingOuterBaseLarge
@@ -70,26 +74,28 @@
name: atmos fire suit name: atmos fire suit
description: An expensive firesuit that protects against even the most deadly of station fires. Designed to protect even if the wearer is set aflame. description: An expensive firesuit that protects against even the most deadly of station fires. Designed to protect even if the wearer is set aflame.
components: components:
- type: Sprite - type: Sprite
sprite: Clothing/OuterClothing/Suits/atmos_firesuit.rsi sprite: Clothing/OuterClothing/Suits/atmos_firesuit.rsi
- type: Clothing - type: Clothing
sprite: Clothing/OuterClothing/Suits/atmos_firesuit.rsi sprite: Clothing/OuterClothing/Suits/atmos_firesuit.rsi
- type: PressureProtection - type: PressureProtection
highPressureMultiplier: 0.02 highPressureMultiplier: 0.02
lowPressureMultiplier: 1000 lowPressureMultiplier: 1000
- type: TemperatureProtection - type: TemperatureProtection
coefficient: 0.001 coefficient: 0.001
- type: Armor - type: Armor
modifiers: modifiers:
coefficients: coefficients:
Slash: 0.9 Slash: 0.9
Heat: 0.3 Heat: 0.3
Cold: 0.2 Cold: 0.2
- type: ClothingSpeedModifier - type: ClothingSpeedModifier
walkModifier: 0.8 walkModifier: 0.8
sprintModifier: 0.8 sprintModifier: 0.8
- type: HeldSpeedModifier - type: HeldSpeedModifier
- type: GroupExamine - type: GroupExamine
- type: ClothingRequiredStepTriggerImmune
slots: WITHOUT_POCKET
- type: entity - type: entity
parent: [ClothingOuterBaseLarge, GeigerCounterClothing] parent: [ClothingOuterBaseLarge, GeigerCounterClothing]
@@ -113,7 +119,9 @@
- type: ContainerContainer - type: ContainerContainer
containers: containers:
toggleable-clothing: !type:ContainerSlot {} toggleable-clothing: !type:ContainerSlot {}
- type: ClothingRequiredStepTriggerImmune
slots: WITHOUT_POCKET
- type: entity - type: entity
parent: ClothingOuterBaseLarge parent: ClothingOuterBaseLarge
id: ClothingOuterSuitSpaceNinja id: ClothingOuterSuitSpaceNinja
@@ -164,6 +172,8 @@
sprite: Clothing/OuterClothing/Suits/chicken.rsi sprite: Clothing/OuterClothing/Suits/chicken.rsi
- type: Clothing - type: Clothing
sprite: Clothing/OuterClothing/Suits/chicken.rsi sprite: Clothing/OuterClothing/Suits/chicken.rsi
- type: ClothingRequiredStepTriggerImmune
slots: WITHOUT_POCKET
- type: entity - type: entity
parent: ClothingOuterBase parent: ClothingOuterBase
@@ -189,6 +199,8 @@
- type: ContainerContainer - type: ContainerContainer
containers: containers:
toggleable-clothing: !type:ContainerSlot {} toggleable-clothing: !type:ContainerSlot {}
- type: ClothingRequiredStepTriggerImmune
slots: WITHOUT_POCKET
- type: entity - type: entity
parent: ClothingOuterBase parent: ClothingOuterBase
@@ -210,6 +222,8 @@
- type: Construction - type: Construction
graph: ClothingOuterSuitIan graph: ClothingOuterSuitIan
node: suit node: suit
- type: ClothingRequiredStepTriggerImmune
slots: WITHOUT_POCKET
- type: entity - type: entity
parent: ClothingOuterBase parent: ClothingOuterBase

View File

@@ -23,6 +23,7 @@
tags: tags:
- ClothMade - ClothMade
- WhitelistChameleon - WhitelistChameleon
- type: ClothingRequiredStepTriggerImmune
- type: entity - type: entity
abstract: true abstract: true

View File

@@ -205,13 +205,13 @@
- type: StandingState - type: StandingState
- type: Tag - type: Tag
tags: tags:
- ShoesRequiredStepTriggerImmune
- DoorBumpOpener - DoorBumpOpener
- CanPilot - CanPilot
- type: Emoting - type: Emoting
- type: GuideHelp - type: GuideHelp
guides: guides:
- Cyborgs - Cyborgs
- type: StepTriggerImmune
- type: entity - type: entity
id: BaseBorgChassisNT id: BaseBorgChassisNT

View File

@@ -44,7 +44,6 @@
- type: Tag - type: Tag
tags: tags:
- DoorBumpOpener - DoorBumpOpener
- ShoesRequiredStepTriggerImmune
- type: MobState - type: MobState
allowedStates: allowedStates:
- Alive - Alive
@@ -73,6 +72,8 @@
- type: InputMover - type: InputMover
- type: MobMover - type: MobMover
- type: ZombieImmune - type: ZombieImmune
- type: ClothingRequiredStepTriggerImmune
slots: All
- type: entity - type: entity
abstract: true abstract: true

View File

@@ -66,7 +66,6 @@
- type: Tag - type: Tag
tags: tags:
- DoorBumpOpener - DoorBumpOpener
- ShoesRequiredStepTriggerImmune
- type: MobState - type: MobState
allowedStates: allowedStates:
- Alive - Alive
@@ -107,6 +106,7 @@
- type: TypingIndicator - type: TypingIndicator
proto: robot proto: robot
- type: ZombieImmune - type: ZombieImmune
- type: StepTriggerImmune
- type: entity - type: entity
parent: MobSiliconBase parent: MobSiliconBase

View File

@@ -15,7 +15,7 @@
requiredTriggeredSpeed: 0 requiredTriggeredSpeed: 0
- type: Mousetrap - type: Mousetrap
- type: TriggerOnStepTrigger - type: TriggerOnStepTrigger
- type: ShoesRequiredStepTrigger - type: ClothingRequiredStepTrigger
- type: DamageUserOnTrigger - type: DamageUserOnTrigger
damage: damage:
types: types:

View File

@@ -121,7 +121,7 @@
- type: StepTrigger - type: StepTrigger
intersectRatio: 0.2 intersectRatio: 0.2
- type: TriggerOnStepTrigger - type: TriggerOnStepTrigger
- type: ShoesRequiredStepTrigger - type: ClothingRequiredStepTrigger
- type: Slippery - type: Slippery
slipSound: slipSound:
path: /Audio/Effects/glass_step.ogg path: /Audio/Effects/glass_step.ogg

View File

@@ -63,7 +63,7 @@
acts: [ "Destruction" ] acts: [ "Destruction" ]
- type: StepTrigger - type: StepTrigger
intersectRatio: 0.2 intersectRatio: 0.2
- type: ShoesRequiredStepTrigger - type: ClothingRequiredStepTrigger
- type: Slippery - type: Slippery
slipSound: slipSound:
path: /Audio/Effects/glass_step.ogg path: /Audio/Effects/glass_step.ogg

View File

@@ -1104,9 +1104,6 @@
- type: Tag - type: Tag
id: Shiv id: Shiv
- type: Tag
id: ShoesRequiredStepTriggerImmune
- type: Tag - type: Tag
id: Shovel id: Shovel