From 8a924c84ae57dfe18fe0c27f995b4ea16be6a527 Mon Sep 17 00:00:00 2001
From: deltanedas <39013340+deltanedas@users.noreply.github.com>
Date: Wed, 18 Sep 2024 22:36:44 +0000
Subject: [PATCH] add interaction success/failure events (#32216)
* add interaction success/failure events
* pro
---------
Co-authored-by: deltanedas <@deltanedas:kde.org>
---
.../Interaction/Events/InteractionFailureEvent.cs | 7 +++++++
.../Interaction/Events/InteractionSuccessEvent.cs | 7 +++++++
Content.Shared/Interaction/InteractionPopupSystem.cs | 7 +++++++
3 files changed, 21 insertions(+)
create mode 100644 Content.Shared/Interaction/Events/InteractionFailureEvent.cs
create mode 100644 Content.Shared/Interaction/Events/InteractionSuccessEvent.cs
diff --git a/Content.Shared/Interaction/Events/InteractionFailureEvent.cs b/Content.Shared/Interaction/Events/InteractionFailureEvent.cs
new file mode 100644
index 0000000000..a820048104
--- /dev/null
+++ b/Content.Shared/Interaction/Events/InteractionFailureEvent.cs
@@ -0,0 +1,7 @@
+namespace Content.Shared.Interaction.Events;
+
+///
+/// Raised on the target when failing to pet/hug something.
+///
+[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
index 0000000000..da4f9e43d7
--- /dev/null
+++ b/Content.Shared/Interaction/Events/InteractionSuccessEvent.cs
@@ -0,0 +1,7 @@
+namespace Content.Shared.Interaction.Events;
+
+///
+/// Raised on the target when successfully petting/hugging something.
+///
+[ByRefEvent]
+public readonly record struct InteractionSuccessEvent(EntityUid User);
diff --git a/Content.Shared/Interaction/InteractionPopupSystem.cs b/Content.Shared/Interaction/InteractionPopupSystem.cs
index 2a742d4211..20c079dfd8 100644
--- a/Content.Shared/Interaction/InteractionPopupSystem.cs
+++ b/Content.Shared/Interaction/InteractionPopupSystem.cs
@@ -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))