diff --git a/Content.Shared/Inventory/InventorySystem.Relay.cs b/Content.Shared/Inventory/InventorySystem.Relay.cs index b418a1d416..6bd65622f1 100644 --- a/Content.Shared/Inventory/InventorySystem.Relay.cs +++ b/Content.Shared/Inventory/InventorySystem.Relay.cs @@ -123,6 +123,11 @@ public sealed class InventoryRelayedEvent : EntityEventArgs } } +public interface IClothingSlots +{ + SlotFlags Slots { get; } +} + /// /// Events that should be relayed to inventory slots should implement this interface. /// diff --git a/Content.Shared/Inventory/InventorySystem.Slots.cs b/Content.Shared/Inventory/InventorySystem.Slots.cs index c634b68e04..1da44155b9 100644 --- a/Content.Shared/Inventory/InventorySystem.Slots.cs +++ b/Content.Shared/Inventory/InventorySystem.Slots.cs @@ -27,6 +27,31 @@ public partial class InventorySystem : EntitySystem .RemoveHandler(HandleViewVariablesSlots, ListViewVariablesSlots); } + /// + /// Tries to find an entity in the specified slot with the specified component. + /// + public bool TryGetInventoryEntity(Entity 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(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) { if (!_prototypeManager.TryIndex(component.TemplateId, out InventoryTemplatePrototype? invTemplate)) diff --git a/Content.Shared/Inventory/SlotFlags.cs b/Content.Shared/Inventory/SlotFlags.cs index 8d5e33e348..90971d1670 100644 --- a/Content.Shared/Inventory/SlotFlags.cs +++ b/Content.Shared/Inventory/SlotFlags.cs @@ -27,4 +27,6 @@ public enum SlotFlags FEET = 1 << 14, SUITSTORAGE = 1 << 15, All = ~NONE, + + WITHOUT_POCKET = All & ~POCKET } diff --git a/Content.Shared/StepTrigger/Components/ClothingRequiredStepTriggerComponent.cs b/Content.Shared/StepTrigger/Components/ClothingRequiredStepTriggerComponent.cs new file mode 100644 index 0000000000..9efd78d082 --- /dev/null +++ b/Content.Shared/StepTrigger/Components/ClothingRequiredStepTriggerComponent.cs @@ -0,0 +1,10 @@ +using Content.Shared.Inventory; +using Robust.Shared.GameStates; + +namespace Content.Shared.StepTrigger.Components; + +/// +/// This is used for marking step trigger events that require the user to wear shoes, such as for glass shards. +/// +[RegisterComponent, NetworkedComponent] +public sealed partial class ClothingRequiredStepTriggerComponent : Component; diff --git a/Content.Shared/StepTrigger/Components/ClothingRequiredStepTriggerImmuneComponent.cs b/Content.Shared/StepTrigger/Components/ClothingRequiredStepTriggerImmuneComponent.cs new file mode 100644 index 0000000000..dc76207828 --- /dev/null +++ b/Content.Shared/StepTrigger/Components/ClothingRequiredStepTriggerImmuneComponent.cs @@ -0,0 +1,16 @@ +using Content.Shared.Inventory; +using Content.Shared.StepTrigger.Systems; +using Robust.Shared.GameStates; + +namespace Content.Shared.StepTrigger.Components; + +/// +/// This is used for cancelling step trigger events if the user is wearing clothing in a valid slot. +/// +[RegisterComponent, NetworkedComponent] +[Access(typeof(StepTriggerImmuneSystem))] +public sealed partial class ClothingRequiredStepTriggerImmuneComponent : Component, IClothingSlots +{ + [DataField] + public SlotFlags Slots { get; set; } = SlotFlags.FEET; +} diff --git a/Content.Shared/StepTrigger/Components/ShoesRequiredStepTriggerComponent.cs b/Content.Shared/StepTrigger/Components/ShoesRequiredStepTriggerComponent.cs deleted file mode 100644 index dd95b94a7e..0000000000 --- a/Content.Shared/StepTrigger/Components/ShoesRequiredStepTriggerComponent.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Robust.Shared.GameStates; - -namespace Content.Shared.StepTrigger.Components; - -/// -/// This is used for cancelling step trigger events if the user is wearing shoes, such as for glass shards. -/// -[RegisterComponent, NetworkedComponent] -public sealed partial class ShoesRequiredStepTriggerComponent : Component -{ -} diff --git a/Content.Shared/StepTrigger/Components/StepTriggerImmuneComponent.cs b/Content.Shared/StepTrigger/Components/StepTriggerImmuneComponent.cs new file mode 100644 index 0000000000..74e10bafce --- /dev/null +++ b/Content.Shared/StepTrigger/Components/StepTriggerImmuneComponent.cs @@ -0,0 +1,9 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared.StepTrigger.Components; + +/// +/// Grants the attached entity to step triggers. +/// +[RegisterComponent, NetworkedComponent] +public sealed partial class StepTriggerImmuneComponent : Component; diff --git a/Content.Shared/StepTrigger/Systems/ShoesRequiredStepTriggerSystem.cs b/Content.Shared/StepTrigger/Systems/ShoesRequiredStepTriggerSystem.cs deleted file mode 100644 index 5fc9140dfd..0000000000 --- a/Content.Shared/StepTrigger/Systems/ShoesRequiredStepTriggerSystem.cs +++ /dev/null @@ -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!; - - /// - public override void Initialize() - { - SubscribeLocalEvent(OnStepTriggerAttempt); - SubscribeLocalEvent(OnExamined); - } - - private void OnStepTriggerAttempt(EntityUid uid, ShoesRequiredStepTriggerComponent component, ref StepTriggerAttemptEvent args) - { - if (_tagSystem.HasTag(args.Tripper, "ShoesRequiredStepTriggerImmune")) - { - args.Cancelled = true; - return; - } - - if (!TryComp(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")); - } -} diff --git a/Content.Shared/StepTrigger/Systems/StepTriggerImmuneSystem.cs b/Content.Shared/StepTrigger/Systems/StepTriggerImmuneSystem.cs new file mode 100644 index 0000000000..ca72a20ae9 --- /dev/null +++ b/Content.Shared/StepTrigger/Systems/StepTriggerImmuneSystem.cs @@ -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!; + + /// + public override void Initialize() + { + SubscribeLocalEvent(OnStepTriggerAttempt); + SubscribeLocalEvent(OnStepTriggerClothingAttempt); + SubscribeLocalEvent(OnExamined); + } + + private void OnStepTriggerAttempt(Entity ent, ref StepTriggerAttemptEvent args) + { + args.Cancelled = true; + } + + private void OnStepTriggerClothingAttempt(EntityUid uid, ClothingRequiredStepTriggerComponent component, ref StepTriggerAttemptEvent args) + { + if (_inventory.TryGetInventoryEntity(args.Tripper, out _)) + { + args.Cancelled = true; + } + } + + private void OnExamined(EntityUid uid, ClothingRequiredStepTriggerComponent component, ExaminedEvent args) + { + args.PushMarkup(Loc.GetString("clothing-required-step-trigger-examine")); + } +} diff --git a/Content.Shared/Weapons/Reflect/ReflectSystem.cs b/Content.Shared/Weapons/Reflect/ReflectSystem.cs index 4a7c2f6b6a..014b3cfe1f 100644 --- a/Content.Shared/Weapons/Reflect/ReflectSystem.cs +++ b/Content.Shared/Weapons/Reflect/ReflectSystem.cs @@ -57,7 +57,7 @@ public sealed class ReflectSystem : EntitySystem if (args.Reflected) 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)) continue; @@ -70,7 +70,7 @@ public sealed class ReflectSystem : EntitySystem 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)) continue; @@ -222,7 +222,7 @@ public sealed class ReflectSystem : EntitySystem /// 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(ent)) continue; diff --git a/Resources/Locale/en-US/step-trigger/shoes-required.ftl b/Resources/Locale/en-US/step-trigger/shoes-required.ftl index 8c1369a49f..07a4b8a84f 100644 --- a/Resources/Locale/en-US/step-trigger/shoes-required.ftl +++ b/Resources/Locale/en-US/step-trigger/shoes-required.ftl @@ -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. diff --git a/Resources/Prototypes/Entities/Clothing/OuterClothing/armor.yml b/Resources/Prototypes/Entities/Clothing/OuterClothing/armor.yml index 9a1f142740..ecc4156aff 100644 --- a/Resources/Prototypes/Entities/Clothing/OuterClothing/armor.yml +++ b/Resources/Prototypes/Entities/Clothing/OuterClothing/armor.yml @@ -138,6 +138,8 @@ Radiation: 0 Caustic: 0.75 - type: GroupExamine + - type: ClothingRequiredStepTriggerImmune + slots: WITHOUT_POCKET - type: entity parent: ClothingOuterArmorHeavy @@ -234,6 +236,8 @@ - type: ExplosionResistance damageCoefficient: 0.5 - type: GroupExamine + - type: ClothingRequiredStepTriggerImmune + slots: WITHOUT_POCKET - type: entity parent: ClothingOuterBaseLarge @@ -260,6 +264,8 @@ - type: Construction graph: BoneArmor node: armor + - type: ClothingRequiredStepTriggerImmune + slots: WITHOUT_POCKET - type: entity parent: ClothingOuterBaseLarge @@ -279,3 +285,6 @@ Piercing: 0.6 Heat: 0.5 - type: GroupExamine + - type: ClothingRequiredStepTriggerImmune + slots: WITHOUT_POCKET + diff --git a/Resources/Prototypes/Entities/Clothing/OuterClothing/base_clothingouter.yml b/Resources/Prototypes/Entities/Clothing/OuterClothing/base_clothingouter.yml index e5067e84c5..16b287917b 100644 --- a/Resources/Prototypes/Entities/Clothing/OuterClothing/base_clothingouter.yml +++ b/Resources/Prototypes/Entities/Clothing/OuterClothing/base_clothingouter.yml @@ -134,6 +134,8 @@ tags: - Hardsuit - WhitelistChameleon + - type: ClothingRequiredStepTriggerImmune + slots: WITHOUT_POCKET - type: entity abstract: true @@ -152,6 +154,8 @@ - type: HeldSpeedModifier - type: Item size: Huge + - type: ClothingRequiredStepTriggerImmune + slots: WITHOUT_POCKET - type: entity parent: ClothingOuterBase diff --git a/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml b/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml index 5e82959c4e..cc6f0131ad 100644 --- a/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml +++ b/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml @@ -25,6 +25,8 @@ tags: - Hardsuit - WhitelistChameleon + - type: ClothingRequiredStepTriggerImmune + slots: WITHOUT_POCKET - type: entity parent: ClothingOuterSuitBomb @@ -63,6 +65,8 @@ sprintModifier: 0.7 - type: HeldSpeedModifier - type: GroupExamine + - type: ClothingRequiredStepTriggerImmune + slots: WITHOUT_POCKET - type: entity parent: ClothingOuterBaseLarge @@ -70,26 +74,28 @@ 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. components: - - type: Sprite - sprite: Clothing/OuterClothing/Suits/atmos_firesuit.rsi - - type: Clothing - sprite: Clothing/OuterClothing/Suits/atmos_firesuit.rsi - - type: PressureProtection - highPressureMultiplier: 0.02 - lowPressureMultiplier: 1000 - - type: TemperatureProtection - coefficient: 0.001 - - type: Armor - modifiers: - coefficients: - Slash: 0.9 - Heat: 0.3 - Cold: 0.2 - - type: ClothingSpeedModifier - walkModifier: 0.8 - sprintModifier: 0.8 - - type: HeldSpeedModifier - - type: GroupExamine + - type: Sprite + sprite: Clothing/OuterClothing/Suits/atmos_firesuit.rsi + - type: Clothing + sprite: Clothing/OuterClothing/Suits/atmos_firesuit.rsi + - type: PressureProtection + highPressureMultiplier: 0.02 + lowPressureMultiplier: 1000 + - type: TemperatureProtection + coefficient: 0.001 + - type: Armor + modifiers: + coefficients: + Slash: 0.9 + Heat: 0.3 + Cold: 0.2 + - type: ClothingSpeedModifier + walkModifier: 0.8 + sprintModifier: 0.8 + - type: HeldSpeedModifier + - type: GroupExamine + - type: ClothingRequiredStepTriggerImmune + slots: WITHOUT_POCKET - type: entity parent: [ClothingOuterBaseLarge, GeigerCounterClothing] @@ -113,7 +119,9 @@ - type: ContainerContainer containers: toggleable-clothing: !type:ContainerSlot {} - + - type: ClothingRequiredStepTriggerImmune + slots: WITHOUT_POCKET + - type: entity parent: ClothingOuterBaseLarge id: ClothingOuterSuitSpaceNinja @@ -164,6 +172,8 @@ sprite: Clothing/OuterClothing/Suits/chicken.rsi - type: Clothing sprite: Clothing/OuterClothing/Suits/chicken.rsi + - type: ClothingRequiredStepTriggerImmune + slots: WITHOUT_POCKET - type: entity parent: ClothingOuterBase @@ -189,6 +199,8 @@ - type: ContainerContainer containers: toggleable-clothing: !type:ContainerSlot {} + - type: ClothingRequiredStepTriggerImmune + slots: WITHOUT_POCKET - type: entity parent: ClothingOuterBase @@ -210,6 +222,8 @@ - type: Construction graph: ClothingOuterSuitIan node: suit + - type: ClothingRequiredStepTriggerImmune + slots: WITHOUT_POCKET - type: entity parent: ClothingOuterBase diff --git a/Resources/Prototypes/Entities/Clothing/Shoes/base_clothingshoes.yml b/Resources/Prototypes/Entities/Clothing/Shoes/base_clothingshoes.yml index 1119d5cda7..a0f56966bb 100644 --- a/Resources/Prototypes/Entities/Clothing/Shoes/base_clothingshoes.yml +++ b/Resources/Prototypes/Entities/Clothing/Shoes/base_clothingshoes.yml @@ -23,6 +23,7 @@ tags: - ClothMade - WhitelistChameleon + - type: ClothingRequiredStepTriggerImmune - type: entity abstract: true diff --git a/Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml b/Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml index 27a19ab899..cb846c7dde 100644 --- a/Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml +++ b/Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml @@ -205,13 +205,13 @@ - type: StandingState - type: Tag tags: - - ShoesRequiredStepTriggerImmune - DoorBumpOpener - CanPilot - type: Emoting - type: GuideHelp guides: - Cyborgs + - type: StepTriggerImmune - type: entity id: BaseBorgChassisNT diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/elemental.yml b/Resources/Prototypes/Entities/Mobs/NPCs/elemental.yml index c2380c4027..58d30ccfc0 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/elemental.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/elemental.yml @@ -44,7 +44,6 @@ - type: Tag tags: - DoorBumpOpener - - ShoesRequiredStepTriggerImmune - type: MobState allowedStates: - Alive @@ -73,6 +72,8 @@ - type: InputMover - type: MobMover - type: ZombieImmune + - type: ClothingRequiredStepTriggerImmune + slots: All - type: entity abstract: true diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml b/Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml index c808ed2d21..7a36046a0f 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml @@ -66,7 +66,6 @@ - type: Tag tags: - DoorBumpOpener - - ShoesRequiredStepTriggerImmune - type: MobState allowedStates: - Alive @@ -107,6 +106,7 @@ - type: TypingIndicator proto: robot - type: ZombieImmune + - type: StepTriggerImmune - type: entity parent: MobSiliconBase diff --git a/Resources/Prototypes/Entities/Objects/Devices/mousetrap.yml b/Resources/Prototypes/Entities/Objects/Devices/mousetrap.yml index c3bd74dd75..d97cae2e6d 100644 --- a/Resources/Prototypes/Entities/Objects/Devices/mousetrap.yml +++ b/Resources/Prototypes/Entities/Objects/Devices/mousetrap.yml @@ -15,7 +15,7 @@ requiredTriggeredSpeed: 0 - type: Mousetrap - type: TriggerOnStepTrigger - - type: ShoesRequiredStepTrigger + - type: ClothingRequiredStepTrigger - type: DamageUserOnTrigger damage: types: diff --git a/Resources/Prototypes/Entities/Objects/Fun/dice.yml b/Resources/Prototypes/Entities/Objects/Fun/dice.yml index 852a1c2699..0b534f0879 100644 --- a/Resources/Prototypes/Entities/Objects/Fun/dice.yml +++ b/Resources/Prototypes/Entities/Objects/Fun/dice.yml @@ -121,7 +121,7 @@ - type: StepTrigger intersectRatio: 0.2 - type: TriggerOnStepTrigger - - type: ShoesRequiredStepTrigger + - type: ClothingRequiredStepTrigger - type: Slippery slipSound: path: /Audio/Effects/glass_step.ogg diff --git a/Resources/Prototypes/Entities/Objects/Materials/shards.yml b/Resources/Prototypes/Entities/Objects/Materials/shards.yml index 834a2e7ff0..dfd02b6fcc 100644 --- a/Resources/Prototypes/Entities/Objects/Materials/shards.yml +++ b/Resources/Prototypes/Entities/Objects/Materials/shards.yml @@ -63,7 +63,7 @@ acts: [ "Destruction" ] - type: StepTrigger intersectRatio: 0.2 - - type: ShoesRequiredStepTrigger + - type: ClothingRequiredStepTrigger - type: Slippery slipSound: path: /Audio/Effects/glass_step.ogg diff --git a/Resources/Prototypes/tags.yml b/Resources/Prototypes/tags.yml index 8238bc2d53..f4477a8c85 100644 --- a/Resources/Prototypes/tags.yml +++ b/Resources/Prototypes/tags.yml @@ -1104,9 +1104,6 @@ - type: Tag id: Shiv -- type: Tag - id: ShoesRequiredStepTriggerImmune - - type: Tag id: Shovel