2020-08-31 18:55:42 +02:00
|
|
|
|
#nullable enable
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using Robust.Shared.GameObjects;
|
2020-07-06 14:27:03 -07:00
|
|
|
|
using Robust.Shared.Interfaces.GameObjects;
|
2020-08-31 18:55:42 +02:00
|
|
|
|
using Robust.Shared.IoC;
|
2020-07-06 14:27:03 -07:00
|
|
|
|
using Robust.Shared.Map;
|
|
|
|
|
|
|
2020-07-18 22:51:56 -07:00
|
|
|
|
namespace Content.Shared.Interfaces.GameObjects.Components
|
2020-07-06 14:27:03 -07:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// This interface gives components behavior when being used to "attack".
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public interface IAttack
|
|
|
|
|
|
{
|
2020-08-31 18:55:42 +02:00
|
|
|
|
// Redirects to ClickAttack by default.
|
|
|
|
|
|
bool WideAttack(AttackEventArgs eventArgs) => ClickAttack(eventArgs);
|
|
|
|
|
|
bool ClickAttack(AttackEventArgs eventArgs);
|
2020-07-06 14:27:03 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class AttackEventArgs : EventArgs
|
|
|
|
|
|
{
|
2020-09-06 16:11:53 +02:00
|
|
|
|
public AttackEventArgs(IEntity user, EntityCoordinates clickLocation, bool wideAttack, EntityUid target = default)
|
2020-07-06 14:27:03 -07:00
|
|
|
|
{
|
|
|
|
|
|
User = user;
|
|
|
|
|
|
ClickLocation = clickLocation;
|
2020-08-31 18:55:42 +02:00
|
|
|
|
WideAttack = wideAttack;
|
|
|
|
|
|
Target = target;
|
2020-09-02 15:22:26 +02:00
|
|
|
|
|
2020-09-06 16:11:53 +02:00
|
|
|
|
IoCManager.Resolve<IEntityManager>().TryGetEntity(Target, out var targetEntity);
|
2020-09-02 15:22:26 +02:00
|
|
|
|
TargetEntity = targetEntity;
|
2020-07-06 14:27:03 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public IEntity User { get; }
|
2020-09-06 16:11:53 +02:00
|
|
|
|
public EntityCoordinates ClickLocation { get; }
|
2020-08-31 18:55:42 +02:00
|
|
|
|
public bool WideAttack { get; }
|
|
|
|
|
|
public EntityUid Target { get; }
|
2020-09-02 15:22:26 +02:00
|
|
|
|
public IEntity? TargetEntity { get; }
|
2020-07-06 14:27:03 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|