add interaction success/failure events (#32216)

* add interaction success/failure events

* pro

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2024-09-22 02:38:57 +01:00
committed by deltanedas
co-authored by deltanedas
parent e331842c01
commit 3a1d442e67
3 changed files with 21 additions and 0 deletions
@@ -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);
@@ -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);
@@ -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))