Melee refactor (#10897)

Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
This commit is contained in:
metalgearsloth
2022-09-29 15:51:59 +10:00
committed by GitHub
parent c583b7b361
commit f51248ecaa
140 changed files with 2440 additions and 1824 deletions

View File

@@ -0,0 +1,47 @@
using Robust.Shared.Map;
using Robust.Shared.Serialization;
namespace Content.Shared.Weapons.Melee.Events
{
[Serializable, NetSerializable]
public abstract class AttackEvent : EntityEventArgs
{
/// <summary>
/// Coordinates being attacked.
/// </summary>
public readonly EntityCoordinates Coordinates;
protected AttackEvent(EntityCoordinates coordinates)
{
Coordinates = coordinates;
}
}
/// <summary>
/// Event raised on entities that have been attacked.
/// </summary>
public sealed class AttackedEvent : EntityEventArgs
{
/// <summary>
/// Entity used to attack, for broadcast purposes.
/// </summary>
public EntityUid Used { get; }
/// <summary>
/// Entity that triggered the attack.
/// </summary>
public EntityUid User { get; }
/// <summary>
/// The original location that was clicked by the user.
/// </summary>
public EntityCoordinates ClickLocation { get; }
public AttackedEvent(EntityUid used, EntityUid user, EntityCoordinates clickLocation)
{
Used = used;
User = user;
ClickLocation = clickLocation;
}
}
}

View File

@@ -0,0 +1,15 @@
using Robust.Shared.Map;
using Robust.Shared.Serialization;
namespace Content.Shared.Weapons.Melee.Events;
[Serializable, NetSerializable]
public sealed class DisarmAttackEvent : AttackEvent
{
public EntityUid? Target;
public DisarmAttackEvent(EntityUid? target, EntityCoordinates coordinates) : base(coordinates)
{
Target = target;
}
}

View File

@@ -0,0 +1,18 @@
using Robust.Shared.Map;
using Robust.Shared.Serialization;
namespace Content.Shared.Weapons.Melee.Events;
/// <summary>
/// Raised on the client when it attempts a heavy attack.
/// </summary>
[Serializable, NetSerializable]
public sealed class HeavyAttackEvent : AttackEvent
{
public readonly EntityUid Weapon;
public HeavyAttackEvent(EntityUid weapon, EntityCoordinates coordinates) : base(coordinates)
{
Weapon = weapon;
}
}

View File

@@ -0,0 +1,20 @@
using Robust.Shared.Map;
using Robust.Shared.Serialization;
namespace Content.Shared.Weapons.Melee.Events;
/// <summary>
/// Raised when a light attack is made.
/// </summary>
[Serializable, NetSerializable]
public sealed class LightAttackEvent : AttackEvent
{
public readonly EntityUid? Target;
public readonly EntityUid Weapon;
public LightAttackEvent(EntityUid? target, EntityUid weapon, EntityCoordinates coordinates) : base(coordinates)
{
Target = target;
Weapon = weapon;
}
}

View File

@@ -0,0 +1,35 @@
using Robust.Shared.Serialization;
namespace Content.Shared.Weapons.Melee.Events;
/// <summary>
/// Data for melee lunges from attacks.
/// </summary>
[Serializable, NetSerializable]
public sealed class MeleeLungeEvent : EntityEventArgs
{
public EntityUid Entity;
/// <summary>
/// Width of the attack angle.
/// </summary>
public Angle Angle;
/// <summary>
/// The relative local position to the <see cref="Entity"/>
/// </summary>
public Vector2 LocalPos;
/// <summary>
/// Entity to spawn for the animation
/// </summary>
public string? Animation;
public MeleeLungeEvent(EntityUid uid, Angle angle, Vector2 localPos, string? animation)
{
Entity = uid;
Angle = angle;
LocalPos = localPos;
Animation = animation;
}
}

View File

@@ -0,0 +1,14 @@
using Robust.Shared.Serialization;
namespace Content.Shared.Weapons.Melee.Events;
[Serializable, NetSerializable]
public sealed class StartHeavyAttackEvent : EntityEventArgs
{
public readonly EntityUid Weapon;
public StartHeavyAttackEvent(EntityUid weapon)
{
Weapon = weapon;
}
}

View File

@@ -0,0 +1,14 @@
using Robust.Shared.Serialization;
namespace Content.Shared.Weapons.Melee.Events;
[Serializable, NetSerializable]
public sealed class StopAttackEvent : EntityEventArgs
{
public readonly EntityUid Weapon;
public StopAttackEvent(EntityUid weapon)
{
Weapon = weapon;
}
}

View File

@@ -0,0 +1,17 @@
using Robust.Shared.Serialization;
namespace Content.Shared.Weapons.Melee.Events;
/// <summary>
/// Raised by the client if it pre-emptively stops a heavy attack.
/// </summary>
[Serializable, NetSerializable]
public sealed class StopHeavyAttackEvent : EntityEventArgs
{
public readonly EntityUid Weapon;
public StopHeavyAttackEvent(EntityUid weapon)
{
Weapon = weapon;
}
}