diff --git a/Content.Server/Interaction/Components/InteractionPopupComponent.cs b/Content.Server/Interaction/Components/InteractionPopupComponent.cs
index f41f57dd09..000344e61c 100644
--- a/Content.Server/Interaction/Components/InteractionPopupComponent.cs
+++ b/Content.Server/Interaction/Components/InteractionPopupComponent.cs
@@ -76,4 +76,10 @@ public sealed partial class InteractionPopupComponent : Component
[ViewVariables(VVAccess.ReadWrite)]
public TimeSpan LastInteractTime;
+
+ ///
+ /// If set to true, activate interactions will also trigger the component.
+ ///
+ [DataField]
+ public bool OnActivate;
}
diff --git a/Content.Server/Interaction/InteractionPopupSystem.cs b/Content.Server/Interaction/InteractionPopupSystem.cs
index 474284cf80..77b76f898a 100644
--- a/Content.Server/Interaction/InteractionPopupSystem.cs
+++ b/Content.Server/Interaction/InteractionPopupSystem.cs
@@ -20,16 +20,36 @@ public sealed class InteractionPopupSystem : EntitySystem
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
+ [Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent(OnInteractHand);
+ SubscribeLocalEvent(OnActivateInWorld);
+ }
+
+ private void OnActivateInWorld(EntityUid uid, InteractionPopupComponent component, ActivateInWorldEvent args)
+ {
+ if (!component.OnActivate)
+ return;
+
+ SharedInteract(uid, component, args, args.Target, args.User);
}
private void OnInteractHand(EntityUid uid, InteractionPopupComponent component, InteractHandEvent args)
{
- if (args.Handled || args.User == args.Target)
+ SharedInteract(uid, component, args, args.Target, args.User);
+ }
+
+ private void SharedInteract(
+ EntityUid uid,
+ InteractionPopupComponent component,
+ HandledEntityEventArgs args,
+ EntityUid target,
+ EntityUid user)
+ {
+ if (args.Handled || user == target)
return;
//Handling does nothing and this thing annoyingly plays way too often.
@@ -64,7 +84,7 @@ public sealed class InteractionPopupSystem : EntitySystem
sfx = component.InteractSuccessSound;
if (component.InteractSuccessSpawn != null)
- Spawn(component.InteractSuccessSpawn, Transform(uid).MapPosition);
+ Spawn(component.InteractSuccessSpawn, _transform.GetMapCoordinates(uid));
}
else
{
@@ -75,25 +95,25 @@ public sealed class InteractionPopupSystem : EntitySystem
sfx = component.InteractFailureSound;
if (component.InteractFailureSpawn != null)
- Spawn(component.InteractFailureSpawn, Transform(uid).MapPosition);
+ Spawn(component.InteractFailureSpawn, _transform.GetMapCoordinates(uid));
}
if (component.MessagePerceivedByOthers != null)
{
var msgOthers = Loc.GetString(component.MessagePerceivedByOthers,
- ("user", Identity.Entity(args.User, EntityManager)), ("target", Identity.Entity(uid, EntityManager)));
- _popupSystem.PopupEntity(msg, uid, args.User);
- _popupSystem.PopupEntity(msgOthers, uid, Filter.PvsExcept(args.User, entityManager: EntityManager), true);
+ ("user", Identity.Entity(user, EntityManager)), ("target", Identity.Entity(uid, EntityManager)));
+ _popupSystem.PopupEntity(msg, uid, user);
+ _popupSystem.PopupEntity(msgOthers, uid, Filter.PvsExcept(user, entityManager: EntityManager), true);
}
else
- _popupSystem.PopupEntity(msg, uid, args.User); //play only for the initiating entity.
+ _popupSystem.PopupEntity(msg, uid, user); //play only for the initiating entity.
if (sfx is not null) //not all cases will have sound.
{
if (component.SoundPerceivedByOthers)
- _audio.PlayPvs(sfx, args.Target); //play for everyone in range
+ _audio.PlayPvs(sfx, target); //play for everyone in range
else
- _audio.PlayEntity(sfx, Filter.Entities(args.User, args.Target), args.Target, true); //play only for the initiating entity and its target.
+ _audio.PlayEntity(sfx, Filter.Entities(user, target), target, true); //play only for the initiating entity and its target.
}
component.LastInteractTime = curTime;
diff --git a/Resources/Prototypes/Entities/Objects/Misc/desk_bell.yml b/Resources/Prototypes/Entities/Objects/Misc/desk_bell.yml
index 092722ec17..cef406ea50 100644
--- a/Resources/Prototypes/Entities/Objects/Misc/desk_bell.yml
+++ b/Resources/Prototypes/Entities/Objects/Misc/desk_bell.yml
@@ -14,6 +14,7 @@
params:
variation: 0.03
volume: 3
+ onActivate: true
- type: EmitSoundOnUse
sound:
collection: DeskBell