Refactor MeleeWeaponComponent and related comps to be ECS (#4133)
* move everything to MeleeWeaponSystem * refactor MeleeChemicalInjector * hypospray and flash refactor * stunbaton refactor * bugfixes * flash afterinteract * resolve issues * props * playing the slots * MeleeInteractEvent + bugfixes * spear can actually use MeleeChemicalInjector
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Shared.Interfaces.GameObjects.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Raised directed on the used entity when a target entity is click attacked by a user.
|
||||
/// </summary>
|
||||
public class ClickAttackEvent : EntityEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Entity used to attack, for broadcast purposes.
|
||||
/// </summary>
|
||||
public IEntity Used { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Entity that triggered the attack.
|
||||
/// </summary>
|
||||
public IEntity User { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The original location that was clicked by the user.
|
||||
/// </summary>
|
||||
public EntityCoordinates ClickLocation { get; }
|
||||
|
||||
/// <summary>
|
||||
/// UID of the entity that was attacked.
|
||||
/// </summary>
|
||||
public EntityUid Target { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Entity that was attacked.
|
||||
/// </summary>
|
||||
public IEntity? TargetEntity { get; }
|
||||
|
||||
public ClickAttackEvent(IEntity used, IEntity user, EntityCoordinates clickLocation, EntityUid target = default)
|
||||
{
|
||||
Used = used;
|
||||
User = user;
|
||||
ClickLocation = clickLocation;
|
||||
Target = target;
|
||||
|
||||
IoCManager.Resolve<IEntityManager>().TryGetEntity(Target, out var targetEntity);
|
||||
TargetEntity = targetEntity;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised directed on the used entity when a target entity is wide attacked by a user.
|
||||
/// </summary>
|
||||
public class WideAttackEvent : EntityEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Entity used to attack, for broadcast purposes.
|
||||
/// </summary>
|
||||
public IEntity Used { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Entity that triggered the attack.
|
||||
/// </summary>
|
||||
public IEntity User { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The original location that was clicked by the user.
|
||||
/// </summary>
|
||||
public EntityCoordinates ClickLocation { get; }
|
||||
|
||||
public WideAttackEvent(IEntity used, IEntity user, EntityCoordinates clickLocation)
|
||||
{
|
||||
Used = used;
|
||||
User = user;
|
||||
ClickLocation = clickLocation;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
#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
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface gives components behavior when being used to "attack".
|
||||
/// </summary>
|
||||
[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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised when a target entity is attacked by a user.
|
||||
/// </summary>
|
||||
public class AttackEvent : EntityEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Entity that triggered the attack.
|
||||
/// </summary>
|
||||
public IEntity User { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The original location that was clicked by the user.
|
||||
/// </summary>
|
||||
public EntityCoordinates ClickLocation { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the attack creates a swing attack or attacks the target entity directly.
|
||||
/// </summary>
|
||||
public bool WideAttack { get; }
|
||||
|
||||
/// <summary>
|
||||
/// UID of the entity that was attacked.
|
||||
/// </summary>
|
||||
public EntityUid Target { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Entity that was attacked.
|
||||
/// </summary>
|
||||
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<IEntityManager>().TryGetEntity(Target, out var targetEntity);
|
||||
TargetEntity = targetEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user