Adds click attacks

This commit is contained in:
Víctor Aguilera Puerto
2020-08-31 18:55:42 +02:00
parent 9d5278ab0d
commit 69bd44c94c
7 changed files with 167 additions and 66 deletions

View File

@@ -9,9 +9,9 @@ namespace Content.Shared.GameObjects.EntitySystemMessages
public static class MeleeWeaponSystemMessages
{
[Serializable, NetSerializable]
public sealed class PlayMeleeWeaponAnimationMessage : EntitySystemMessage
public sealed class PlayMeleeWeaponArcAnimationMessage : EntitySystemMessage
{
public PlayMeleeWeaponAnimationMessage(string arcPrototype, Angle angle, EntityUid attacker, List<EntityUid> hits)
public PlayMeleeWeaponArcAnimationMessage(string arcPrototype, Angle angle, EntityUid attacker, List<EntityUid> hits)
{
ArcPrototype = arcPrototype;
Angle = angle;
@@ -24,5 +24,19 @@ namespace Content.Shared.GameObjects.EntitySystemMessages
public EntityUid Attacker { get; }
public List<EntityUid> Hits { get; }
}
[Serializable, NetSerializable]
public sealed class PlayMeleeWeaponAnimationMessage : EntitySystemMessage
{
public PlayMeleeWeaponAnimationMessage(Angle angle, EntityUid attacker, EntityUid hit)
{
Attacker = attacker;
Hit = hit;
}
public Angle Angle { get; }
public EntityUid Attacker { get; }
public EntityUid Hit { get; }
}
}
}

View File

@@ -1,5 +1,9 @@
using System;
#nullable enable
using System;
using Content.Shared.GameObjects.Components.Research;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
namespace Content.Shared.Interfaces.GameObjects.Components
@@ -9,18 +13,25 @@ namespace Content.Shared.Interfaces.GameObjects.Components
/// </summary>
public interface IAttack
{
void Attack(AttackEventArgs eventArgs);
// Redirects to ClickAttack by default.
bool WideAttack(AttackEventArgs eventArgs) => ClickAttack(eventArgs);
bool ClickAttack(AttackEventArgs eventArgs);
}
public class AttackEventArgs : EventArgs
{
public AttackEventArgs(IEntity user, GridCoordinates clickLocation)
public AttackEventArgs(IEntity user, GridCoordinates clickLocation, bool wideAttack, EntityUid target = default)
{
User = user;
ClickLocation = clickLocation;
WideAttack = wideAttack;
Target = target;
}
public IEntity User { get; }
public GridCoordinates ClickLocation { get; }
public bool WideAttack { get; }
public EntityUid Target { get; }
public IEntity? TargetEntity => IoCManager.Resolve<IEntityManager>()?.GetEntity(Target) ?? null;
}
}