]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
add interaction success/failure events (#32216)
authordeltanedas <39013340+deltanedas@users.noreply.github.com>
Wed, 18 Sep 2024 22:36:44 +0000 (22:36 +0000)
committerGitHub <noreply@github.com>
Wed, 18 Sep 2024 22:36:44 +0000 (00:36 +0200)
* add interaction success/failure events

* pro

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
Content.Shared/Interaction/Events/InteractionFailureEvent.cs [new file with mode: 0644]
Content.Shared/Interaction/Events/InteractionSuccessEvent.cs [new file with mode: 0644]
Content.Shared/Interaction/InteractionPopupSystem.cs

diff --git a/Content.Shared/Interaction/Events/InteractionFailureEvent.cs b/Content.Shared/Interaction/Events/InteractionFailureEvent.cs
new file mode 100644 (file)
index 0000000..a820048
--- /dev/null
@@ -0,0 +1,7 @@
+namespace Content.Shared.Interaction.Events;
+
+/// <summary>
+/// Raised on the target when failing to pet/hug something.
+/// </summary>
+[ByRefEvent]
+public readonly record struct InteractionFailureEvent(EntityUid User);
diff --git a/Content.Shared/Interaction/Events/InteractionSuccessEvent.cs b/Content.Shared/Interaction/Events/InteractionSuccessEvent.cs
new file mode 100644 (file)
index 0000000..da4f9e4
--- /dev/null
@@ -0,0 +1,7 @@
+namespace Content.Shared.Interaction.Events;
+
+/// <summary>
+/// Raised on the target when successfully petting/hugging something.
+/// </summary>
+[ByRefEvent]
+public readonly record struct InteractionSuccessEvent(EntityUid User);
index 2a742d4211b6cf0bfd043e8cfa8ef9d027ad8e68..20c079dfd8c8d07c35f27ed0b8972710e6d3be78 100644 (file)
@@ -1,6 +1,7 @@
 using Content.Shared.Bed.Sleep;
 using Content.Shared.IdentityManagement;
 using Content.Shared.Interaction.Components;
+using Content.Shared.Interaction.Events;
 using Content.Shared.Mobs.Components;
 using Content.Shared.Mobs.Systems;
 using Content.Shared.Popups;
@@ -100,6 +101,9 @@ public sealed class InteractionPopupSystem : EntitySystem
 
             if (component.InteractSuccessSpawn != null)
                 Spawn(component.InteractSuccessSpawn, _transform.GetMapCoordinates(uid));
+
+            var ev = new InteractionSuccessEvent(user);
+            RaiseLocalEvent(target, ref ev);
         }
         else
         {
@@ -111,6 +115,9 @@ public sealed class InteractionPopupSystem : EntitySystem
 
             if (component.InteractFailureSpawn != null)
                 Spawn(component.InteractFailureSpawn, _transform.GetMapCoordinates(uid));
+
+            var ev = new InteractionFailureEvent(user);
+            RaiseLocalEvent(target, ref ev);
         }
 
         if (!string.IsNullOrEmpty(component.MessagePerceivedByOthers))