Melee refactor (#10897)
Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
This commit is contained in:
47
Content.Shared/Weapons/Melee/Events/AttackEvent.cs
Normal file
47
Content.Shared/Weapons/Melee/Events/AttackEvent.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
15
Content.Shared/Weapons/Melee/Events/DisarmAttackEvent.cs
Normal file
15
Content.Shared/Weapons/Melee/Events/DisarmAttackEvent.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
18
Content.Shared/Weapons/Melee/Events/HeavyAttackEvent.cs
Normal file
18
Content.Shared/Weapons/Melee/Events/HeavyAttackEvent.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
20
Content.Shared/Weapons/Melee/Events/LightAttackEvent.cs
Normal file
20
Content.Shared/Weapons/Melee/Events/LightAttackEvent.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
35
Content.Shared/Weapons/Melee/Events/MeleeLungeEvent.cs
Normal file
35
Content.Shared/Weapons/Melee/Events/MeleeLungeEvent.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
14
Content.Shared/Weapons/Melee/Events/StartHeavyAttackEvent.cs
Normal file
14
Content.Shared/Weapons/Melee/Events/StartHeavyAttackEvent.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
14
Content.Shared/Weapons/Melee/Events/StopAttackEvent.cs
Normal file
14
Content.Shared/Weapons/Melee/Events/StopAttackEvent.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
17
Content.Shared/Weapons/Melee/Events/StopHeavyAttackEvent.cs
Normal file
17
Content.Shared/Weapons/Melee/Events/StopHeavyAttackEvent.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user