#nullable enable
using System;
using Robust.Shared.Analyzers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
namespace Content.Shared.Interfaces.GameObjects.Components
{
///
/// This interface gives components behavior when being used to "attack".
///
[RequiresExplicitImplementation]
public interface IAttack
{
// Redirects to ClickAttack by default.
[Obsolete("WideAttack")]
bool WideAttack(AttackEvent eventArgs) => ClickAttack(eventArgs);
[Obsolete("Use ClickAttack instead")]
bool ClickAttack(AttackEvent eventArgs);
}
///
/// Raised when a target entity is attacked by a user.
///
public class AttackEvent : EntityEventArgs
{
///
/// Entity that triggered the attack.
///
public IEntity User { get; }
///
/// The original location that was clicked by the user.
///
public EntityCoordinates ClickLocation { get; }
///
/// Indicates whether the attack creates a swing attack or attacks the target entity directly.
///
public bool WideAttack { get; }
///
/// UID of the entity that was attacked.
///
public EntityUid Target { get; }
///
/// Entity that was attacked.
///
public IEntity? TargetEntity { get; }
public AttackEvent(IEntity user, EntityCoordinates clickLocation, bool wideAttack, EntityUid target = default)
{
User = user;
ClickLocation = clickLocation;
WideAttack = wideAttack;
Target = target;
IoCManager.Resolve().TryGetEntity(Target, out var targetEntity);
TargetEntity = targetEntity;
}
}
}