@@ -14,9 +14,8 @@ namespace Content.Server.Radio.Components
|
|||||||
[ComponentProtoName("Radio")]
|
[ComponentProtoName("Radio")]
|
||||||
[ComponentReference(typeof(IRadio))]
|
[ComponentReference(typeof(IRadio))]
|
||||||
[ComponentReference(typeof(IListen))]
|
[ComponentReference(typeof(IListen))]
|
||||||
[ComponentReference(typeof(IActivate))]
|
|
||||||
#pragma warning disable 618
|
#pragma warning disable 618
|
||||||
public sealed class HandheldRadioComponent : Component, IListen, IRadio, IActivate
|
public sealed class HandheldRadioComponent : Component, IListen, IRadio
|
||||||
#pragma warning restore 618
|
#pragma warning restore 618
|
||||||
{
|
{
|
||||||
private ChatSystem _chatSystem = default!;
|
private ChatSystem _chatSystem = default!;
|
||||||
@@ -98,10 +97,5 @@ namespace Content.Server.Radio.Components
|
|||||||
{
|
{
|
||||||
_radioSystem.SpreadMessage(this, speaker, message, channel);
|
_radioSystem.SpreadMessage(this, speaker, message, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IActivate.Activate(ActivateEventArgs eventArgs)
|
|
||||||
{
|
|
||||||
Use(eventArgs.User);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using Content.Server.Radio.Components;
|
using Content.Server.Radio.Components;
|
||||||
using Content.Shared.Radio;
|
using Content.Shared.Radio;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Content.Shared.Interaction;
|
||||||
|
|
||||||
namespace Content.Server.Radio.EntitySystems
|
namespace Content.Server.Radio.EntitySystems
|
||||||
{
|
{
|
||||||
@@ -15,6 +16,16 @@ namespace Content.Server.Radio.EntitySystems
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<HandheldRadioComponent, ExaminedEvent>(OnExamine);
|
SubscribeLocalEvent<HandheldRadioComponent, ExaminedEvent>(OnExamine);
|
||||||
|
SubscribeLocalEvent<HandheldRadioComponent, ActivateInWorldEvent>(OnActivate);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnActivate(EntityUid uid, HandheldRadioComponent component, ActivateInWorldEvent args)
|
||||||
|
{
|
||||||
|
if (args.Handled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
args.Handled = true;
|
||||||
|
component.Use(args.User);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnExamine(EntityUid uid, HandheldRadioComponent component, ExaminedEvent args)
|
private void OnExamine(EntityUid uid, HandheldRadioComponent component, ExaminedEvent args)
|
||||||
|
|||||||
26
Content.Shared/Interaction/ActivateInWorldEvent.cs
Normal file
26
Content.Shared/Interaction/ActivateInWorldEvent.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using JetBrains.Annotations;
|
||||||
|
|
||||||
|
namespace Content.Shared.Interaction;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raised when an entity is activated in the world.
|
||||||
|
/// </summary>
|
||||||
|
[PublicAPI]
|
||||||
|
public sealed class ActivateInWorldEvent : HandledEntityEventArgs, ITargetedInteractEventArgs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Entity that activated the target world entity.
|
||||||
|
/// </summary>
|
||||||
|
public EntityUid User { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Entity that was activated in the world.
|
||||||
|
/// </summary>
|
||||||
|
public EntityUid Target { get; }
|
||||||
|
|
||||||
|
public ActivateInWorldEvent(EntityUid user, EntityUid target)
|
||||||
|
{
|
||||||
|
User = user;
|
||||||
|
Target = target;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
using JetBrains.Annotations;
|
|
||||||
|
|
||||||
namespace Content.Shared.Interaction
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// This interface gives components behavior when being activated (by default,
|
|
||||||
/// this is done via the "E" key) when the user is in range and has unobstructed access to the target entity
|
|
||||||
/// (allows inside blockers). This includes activating an object in the world as well as activating an
|
|
||||||
/// object in inventory. Unlike IUse, this can be performed on entities that aren't in the active hand,
|
|
||||||
/// even when the active hand is currently holding something else.
|
|
||||||
/// </summary>
|
|
||||||
[RequiresExplicitImplementation]
|
|
||||||
public interface IActivate
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Called when this component is activated by another entity who is in range.
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("Use ActivateInWorldMessage instead")]
|
|
||||||
void Activate(ActivateEventArgs eventArgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public sealed class ActivateEventArgs : EventArgs, ITargetedInteractEventArgs
|
|
||||||
{
|
|
||||||
public ActivateEventArgs(EntityUid user, EntityUid target)
|
|
||||||
{
|
|
||||||
User = user;
|
|
||||||
Target = target;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityUid User { get; }
|
|
||||||
public EntityUid Target { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Raised when an entity is activated in the world.
|
|
||||||
/// </summary>
|
|
||||||
[PublicAPI]
|
|
||||||
public sealed class ActivateInWorldEvent : HandledEntityEventArgs, ITargetedInteractEventArgs
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Entity that activated the target world entity.
|
|
||||||
/// </summary>
|
|
||||||
public EntityUid User { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Entity that was activated in the world.
|
|
||||||
/// </summary>
|
|
||||||
public EntityUid Target { get; }
|
|
||||||
|
|
||||||
public ActivateInWorldEvent(EntityUid user, EntityUid target)
|
|
||||||
{
|
|
||||||
User = user;
|
|
||||||
Target = target;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -649,15 +649,6 @@ namespace Content.Shared.Interaction
|
|||||||
if (afterInteractEvent.Handled)
|
if (afterInteractEvent.Handled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var afterInteractEventArgs = new AfterInteractEventArgs(user, clickLocation, target, canReach);
|
|
||||||
var afterInteracts = AllComps<IAfterInteract>(used).OrderByDescending(x => x.Priority).ToList();
|
|
||||||
|
|
||||||
foreach (var afterInteract in afterInteracts)
|
|
||||||
{
|
|
||||||
if (await afterInteract.AfterInteract(afterInteractEventArgs))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target == null)
|
if (target == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -718,20 +709,9 @@ namespace Content.Shared.Interaction
|
|||||||
|
|
||||||
var activateMsg = new ActivateInWorldEvent(user, used);
|
var activateMsg = new ActivateInWorldEvent(user, used);
|
||||||
RaiseLocalEvent(used, activateMsg, true);
|
RaiseLocalEvent(used, activateMsg, true);
|
||||||
if (activateMsg.Handled)
|
if (!activateMsg.Handled)
|
||||||
{
|
|
||||||
_useDelay.BeginDelay(used, delayComponent);
|
|
||||||
_adminLogger.Add(LogType.InteractActivate, LogImpact.Low, $"{ToPrettyString(user):user} activated {ToPrettyString(used):used}");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
var activatable = AllComps<IActivate>(used).FirstOrDefault();
|
|
||||||
if (activatable == null)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
activatable.Activate(new ActivateEventArgs(user, used));
|
|
||||||
|
|
||||||
// No way to check success.
|
|
||||||
_useDelay.BeginDelay(used, delayComponent);
|
_useDelay.BeginDelay(used, delayComponent);
|
||||||
_adminLogger.Add(LogType.InteractActivate, LogImpact.Low, $"{ToPrettyString(user):user} activated {ToPrettyString(used):used}");
|
_adminLogger.Add(LogType.InteractActivate, LogImpact.Low, $"{ToPrettyString(user):user} activated {ToPrettyString(used):used}");
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user