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)
|
||||
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)
|
||||
return;
|
||||
|
||||
@@ -718,20 +709,9 @@ namespace Content.Shared.Interaction
|
||||
|
||||
var activateMsg = new ActivateInWorldEvent(user, used);
|
||||
RaiseLocalEvent(used, activateMsg, true);
|
||||
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)
|
||||
if (!activateMsg.Handled)
|
||||
return false;
|
||||
|
||||
activatable.Activate(new ActivateEventArgs(user, used));
|
||||
|
||||
// No way to check success.
|
||||
_useDelay.BeginDelay(used, delayComponent);
|
||||
_adminLogger.Add(LogType.InteractActivate, LogImpact.Low, $"{ToPrettyString(user):user} activated {ToPrettyString(used):used}");
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user