Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Port] StepTriggerGroup From WhiteDream #929

Merged
merged 4 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions Content.Shared/StepTrigger/Components/StepTriggerComponent.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Shared.StepTrigger.Prototypes;
using Content.Shared.StepTrigger.Systems;
using Content.Shared.Whitelist;
using Robust.Shared.GameStates;
Expand Down Expand Up @@ -53,15 +54,18 @@ public sealed partial class StepTriggerComponent : Component
public bool IgnoreWeightless;

/// <summary>
/// Does this have separate "StepOn" and "StepOff" triggers.
/// Does this have separate "StepOn" and "StepOff" triggers.
/// </summary>
[DataField, AutoNetworkedField]
public bool StepOn = false;

/// <summary>
/// If TriggerGroups is specified, it will check StepTriggerImmunityComponent to have the same TriggerType to activate immunity
/// </summary>
[DataField]
public StepTriggerGroup? TriggerGroups;
}

[RegisterComponent]
[Access(typeof(StepTriggerSystem))]
public sealed partial class StepTriggerActiveComponent : Component
{

}
public sealed partial class StepTriggerActiveComponent : Component { }
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Content.Shared.StepTrigger.Prototypes;
using Content.Shared.StepTrigger.Systems;
using Robust.Shared.GameStates;

namespace Content.Shared.StepTrigger.Components;
Expand All @@ -12,4 +14,12 @@ namespace Content.Shared.StepTrigger.Components;
/// Consider using a subscription to StepTriggerAttemptEvent if you wish to be more selective.
/// </remarks>
[RegisterComponent, NetworkedComponent]
public sealed partial class StepTriggerImmuneComponent : Component { }
[Access(typeof(StepTriggerSystem))]
public sealed partial class StepTriggerImmuneComponent : Component
{
/// <summary>
/// WhiteList of immunity step triggers.
/// </summary>
[DataField]
public StepTriggerGroup? Whitelist;
}
72 changes: 72 additions & 0 deletions Content.Shared/StepTrigger/Prototypes/StepTriggerGroup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using Content.Shared.StepTrigger.Components;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;

namespace Content.Shared.StepTrigger.Prototypes;

/// <summary>
/// A group of <see cref="StepTriggerTypePrototype">
/// Used to determine StepTriggerTypes like Tags.
/// Used for better work with Immunity.
/// StepTriggerTypes in StepTriggerTypes.yml
/// </summary>
/// <code>
/// stepTriggerGroups:
/// types:
/// - Lava
/// - Landmine
/// - Shard
/// - Chasm
/// - Mousetrap
/// - SlipTile
/// - SlipEntity
/// </code>
[DataDefinition]
[Serializable, NetSerializable]
public sealed partial class StepTriggerGroup
{
[DataField]
public List<ProtoId<StepTriggerTypePrototype>>? Types = null;

/// <summary>
/// Checks if types of this StepTriggerGroup is similar to types of AnotherGroup
/// </summary>
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;
}

/// <summary>
/// Checks validation (if types of this StepTriggerGroup are similar to types of
/// another StepTriggerComponent.
/// </summary>
public bool IsValid(StepTriggerComponent component)
{
if (component.TriggerGroups is null)
return false;

return IsValid(component.TriggerGroups);
}

/// <summary>
/// Checks validation (if types of this StepTriggerGroup are similar to types of
/// another StepTriggerImmuneComponent.
/// </summary>
public bool IsValid(StepTriggerImmuneComponent component)
{
if (component.Whitelist is null)
return false;

return IsValid(component.Whitelist);
}
}
15 changes: 15 additions & 0 deletions Content.Shared/StepTrigger/Prototypes/StepTriggerTypePrototype.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Robust.Shared.Prototypes;

namespace Content.Shared.StepTrigger.Prototypes;

/// <summary>
/// Prototype representing a StepTriggerType in YAML.
/// Meant to only have an ID property, as that is the only thing that
/// gets saved in StepTriggerGroup.
/// </summary>
[Prototype]
public sealed partial class StepTriggerTypePrototype : IPrototype
{
[ViewVariables, IdDataField]
public string ID { get; private set; } = default!;
}
9 changes: 7 additions & 2 deletions Content.Shared/StepTrigger/Systems/StepTriggerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,16 @@ private void UpdateColliding(EntityUid uid, StepTriggerComponent component, Tran

private bool CanTrigger(EntityUid uid, EntityUid otherUid, StepTriggerComponent component)
{
if (HasComp<StepTriggerImmuneComponent>(otherUid)
|| !component.Active
if (!component.Active
|| component.CurrentlySteppedOn.Contains(otherUid))
return false;

// Immunity checks
if (TryComp<StepTriggerImmuneComponent>(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
Expand Down
5 changes: 4 additions & 1 deletion Resources/Prototypes/Entities/Effects/chemistry_effects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
animationState: foam-dissolve
- type: Slippery
- type: StepTrigger
triggerGroups: # WD EDIT
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
types:
- SlipTile
# disabled until foam reagent duplication is fixed
#- type: ScoopableSolution
# solution: solutionArea
Expand Down Expand Up @@ -135,7 +138,7 @@
- type: RCDDeconstructable
cost: 2
delay: 2
fx: EffectRCDDeconstruct2
fx: EffectRCDDeconstruct2
- type: Clickable
- type: InteractionOutline
- type: Sprite
Expand Down
3 changes: 3 additions & 0 deletions Resources/Prototypes/Entities/Effects/puddle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@
- type: EdgeSpreader
id: Puddle
- type: StepTrigger
triggerGroups:
types:
- SlipTile
- type: Drink
delay: 3
transferAmount: 1
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Entities/Mobs/NPCs/animals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1689,6 +1689,10 @@
- type: FireVisuals
sprite: Mobs/Effects/onfire.rsi
normalState: Mouse_burning
- type: StepTriggerImmune # WD EDIT START
whitelist:
types:
- Landmine # END
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved

- type: entity
parent: MobMouse
Expand Down
3 changes: 3 additions & 0 deletions Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@
- type: Speech
speechVerb: Cluwne
- type: StepTrigger
triggerGroups:
types:
- SlipEntity
intersectRatio: 0.2
- type: Fixtures
fixtures:
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Entities/Mobs/Player/ipc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@
- type: OfferItem
- type: LayingDown
- type: Carriable
- type: StepTriggerImmune #WD EDIT
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
whitelist:
types:
- Shard

- type: entity
save: false
Expand Down
5 changes: 5 additions & 0 deletions Resources/Prototypes/Entities/Mobs/Species/harpy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@
- GalacticCommon
- SolCommon
- type: StepTriggerImmune
whitelist: # WD EDIT
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
types:
- Shard
- Landmine
- Mousetrap

- type: entity
save: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@
launchForwardsMultiplier: 1.5
- type: StepTrigger
intersectRatio: 0.2
triggerGroups:
types:
- SlipEntity
- type: CollisionWake
enabled: false
- type: Physics
Expand Down
3 changes: 3 additions & 0 deletions Resources/Prototypes/Entities/Objects/Devices/mousetrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
- type: StepTrigger
intersectRatio: 0.2
requiredTriggeredSpeed: 0
triggerGroups: # WD EDIT
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
types:
- Mousetrap
- type: Mousetrap
- type: TriggerOnStepTrigger
- type: ShoesRequiredStepTrigger
Expand Down
3 changes: 3 additions & 0 deletions Resources/Prototypes/Entities/Objects/Devices/pda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@
paralyzeTime: 4
launchForwardsMultiplier: 1.5
- type: StepTrigger
triggerGroups: # WD EDIT
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
types:
- SlipEntity
- type: CollisionWake
enabled: false
- type: Physics
Expand Down
3 changes: 3 additions & 0 deletions Resources/Prototypes/Entities/Objects/Fun/dice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@
mask:
- ItemMask
- type: StepTrigger
triggerGroups: # WD EDIT
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
types:
- Shard
intersectRatio: 0.2
- type: TriggerOnStepTrigger
- type: ShoesRequiredStepTrigger
Expand Down
3 changes: 3 additions & 0 deletions Resources/Prototypes/Entities/Objects/Materials/shards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
- !type:DoActsBehavior
acts: [ "Destruction" ]
- type: StepTrigger
triggerGroups: # WD EDIT
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
types:
- Shard
intersectRatio: 0.2
- type: ShoesRequiredStepTrigger
- type: Slippery
Expand Down
3 changes: 3 additions & 0 deletions Resources/Prototypes/Entities/Objects/Misc/land_mine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
params:
maxDistance: 10
- type: StepTrigger
triggerGroups: # WD EDIT
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
types:
- Landmine
requiredTriggeredSpeed: 0
stepOn: true

Expand Down
3 changes: 3 additions & 0 deletions Resources/Prototypes/Entities/Objects/Misc/spider_web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@
paralyzeTime: 2
launchForwardsMultiplier: 1.5
- type: StepTrigger
triggerGroups:
types:
- SlipTile
intersectRatio: 0.2
- type: Physics
- type: Fixtures
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
paralyzeTime: 2
launchForwardsMultiplier: 1.5
- type: StepTrigger
triggerGroups: # WD EDIT
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
types:
- SlipEntity
intersectRatio: 0.2
- type: CollisionWake
enabled: false
Expand Down Expand Up @@ -157,6 +160,9 @@
paralyzeTime: 5
launchForwardsMultiplier: 2.5
- type: StepTrigger
triggerGroups: # WD EDIT
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
types:
- SlipEntity
intersectRatio: 0.04
- type: Item
heldPrefix: syndie
Expand Down Expand Up @@ -198,6 +204,9 @@
- type: Slippery
paralyzeTime: 2
- type: StepTrigger
triggerGroups: # WD EDIT
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
types:
- SlipEntity
- type: Item
heldPrefix: gibs
- type: FlavorProfile
Expand Down
3 changes: 3 additions & 0 deletions Resources/Prototypes/Entities/Tiles/bananium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
paralyzeTime: 2
launchForwardsMultiplier: 1.5
- type: StepTrigger
triggerGroups: # WD EDIT
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
types:
- SlipTile
intersectRatio: 0.2
- type: Physics
bodyType: Static
Expand Down
9 changes: 6 additions & 3 deletions Resources/Prototypes/Entities/Tiles/chasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
blacklist:
tags:
- Catwalk
triggerGroups: # WD EDIT
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
types:
- Chasm
- type: Transform
anchored: true
- type: Clickable
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -74,4 +77,4 @@
- type: Sprite
sprite: Tiles/Planet/Chasms/snow_chasm.rsi
- type: Icon
sprite: Tiles/Planet/Chasms/snow_chasm.rsi
sprite: Tiles/Planet/Chasms/snow_chasm.rsi
3 changes: 3 additions & 0 deletions Resources/Prototypes/Entities/Tiles/lava.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
blacklist:
tags:
- Catwalk
triggerGroups: # WD EDIT
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
types:
- Lava
- type: Lava
fireStacks: 0.75
- type: Transform
Expand Down
3 changes: 3 additions & 0 deletions Resources/Prototypes/Entities/Tiles/liquid_plasma.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
blacklist:
tags:
- Catwalk
triggerGroups: # WD EDIT
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
types:
- Lava
- type: Lava
fireStacks: 0.75
- type: Transform
Expand Down
Loading
Loading