]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
ExtinguishOnTrigger and TriggerOnInteractHand (#39537)
authorāda <ss.adasts@gmail.com>
Mon, 11 Aug 2025 19:21:11 +0000 (14:21 -0500)
committerGitHub <noreply@github.com>
Mon, 11 Aug 2025 19:21:11 +0000 (21:21 +0200)
* simplely one commit

* simplelly two commit

* requested changes

---------

Co-authored-by: iaada <iaada@users.noreply.github.com>
Content.Server/Trigger/Systems/FireStackOnTriggerSystem.cs [new file with mode: 0644]
Content.Server/Trigger/Systems/FlameStackOnTriggerSystem.cs [deleted file]
Content.Server/Trigger/Systems/IgniteOnTriggerSystem.cs
Content.Shared/Trigger/Components/Effects/ExtinguishOnTriggerComponent.cs [new file with mode: 0644]
Content.Shared/Trigger/Components/Effects/FireStackOnTriggerComponent.cs [moved from Content.Shared/Trigger/Components/Effects/FlameStackOnTriggerComponent.cs with 90% similarity]
Content.Shared/Trigger/Components/Effects/IgniteOnTriggerComponent.cs
Content.Shared/Trigger/Components/Triggers/TriggerOnInteractHandComponent.cs [new file with mode: 0644]
Content.Shared/Trigger/Systems/TriggerSystem.Interaction.cs

diff --git a/Content.Server/Trigger/Systems/FireStackOnTriggerSystem.cs b/Content.Server/Trigger/Systems/FireStackOnTriggerSystem.cs
new file mode 100644 (file)
index 0000000..af3298b
--- /dev/null
@@ -0,0 +1,53 @@
+using Content.Server.Atmos.EntitySystems;
+using Content.Shared.Trigger;
+using Content.Shared.Trigger.Components.Effects;
+
+namespace Content.Server.Trigger.Systems;
+
+/// <summary>
+/// Trigger system for adding or removing fire stacks from an entity with <see cref="FlammableComponent"/>.
+/// </summary>
+/// <seealso cref="IgniteOnTriggerSystem"/>
+public sealed class FireStackOnTriggerSystem : EntitySystem
+{
+    [Dependency] private readonly FlammableSystem _flame = default!;
+
+    /// <inheritdoc/>
+    public override void Initialize()
+    {
+        base.Initialize();
+
+        SubscribeLocalEvent<FireStackOnTriggerComponent, TriggerEvent>(OnTriggerFlame);
+        SubscribeLocalEvent<ExtinguishOnTriggerComponent, TriggerEvent>(OnTriggerExtinguish);
+    }
+
+    private void OnTriggerFlame(Entity<FireStackOnTriggerComponent> ent, ref TriggerEvent args)
+    {
+        if (args.Key != null && !ent.Comp.KeysIn.Contains(args.Key))
+            return;
+
+        var target = ent.Comp.TargetUser ? args.User : ent.Owner;
+
+        if (target == null)
+            return;
+
+        _flame.AdjustFireStacks(target.Value, ent.Comp.FireStacks, ignite: ent.Comp.DoIgnite);
+
+        args.Handled = true;
+    }
+
+    private void OnTriggerExtinguish(Entity<ExtinguishOnTriggerComponent> ent, ref TriggerEvent args)
+    {
+        if (args.Key != null && !ent.Comp.KeysIn.Contains(args.Key))
+            return;
+
+        var target = ent.Comp.TargetUser ? args.User : ent.Owner;
+
+        if (target == null)
+            return;
+
+        _flame.Extinguish(target.Value);
+
+        args.Handled = true;
+    }
+}
diff --git a/Content.Server/Trigger/Systems/FlameStackOnTriggerSystem.cs b/Content.Server/Trigger/Systems/FlameStackOnTriggerSystem.cs
deleted file mode 100644 (file)
index 879d57b..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-using Content.Server.Atmos.EntitySystems;
-using Content.Shared.Trigger;
-using Content.Shared.Trigger.Components.Effects;
-
-namespace Content.Server.Trigger.Systems;
-
-/// <summary>
-/// Trigger system for setting something on fire.
-/// </summary>
-/// <seealso cref="IgniteOnTriggerSystem"/>
-public sealed class FlameStackOnTriggerSystem : EntitySystem
-{
-    [Dependency] private readonly FlammableSystem _flame = default!;
-
-    /// <inheritdoc/>
-    public override void Initialize()
-    {
-        base.Initialize();
-
-        SubscribeLocalEvent<FlameStackOnTriggerComponent, TriggerEvent>(OnTrigger);
-    }
-
-    private void OnTrigger(Entity<FlameStackOnTriggerComponent> ent, ref TriggerEvent args)
-    {
-        if (args.Key != null && !ent.Comp.KeysIn.Contains(args.Key))
-            return;
-
-        var target = ent.Comp.TargetUser ? args.User : ent.Owner;
-
-        if (target == null)
-            return;
-
-        _flame.AdjustFireStacks(target.Value, ent.Comp.FireStacks, ignite: ent.Comp.DoIgnite);
-
-        args.Handled = true;
-    }
-}
index b19f4738ca90889a277f51ea9258ff369b89ec77..c6ae16ec78fb9a5f852b40a013e2b524c1dbbc98 100644 (file)
@@ -8,7 +8,7 @@ namespace Content.Server.Trigger.Systems;
 /// <summary>
 /// Handles igniting when triggered and stopping ignition after the delay.
 /// </summary>
-/// <seealso cref="FlameStackOnTriggerSystem"/>
+/// <seealso cref="FireStackOnTriggerSystem"/>
 public sealed class IgniteOnTriggerSystem : EntitySystem
 {
     [Dependency] private readonly IGameTiming _timing = default!;
diff --git a/Content.Shared/Trigger/Components/Effects/ExtinguishOnTriggerComponent.cs b/Content.Shared/Trigger/Components/Effects/ExtinguishOnTriggerComponent.cs
new file mode 100644 (file)
index 0000000..43208a9
--- /dev/null
@@ -0,0 +1,10 @@
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Trigger.Components.Effects;
+
+/// <summary>
+/// This trigger removes all the fire stacks on a target with <see cref="FlammableComponent"/>.
+/// If TargetUser is true, the entity that caused this trigger will be extinguished instead.
+/// </summary>
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
+public sealed partial class ExtinguishOnTriggerComponent : BaseXOnTriggerComponent;
similarity index 90%
rename from Content.Shared/Trigger/Components/Effects/FlameStackOnTriggerComponent.cs
rename to Content.Shared/Trigger/Components/Effects/FireStackOnTriggerComponent.cs
index f7186ae003b9232969636d6aca5040dc88fd42e2..cde5075e9b693b9a9c6547ba4a77b059cd70f69e 100644 (file)
@@ -9,7 +9,7 @@ namespace Content.Shared.Trigger.Components.Effects;
 /// </summary>
 /// <seealso cref="IgniteOnTriggerComponent"/>
 [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
-public sealed partial class FlameStackOnTriggerComponent : BaseXOnTriggerComponent
+public sealed partial class FireStackOnTriggerComponent : BaseXOnTriggerComponent
 {
     /// <summary>
     /// How many fire stacks to add or remove.
index e9f51cf4e78b8c200aabdf0d4353a194b45a633f..3e3db526e4b350859741c957a84f12677bccc70a 100644 (file)
@@ -8,7 +8,7 @@ namespace Content.Shared.Trigger.Components.Effects;
 /// Requires <see cref="IgnitionSourceComponent"/> along with triggering components.
 /// The if TargetUser is true they will be ignited instead (they need IgnitionSourceComponent as well).
 /// </summary>
-/// <seealso cref="FlameStackOnTriggerComponent"/>
+/// <seealso cref="FireStackOnTriggerComponent"/>
 [RegisterComponent, NetworkedComponent]
 [AutoGenerateComponentState, AutoGenerateComponentPause]
 public sealed partial class IgniteOnTriggerComponent : BaseXOnTriggerComponent
diff --git a/Content.Shared/Trigger/Components/Triggers/TriggerOnInteractHandComponent.cs b/Content.Shared/Trigger/Components/Triggers/TriggerOnInteractHandComponent.cs
new file mode 100644 (file)
index 0000000..ca7e96b
--- /dev/null
@@ -0,0 +1,11 @@
+using Content.Shared.Interaction;
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Trigger.Components.Triggers;
+
+/// <summary>
+/// Trigger on <see cref="InteractHandEvent"/>, aka clicking on an entity with an empty hand.
+/// User is the player with the hand doing the clicking.
+/// </summary>
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
+public sealed partial class TriggerOnInteractHandComponent : BaseTriggerOnXComponent;
index f50690976043a3a69c1cd11796232bbe3b7a06d2..035ef4ec9119363f7da5a7c4e0b6fa9430148faa 100644 (file)
@@ -12,6 +12,7 @@ public sealed partial class TriggerSystem
     {
         SubscribeLocalEvent<TriggerOnActivateComponent, ActivateInWorldEvent>(OnActivate);
         SubscribeLocalEvent<TriggerOnUseComponent, UseInHandEvent>(OnUse);
+        SubscribeLocalEvent<TriggerOnInteractHandComponent, InteractHandEvent>(OnInteractHand);
 
         SubscribeLocalEvent<ItemToggleOnTriggerComponent, TriggerEvent>(HandleItemToggleOnTrigger);
         SubscribeLocalEvent<AnchorOnTriggerComponent, TriggerEvent>(HandleAnchorOnTrigger);
@@ -39,6 +40,15 @@ public sealed partial class TriggerSystem
         args.Handled = true;
     }
 
+    private void OnInteractHand(Entity<TriggerOnInteractHandComponent> ent, ref InteractHandEvent args)
+    {
+        if (args.Handled)
+            return;
+
+        Trigger(ent.Owner, args.User, ent.Comp.KeyOut);
+        args.Handled = true;
+    }
+
     private void HandleItemToggleOnTrigger(Entity<ItemToggleOnTriggerComponent> ent, ref TriggerEvent args)
     {
         if (args.Key != null && !ent.Comp.KeysIn.Contains(args.Key))