Files
OldThink/Content.Shared/Interaction/IActivate.cs

60 lines
1.9 KiB
C#
Raw Normal View History

using System;
using JetBrains.Annotations;
2021-01-23 22:45:23 +01:00
using Robust.Shared.Analyzers;
using Robust.Shared.GameObjects;
2021-06-09 22:19:39 +02:00
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>
2021-01-23 20:00:29 +01:00
[RequiresExplicitImplementation]
public interface IActivate
{
/// <summary>
/// Called when this component is activated by another entity who is in range.
/// </summary>
2021-04-29 03:23:15 +10:00
[Obsolete("Use ActivateInWorldMessage instead")]
void Activate(ActivateEventArgs eventArgs);
}
public sealed class ActivateEventArgs : EventArgs, ITargetedInteractEventArgs
{
2021-12-04 12:35:33 +01:00
public ActivateEventArgs(EntityUid user, EntityUid target)
{
User = user;
Target = target;
}
2021-12-04 12:35:33 +01:00
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>
2021-12-04 12:35:33 +01:00
public EntityUid User { get; }
/// <summary>
/// Entity that was activated in the world.
/// </summary>
2021-12-04 12:35:33 +01:00
public EntityUid Target { get; }
2021-12-04 12:35:33 +01:00
public ActivateInWorldEvent(EntityUid user, EntityUid target)
{
User = user;
Target = target;
}
}
}