}
}
+public interface IClothingSlots
+{
+ SlotFlags Slots { get; }
+}
+
/// <summary>
/// Events that should be relayed to inventory slots should implement this interface.
/// </summary>
.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)
{
if (!_prototypeManager.TryIndex(component.TemplateId, out InventoryTemplatePrototype? invTemplate))
FEET = 1 << 14,
SUITSTORAGE = 1 << 15,
All = ~NONE,
+
+ WITHOUT_POCKET = All & ~POCKET
}
--- /dev/null
+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;
--- /dev/null
+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;
+}
+++ /dev/null
-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
-{
-}
--- /dev/null
+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;
+++ /dev/null
-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"));
- }
-}
--- /dev/null
+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"));
+ }
+}
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;
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;
/// </summary>
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))
continue;
-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.
Radiation: 0
Caustic: 0.75
- type: GroupExamine
+ - type: ClothingRequiredStepTriggerImmune
+ slots: WITHOUT_POCKET
- type: entity
parent: ClothingOuterArmorHeavy
- type: ExplosionResistance
damageCoefficient: 0.5
- type: GroupExamine
+ - type: ClothingRequiredStepTriggerImmune
+ slots: WITHOUT_POCKET
- type: entity
parent: ClothingOuterBaseLarge
- type: Construction
graph: BoneArmor
node: armor
+ - type: ClothingRequiredStepTriggerImmune
+ slots: WITHOUT_POCKET
- type: entity
parent: ClothingOuterBaseLarge
Piercing: 0.6
Heat: 0.5
- type: GroupExamine
+ - type: ClothingRequiredStepTriggerImmune
+ slots: WITHOUT_POCKET
+
tags:
- Hardsuit
- WhitelistChameleon
+ - type: ClothingRequiredStepTriggerImmune
+ slots: WITHOUT_POCKET
- type: entity
abstract: true
- type: HeldSpeedModifier
- type: Item
size: Huge
+ - type: ClothingRequiredStepTriggerImmune
+ slots: WITHOUT_POCKET
- type: entity
parent: ClothingOuterBase
tags:
- Hardsuit
- WhitelistChameleon
+ - type: ClothingRequiredStepTriggerImmune
+ slots: WITHOUT_POCKET
- type: entity
parent: ClothingOuterSuitBomb
sprintModifier: 0.7
- type: HeldSpeedModifier
- type: GroupExamine
+ - type: ClothingRequiredStepTriggerImmune
+ slots: WITHOUT_POCKET
- type: entity
parent: ClothingOuterBaseLarge
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]
- type: ContainerContainer
containers:
toggleable-clothing: !type:ContainerSlot {}
-
+ - type: ClothingRequiredStepTriggerImmune
+ slots: WITHOUT_POCKET
+
- type: entity
parent: ClothingOuterBaseLarge
id: ClothingOuterSuitSpaceNinja
sprite: Clothing/OuterClothing/Suits/chicken.rsi
- type: Clothing
sprite: Clothing/OuterClothing/Suits/chicken.rsi
+ - type: ClothingRequiredStepTriggerImmune
+ slots: WITHOUT_POCKET
- type: entity
parent: ClothingOuterBase
- type: ContainerContainer
containers:
toggleable-clothing: !type:ContainerSlot {}
+ - type: ClothingRequiredStepTriggerImmune
+ slots: WITHOUT_POCKET
- type: entity
parent: ClothingOuterBase
- type: Construction
graph: ClothingOuterSuitIan
node: suit
+ - type: ClothingRequiredStepTriggerImmune
+ slots: WITHOUT_POCKET
- type: entity
parent: ClothingOuterBase
tags:
- ClothMade
- WhitelistChameleon
+ - type: ClothingRequiredStepTriggerImmune
- type: entity
abstract: true
- type: StandingState
- type: Tag
tags:
- - ShoesRequiredStepTriggerImmune
- DoorBumpOpener
- CanPilot
- type: Emoting
- type: GuideHelp
guides:
- Cyborgs
+ - type: StepTriggerImmune
- type: entity
id: BaseBorgChassisNT
- type: Tag
tags:
- DoorBumpOpener
- - ShoesRequiredStepTriggerImmune
- type: MobState
allowedStates:
- Alive
- type: InputMover
- type: MobMover
- type: ZombieImmune
+ - type: ClothingRequiredStepTriggerImmune
+ slots: All
- type: entity
abstract: true
- type: Tag
tags:
- DoorBumpOpener
- - ShoesRequiredStepTriggerImmune
- type: MobState
allowedStates:
- Alive
- type: TypingIndicator
proto: robot
- type: ZombieImmune
+ - type: StepTriggerImmune
- type: entity
parent: MobSiliconBase
requiredTriggeredSpeed: 0
- type: Mousetrap
- type: TriggerOnStepTrigger
- - type: ShoesRequiredStepTrigger
+ - type: ClothingRequiredStepTrigger
- type: DamageUserOnTrigger
damage:
types:
- type: StepTrigger
intersectRatio: 0.2
- type: TriggerOnStepTrigger
- - type: ShoesRequiredStepTrigger
+ - type: ClothingRequiredStepTrigger
- type: Slippery
slipSound:
path: /Audio/Effects/glass_step.ogg
acts: [ "Destruction" ]
- type: StepTrigger
intersectRatio: 0.2
- - type: ShoesRequiredStepTrigger
+ - type: ClothingRequiredStepTrigger
- type: Slippery
slipSound:
path: /Audio/Effects/glass_step.ogg
- type: Tag
id: Shiv
-- type: Tag
- id: ShoesRequiredStepTriggerImmune
-
- type: Tag
id: Shovel