diff --git a/Content.Shared/Sound/Components/EmitSoundOnThrowComponent.cs b/Content.Shared/Sound/Components/EmitSoundOnThrowComponent.cs
index 76e9f08076..0498642c00 100644
--- a/Content.Shared/Sound/Components/EmitSoundOnThrowComponent.cs
+++ b/Content.Shared/Sound/Components/EmitSoundOnThrowComponent.cs
@@ -3,7 +3,7 @@ using Robust.Shared.GameStates;
namespace Content.Shared.Sound.Components;
///
-/// Simple sound emitter that emits sound on ThrowEvent
+/// Simple sound emitter that emits sound on ThrownEvent
///
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class EmitSoundOnThrowComponent : BaseEmitSoundComponent;
diff --git a/Content.Shared/Throwing/ThrowEvents.cs b/Content.Shared/Throwing/ThrowEvents.cs
index fbda80b8ca..8b60a7b4b1 100644
--- a/Content.Shared/Throwing/ThrowEvents.cs
+++ b/Content.Shared/Throwing/ThrowEvents.cs
@@ -1,39 +1,25 @@
-namespace Content.Shared.Throwing
-{
- ///
- /// Base class for all throw events.
- ///
- public abstract class ThrowEvent : HandledEntityEventArgs
- {
- public readonly EntityUid Thrown;
- public readonly EntityUid Target;
- public ThrownItemComponent Component;
+namespace Content.Shared.Throwing;
- public ThrowEvent(EntityUid thrown, EntityUid target, ThrownItemComponent component)
- {
- Thrown = thrown;
- Target = target;
- Component = component;
- }
- }
+///
+/// Raised on an entity after it has thrown something.
+///
+[ByRefEvent]
+public readonly record struct ThrowEvent(EntityUid? User, EntityUid Thrown);
- ///
- /// Raised directed on the target entity being hit by the thrown entity.
- ///
- public sealed class ThrowHitByEvent : ThrowEvent
- {
- public ThrowHitByEvent(EntityUid thrown, EntityUid target, ThrownItemComponent component) : base(thrown, target, component)
- {
- }
- }
+///
+/// Raised on an entity after it has been thrown.
+///
+[ByRefEvent]
+public readonly record struct ThrownEvent(EntityUid? User, EntityUid Thrown);
- ///
- /// Raised directed on the thrown entity that hits another.
- ///
- public sealed class ThrowDoHitEvent : ThrowEvent
- {
- public ThrowDoHitEvent(EntityUid thrown, EntityUid target, ThrownItemComponent component) : base(thrown, target, component)
- {
- }
- }
-}
+///
+/// Raised directed on the target entity being hit by the thrown entity.
+///
+[ByRefEvent]
+public readonly record struct ThrowHitByEvent(EntityUid Thrown, EntityUid Target, ThrownItemComponent Component);
+
+///
+/// Raised directed on the thrown entity that hits another.
+///
+[ByRefEvent]
+public readonly record struct ThrowDoHitEvent(EntityUid Thrown, EntityUid Target, ThrownItemComponent Component);
diff --git a/Content.Shared/Throwing/ThrowingSystem.cs b/Content.Shared/Throwing/ThrowingSystem.cs
index ceb9cf8bfb..4e44901c57 100644
--- a/Content.Shared/Throwing/ThrowingSystem.cs
+++ b/Content.Shared/Throwing/ThrowingSystem.cs
@@ -192,8 +192,6 @@ public sealed class ThrowingSystem : EntitySystem
}
}
- var throwEvent = new ThrownEvent(user, uid);
- RaiseLocalEvent(uid, ref throwEvent, true);
if (user != null)
_adminLogger.Add(LogType.Throw, LogImpact.Low, $"{ToPrettyString(user.Value):user} threw {ToPrettyString(uid):entity}");
@@ -206,6 +204,14 @@ public sealed class ThrowingSystem : EntitySystem
var impulseVector = direction.Normalized() * throwSpeed * physics.Mass;
_physics.ApplyLinearImpulse(uid, impulseVector, body: physics);
+ var thrownEvent = new ThrownEvent(user, uid);
+ RaiseLocalEvent(uid, ref thrownEvent, true);
+ if (user != null)
+ {
+ var throwEvent = new ThrowEvent(user, uid);
+ RaiseLocalEvent(user.Value, ref throwEvent, true);
+ }
+
if (comp.LandTime == null || comp.LandTime <= TimeSpan.Zero)
{
_thrownSystem.LandComponent(uid, comp, physics, playSound);
diff --git a/Content.Shared/Throwing/ThrownEvent.cs b/Content.Shared/Throwing/ThrownEvent.cs
deleted file mode 100644
index 70cb6ee43d..0000000000
--- a/Content.Shared/Throwing/ThrownEvent.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using JetBrains.Annotations;
-
-namespace Content.Shared.Throwing;
-
-///
-/// Raised on thrown entity.
-///
-[PublicAPI]
-[ByRefEvent]
-public readonly record struct ThrownEvent(EntityUid? User, EntityUid Thrown);
diff --git a/Content.Shared/Throwing/ThrownItemSystem.cs b/Content.Shared/Throwing/ThrownItemSystem.cs
index 65c5a0f13e..5adad359e5 100644
--- a/Content.Shared/Throwing/ThrownItemSystem.cs
+++ b/Content.Shared/Throwing/ThrownItemSystem.cs
@@ -140,8 +140,10 @@ namespace Content.Shared.Throwing
_adminLogger.Add(LogType.ThrowHit, LogImpact.Low,
$"{ToPrettyString(thrown):thrown} thrown by {ToPrettyString(component.Thrower.Value):thrower} hit {ToPrettyString(target):target}.");
- RaiseLocalEvent(target, new ThrowHitByEvent(thrown, target, component), true);
- RaiseLocalEvent(thrown, new ThrowDoHitEvent(thrown, target, component), true);
+ var hitByEv = new ThrowHitByEvent(thrown, target, component);
+ var doHitEv = new ThrowDoHitEvent(thrown, target, component);
+ RaiseLocalEvent(target, ref hitByEv, true);
+ RaiseLocalEvent(thrown, ref doHitEv, true);
}
public override void Update(float frameTime)
diff --git a/Content.Shared/Trigger/Components/Triggers/TriggerOnThrowComponent.cs b/Content.Shared/Trigger/Components/Triggers/TriggerOnThrowComponent.cs
new file mode 100644
index 0000000000..e9249a8f2a
--- /dev/null
+++ b/Content.Shared/Trigger/Components/Triggers/TriggerOnThrowComponent.cs
@@ -0,0 +1,10 @@
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Trigger.Components.Triggers;
+
+///
+/// Triggers when after an entity has thrown something.
+/// The user is the thrown item.
+///
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
+public sealed partial class TriggerOnThrowComponent : BaseTriggerOnXComponent;
diff --git a/Content.Shared/Trigger/Components/Triggers/TriggerOnThrownComponent.cs b/Content.Shared/Trigger/Components/Triggers/TriggerOnThrownComponent.cs
new file mode 100644
index 0000000000..e309261711
--- /dev/null
+++ b/Content.Shared/Trigger/Components/Triggers/TriggerOnThrownComponent.cs
@@ -0,0 +1,10 @@
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Trigger.Components.Triggers;
+
+///
+/// Triggers when an entity was thrown.
+/// The user is the thrower.
+///
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
+public sealed partial class TriggerOnThrownComponent : BaseTriggerOnXComponent;
diff --git a/Content.Shared/Trigger/Systems/TriggerSystem.Interaction.cs b/Content.Shared/Trigger/Systems/TriggerSystem.Interaction.cs
index 230b628663..39ef4889de 100644
--- a/Content.Shared/Trigger/Systems/TriggerSystem.Interaction.cs
+++ b/Content.Shared/Trigger/Systems/TriggerSystem.Interaction.cs
@@ -2,6 +2,7 @@
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Item.ItemToggle.Components;
+using Content.Shared.Throwing;
using Content.Shared.Trigger.Components.Triggers;
using Content.Shared.Trigger.Components.Effects;
@@ -12,10 +13,11 @@ public sealed partial class TriggerSystem
private void InitializeInteraction()
{
SubscribeLocalEvent(OnExamined);
-
SubscribeLocalEvent(OnActivate);
SubscribeLocalEvent(OnUse);
SubscribeLocalEvent(OnInteractHand);
+ SubscribeLocalEvent(OnThrow);
+ SubscribeLocalEvent(OnThrown);
SubscribeLocalEvent(HandleItemToggleOnTrigger);
SubscribeLocalEvent(HandleAnchorOnTrigger);
@@ -57,6 +59,16 @@ public sealed partial class TriggerSystem
args.Handled = true;
}
+ private void OnThrow(Entity ent, ref ThrowEvent args)
+ {
+ Trigger(ent.Owner, args.Thrown, ent.Comp.KeyOut);
+ }
+
+ private void OnThrown(Entity ent, ref ThrownEvent args)
+ {
+ Trigger(ent.Owner, args.User, ent.Comp.KeyOut);
+ }
+
private void HandleItemToggleOnTrigger(Entity ent, ref TriggerEvent args)
{
if (args.Key != null && !ent.Comp.KeysIn.Contains(args.Key))