diff --git a/Content.Shared/StepTrigger/Components/StepTriggerComponent.cs b/Content.Shared/StepTrigger/Components/StepTriggerComponent.cs index b8483d021a4..d12c2c983ee 100644 --- a/Content.Shared/StepTrigger/Components/StepTriggerComponent.cs +++ b/Content.Shared/StepTrigger/Components/StepTriggerComponent.cs @@ -1,3 +1,4 @@ +using Content.Shared.StepTrigger.Prototypes; using Content.Shared.StepTrigger.Systems; using Content.Shared.Whitelist; using Robust.Shared.GameStates; @@ -53,15 +54,18 @@ public sealed partial class StepTriggerComponent : Component public bool IgnoreWeightless; /// - /// Does this have separate "StepOn" and "StepOff" triggers. + /// Does this have separate "StepOn" and "StepOff" triggers. /// [DataField, AutoNetworkedField] public bool StepOn = false; + + /// + /// If TriggerGroups is specified, it will check StepTriggerImmunityComponent to have the same TriggerType to activate immunity + /// + [DataField] + public StepTriggerGroup? TriggerGroups; } [RegisterComponent] [Access(typeof(StepTriggerSystem))] -public sealed partial class StepTriggerActiveComponent : Component -{ - -} +public sealed partial class StepTriggerActiveComponent : Component { } diff --git a/Content.Shared/StepTrigger/Components/StepTriggerImmuneComponent.cs b/Content.Shared/StepTrigger/Components/StepTriggerImmuneComponent.cs index 4321334a3ae..1b92905fa61 100644 --- a/Content.Shared/StepTrigger/Components/StepTriggerImmuneComponent.cs +++ b/Content.Shared/StepTrigger/Components/StepTriggerImmuneComponent.cs @@ -1,3 +1,5 @@ +using Content.Shared.StepTrigger.Prototypes; +using Content.Shared.StepTrigger.Systems; using Robust.Shared.GameStates; namespace Content.Shared.StepTrigger.Components; @@ -12,4 +14,12 @@ namespace Content.Shared.StepTrigger.Components; /// Consider using a subscription to StepTriggerAttemptEvent if you wish to be more selective. /// [RegisterComponent, NetworkedComponent] -public sealed partial class StepTriggerImmuneComponent : Component { } +[Access(typeof(StepTriggerSystem))] +public sealed partial class StepTriggerImmuneComponent : Component +{ + /// + /// WhiteList of immunity step triggers. + /// + [DataField] + public StepTriggerGroup? Whitelist; +} diff --git a/Content.Shared/StepTrigger/Prototypes/StepTriggerGroup.cs b/Content.Shared/StepTrigger/Prototypes/StepTriggerGroup.cs new file mode 100644 index 00000000000..5b64085e9a9 --- /dev/null +++ b/Content.Shared/StepTrigger/Prototypes/StepTriggerGroup.cs @@ -0,0 +1,72 @@ +using Content.Shared.StepTrigger.Components; +using Robust.Shared.Prototypes; +using Robust.Shared.Serialization; + +namespace Content.Shared.StepTrigger.Prototypes; + +/// +/// A group of +/// Used to determine StepTriggerTypes like Tags. +/// Used for better work with Immunity. +/// StepTriggerTypes in StepTriggerTypes.yml +/// +/// +/// stepTriggerGroups: +/// types: +/// - Lava +/// - Landmine +/// - Shard +/// - Chasm +/// - Mousetrap +/// - SlipTile +/// - SlipEntity +/// +[DataDefinition] +[Serializable, NetSerializable] +public sealed partial class StepTriggerGroup +{ + [DataField] + public List>? Types = null; + + /// + /// Checks if types of this StepTriggerGroup is similar to types of AnotherGroup + /// + public bool IsValid(StepTriggerGroup? anotherGroup) + { + if (Types is null) + return false; + + foreach (var type in Types) + { + if (anotherGroup != null + && anotherGroup.Types != null + && anotherGroup.Types.Contains(type)) + return true; + } + return false; + } + + /// + /// Checks validation (if types of this StepTriggerGroup are similar to types of + /// another StepTriggerComponent. + /// + public bool IsValid(StepTriggerComponent component) + { + if (component.TriggerGroups is null) + return false; + + return IsValid(component.TriggerGroups); + } + + /// + /// Checks validation (if types of this StepTriggerGroup are similar to types of + /// another StepTriggerImmuneComponent. + /// + public bool IsValid(StepTriggerImmuneComponent component) + { + if (component.Whitelist is null) + return false; + + return IsValid(component.Whitelist); + } +} diff --git a/Content.Shared/StepTrigger/Prototypes/StepTriggerTypePrototype.cs b/Content.Shared/StepTrigger/Prototypes/StepTriggerTypePrototype.cs new file mode 100644 index 00000000000..732eb4b732e --- /dev/null +++ b/Content.Shared/StepTrigger/Prototypes/StepTriggerTypePrototype.cs @@ -0,0 +1,15 @@ +using Robust.Shared.Prototypes; + +namespace Content.Shared.StepTrigger.Prototypes; + +/// +/// Prototype representing a StepTriggerType in YAML. +/// Meant to only have an ID property, as that is the only thing that +/// gets saved in StepTriggerGroup. +/// +[Prototype] +public sealed partial class StepTriggerTypePrototype : IPrototype +{ + [ViewVariables, IdDataField] + public string ID { get; private set; } = default!; +} diff --git a/Content.Shared/StepTrigger/Systems/StepTriggerSystem.cs b/Content.Shared/StepTrigger/Systems/StepTriggerSystem.cs index 89655afac23..d0cd5c4b4e2 100644 --- a/Content.Shared/StepTrigger/Systems/StepTriggerSystem.cs +++ b/Content.Shared/StepTrigger/Systems/StepTriggerSystem.cs @@ -118,11 +118,16 @@ private void UpdateColliding(EntityUid uid, StepTriggerComponent component, Tran private bool CanTrigger(EntityUid uid, EntityUid otherUid, StepTriggerComponent component) { - if (HasComp(otherUid) - || !component.Active + if (!component.Active || component.CurrentlySteppedOn.Contains(otherUid)) return false; + // Immunity checks + if (TryComp(otherUid, out var stepTriggerImmuneComponent) + && component.TriggerGroups != null + && component.TriggerGroups.IsValid(stepTriggerImmuneComponent)) + return false; + // Can't trigger if we don't ignore weightless entities // and the entity is flying or currently weightless // Makes sense simulation wise to have this be part of steptrigger directly IMO diff --git a/Resources/Prototypes/Entities/Effects/chemistry_effects.yml b/Resources/Prototypes/Entities/Effects/chemistry_effects.yml index 096e88bcb6f..469bab32782 100644 --- a/Resources/Prototypes/Entities/Effects/chemistry_effects.yml +++ b/Resources/Prototypes/Entities/Effects/chemistry_effects.yml @@ -77,6 +77,9 @@ animationState: foam-dissolve - type: Slippery - type: StepTrigger + triggerGroups: + types: + - SlipTile # disabled until foam reagent duplication is fixed #- type: ScoopableSolution # solution: solutionArea @@ -135,7 +138,7 @@ - type: RCDDeconstructable cost: 2 delay: 2 - fx: EffectRCDDeconstruct2 + fx: EffectRCDDeconstruct2 - type: Clickable - type: InteractionOutline - type: Sprite diff --git a/Resources/Prototypes/Entities/Effects/puddle.yml b/Resources/Prototypes/Entities/Effects/puddle.yml index 2c845e1d0f0..d3156c50a3f 100644 --- a/Resources/Prototypes/Entities/Effects/puddle.yml +++ b/Resources/Prototypes/Entities/Effects/puddle.yml @@ -149,6 +149,9 @@ - type: EdgeSpreader id: Puddle - type: StepTrigger + triggerGroups: + types: + - SlipTile - type: Drink delay: 3 transferAmount: 1 diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml b/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml index 29234ea34cf..01eed043139 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml @@ -1689,6 +1689,10 @@ - type: FireVisuals sprite: Mobs/Effects/onfire.rsi normalState: Mouse_burning + - type: StepTriggerImmune + whitelist: + types: + - Landmine - type: entity parent: MobMouse diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml b/Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml index d01fc8b8de2..90d9a5e5c97 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml @@ -137,6 +137,9 @@ - type: Speech speechVerb: Cluwne - type: StepTrigger + triggerGroups: + types: + - SlipEntity intersectRatio: 0.2 - type: Fixtures fixtures: diff --git a/Resources/Prototypes/Entities/Mobs/Player/ipc.yml b/Resources/Prototypes/Entities/Mobs/Player/ipc.yml index 1bed477b7d1..247226dc7d5 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/ipc.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/ipc.yml @@ -111,6 +111,10 @@ - type: OfferItem - type: LayingDown - type: Carriable + - type: StepTriggerImmune + whitelist: + types: + - Shard - type: entity save: false diff --git a/Resources/Prototypes/Entities/Mobs/Species/diona.yml b/Resources/Prototypes/Entities/Mobs/Species/diona.yml index 42383d9a426..81c9e596163 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/diona.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/diona.yml @@ -114,6 +114,10 @@ walkModifier: 0.75 - type: SpeedModifierImmunity - type: NoSlip + - type: StepTriggerImmune + whitelist: + types: + - Shard - type: entity parent: BaseSpeciesDummy diff --git a/Resources/Prototypes/Entities/Mobs/Species/harpy.yml b/Resources/Prototypes/Entities/Mobs/Species/harpy.yml index 05ac3de8bb3..8882da868b1 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/harpy.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/harpy.yml @@ -123,6 +123,11 @@ - GalacticCommon - SolCommon - type: StepTriggerImmune + whitelist: + types: + - Shard + - Landmine + - Mousetrap - type: entity save: false diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Food/produce.yml b/Resources/Prototypes/Entities/Objects/Consumable/Food/produce.yml index 3f0277e1bc3..930d7fa64dc 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Food/produce.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Food/produce.yml @@ -314,6 +314,9 @@ launchForwardsMultiplier: 1.5 - type: StepTrigger intersectRatio: 0.2 + triggerGroups: + types: + - SlipEntity - type: CollisionWake enabled: false - type: Physics diff --git a/Resources/Prototypes/Entities/Objects/Devices/mousetrap.yml b/Resources/Prototypes/Entities/Objects/Devices/mousetrap.yml index c3bd74dd751..a93cd545bfc 100644 --- a/Resources/Prototypes/Entities/Objects/Devices/mousetrap.yml +++ b/Resources/Prototypes/Entities/Objects/Devices/mousetrap.yml @@ -13,6 +13,9 @@ - type: StepTrigger intersectRatio: 0.2 requiredTriggeredSpeed: 0 + triggerGroups: + types: + - Mousetrap - type: Mousetrap - type: TriggerOnStepTrigger - type: ShoesRequiredStepTrigger diff --git a/Resources/Prototypes/Entities/Objects/Devices/pda.yml b/Resources/Prototypes/Entities/Objects/Devices/pda.yml index f0d07f9434a..1a388997835 100644 --- a/Resources/Prototypes/Entities/Objects/Devices/pda.yml +++ b/Resources/Prototypes/Entities/Objects/Devices/pda.yml @@ -272,6 +272,9 @@ paralyzeTime: 4 launchForwardsMultiplier: 1.5 - type: StepTrigger + triggerGroups: + types: + - SlipEntity - type: CollisionWake enabled: false - type: Physics diff --git a/Resources/Prototypes/Entities/Objects/Fun/dice.yml b/Resources/Prototypes/Entities/Objects/Fun/dice.yml index 852a1c2699c..f7395ef9ca6 100644 --- a/Resources/Prototypes/Entities/Objects/Fun/dice.yml +++ b/Resources/Prototypes/Entities/Objects/Fun/dice.yml @@ -119,6 +119,9 @@ mask: - ItemMask - type: StepTrigger + triggerGroups: + types: + - Shard intersectRatio: 0.2 - type: TriggerOnStepTrigger - type: ShoesRequiredStepTrigger diff --git a/Resources/Prototypes/Entities/Objects/Materials/shards.yml b/Resources/Prototypes/Entities/Objects/Materials/shards.yml index 6cdc066cf10..34685343145 100644 --- a/Resources/Prototypes/Entities/Objects/Materials/shards.yml +++ b/Resources/Prototypes/Entities/Objects/Materials/shards.yml @@ -64,6 +64,9 @@ - !type:DoActsBehavior acts: [ "Destruction" ] - type: StepTrigger + triggerGroups: + types: + - Shard intersectRatio: 0.2 - type: ShoesRequiredStepTrigger - type: Slippery diff --git a/Resources/Prototypes/Entities/Objects/Misc/land_mine.yml b/Resources/Prototypes/Entities/Objects/Misc/land_mine.yml index a3e3485bc65..97053660a19 100644 --- a/Resources/Prototypes/Entities/Objects/Misc/land_mine.yml +++ b/Resources/Prototypes/Entities/Objects/Misc/land_mine.yml @@ -40,6 +40,9 @@ params: maxDistance: 10 - type: StepTrigger + triggerGroups: + types: + - Landmine requiredTriggeredSpeed: 0 stepOn: true diff --git a/Resources/Prototypes/Entities/Objects/Misc/spider_web.yml b/Resources/Prototypes/Entities/Objects/Misc/spider_web.yml index 9561fa3538f..bb284000a76 100644 --- a/Resources/Prototypes/Entities/Objects/Misc/spider_web.yml +++ b/Resources/Prototypes/Entities/Objects/Misc/spider_web.yml @@ -111,6 +111,9 @@ paralyzeTime: 2 launchForwardsMultiplier: 1.5 - type: StepTrigger + triggerGroups: + types: + - SlipTile intersectRatio: 0.2 - type: Physics - type: Fixtures diff --git a/Resources/Prototypes/Entities/Objects/Specific/Janitorial/soap.yml b/Resources/Prototypes/Entities/Objects/Specific/Janitorial/soap.yml index 5678de6bafc..5fe88f8d0cf 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Janitorial/soap.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Janitorial/soap.yml @@ -24,6 +24,9 @@ paralyzeTime: 2 launchForwardsMultiplier: 1.5 - type: StepTrigger + triggerGroups: + types: + - SlipEntity intersectRatio: 0.2 - type: CollisionWake enabled: false @@ -157,6 +160,9 @@ paralyzeTime: 5 launchForwardsMultiplier: 2.5 - type: StepTrigger + triggerGroups: + types: + - SlipEntity intersectRatio: 0.04 - type: Item heldPrefix: syndie @@ -198,6 +204,9 @@ - type: Slippery paralyzeTime: 2 - type: StepTrigger + triggerGroups: + types: + - SlipEntity - type: Item heldPrefix: gibs - type: FlavorProfile diff --git a/Resources/Prototypes/Entities/Tiles/bananium.yml b/Resources/Prototypes/Entities/Tiles/bananium.yml index c9a6ec28441..9e8a46b2c35 100644 --- a/Resources/Prototypes/Entities/Tiles/bananium.yml +++ b/Resources/Prototypes/Entities/Tiles/bananium.yml @@ -47,6 +47,9 @@ paralyzeTime: 2 launchForwardsMultiplier: 1.5 - type: StepTrigger + triggerGroups: + types: + - SlipTile intersectRatio: 0.2 - type: Physics bodyType: Static diff --git a/Resources/Prototypes/Entities/Tiles/chasm.yml b/Resources/Prototypes/Entities/Tiles/chasm.yml index 23f3ad83950..85bc7b5ab34 100644 --- a/Resources/Prototypes/Entities/Tiles/chasm.yml +++ b/Resources/Prototypes/Entities/Tiles/chasm.yml @@ -14,6 +14,9 @@ blacklist: tags: - Catwalk + triggerGroups: + types: + - Chasm - type: Transform anchored: true - type: Clickable @@ -55,7 +58,7 @@ sprite: Tiles/Planet/Chasms/chromite_chasm.rsi - type: Icon sprite: Tiles/Planet/Chasms/chromite_chasm.rsi - + - type: entity parent: FloorChasmEntity id: FloorDesertChasm @@ -65,7 +68,7 @@ sprite: Tiles/Planet/Chasms/desert_chasm.rsi - type: Icon sprite: Tiles/Planet/Chasms/desert_chasm.rsi - + - type: entity parent: FloorChasmEntity id: FloorSnowChasm @@ -74,4 +77,4 @@ - type: Sprite sprite: Tiles/Planet/Chasms/snow_chasm.rsi - type: Icon - sprite: Tiles/Planet/Chasms/snow_chasm.rsi \ No newline at end of file + sprite: Tiles/Planet/Chasms/snow_chasm.rsi diff --git a/Resources/Prototypes/Entities/Tiles/lava.yml b/Resources/Prototypes/Entities/Tiles/lava.yml index 72641309b31..9d61304af9d 100644 --- a/Resources/Prototypes/Entities/Tiles/lava.yml +++ b/Resources/Prototypes/Entities/Tiles/lava.yml @@ -13,6 +13,9 @@ blacklist: tags: - Catwalk + triggerGroups: + types: + - Lava - type: Lava fireStacks: 0.75 - type: Transform diff --git a/Resources/Prototypes/Entities/Tiles/liquid_plasma.yml b/Resources/Prototypes/Entities/Tiles/liquid_plasma.yml index 08f46538631..500286ead31 100644 --- a/Resources/Prototypes/Entities/Tiles/liquid_plasma.yml +++ b/Resources/Prototypes/Entities/Tiles/liquid_plasma.yml @@ -13,6 +13,9 @@ blacklist: tags: - Catwalk + triggerGroups: + types: + - Lava - type: Lava fireStacks: 0.75 - type: Transform diff --git a/Resources/Prototypes/Nyanotrasen/Entities/Mobs/Species/felinid.yml b/Resources/Prototypes/Nyanotrasen/Entities/Mobs/Species/felinid.yml index a1ca357b080..411eb13444b 100644 --- a/Resources/Prototypes/Nyanotrasen/Entities/Mobs/Species/felinid.yml +++ b/Resources/Prototypes/Nyanotrasen/Entities/Mobs/Species/felinid.yml @@ -80,6 +80,12 @@ stripTimeReduction: 0 stripTimeMultiplier: 0.667 - type: StepTriggerImmune + whitelist: + types: + - Shard + - Landmine + - Mousetrap + - SlipEntity - type: entity save: false diff --git a/Resources/Prototypes/StepTrigger/StepTriggerTypes.yml b/Resources/Prototypes/StepTrigger/StepTriggerTypes.yml new file mode 100644 index 00000000000..6d03908a17f --- /dev/null +++ b/Resources/Prototypes/StepTrigger/StepTriggerTypes.yml @@ -0,0 +1,20 @@ +- type: stepTriggerType + id: Lava + +- type: stepTriggerType + id: Landmine + +- type: stepTriggerType + id: Shard + +- type: stepTriggerType + id: Chasm + +- type: stepTriggerType + id: Mousetrap + +- type: stepTriggerType + id: SlipTile + +- type: stepTriggerType + id: SlipEntity diff --git a/Resources/Prototypes/Traits/skills.yml b/Resources/Prototypes/Traits/skills.yml index d757cbcd564..fa79666c7ab 100644 --- a/Resources/Prototypes/Traits/skills.yml +++ b/Resources/Prototypes/Traits/skills.yml @@ -270,6 +270,12 @@ points: -3 components: - type: StepTriggerImmune + whitelist: + types: + - Shard + - Landmine + - Mousetrap + - SlipEntity requirements: - !type:CharacterSpeciesRequirement inverted: true