Fire MeleeHitEvent on misses. (#12867)

* Fire MeleeHitEvent when there are no targets.

* Prevent certain weapons from activating if they had no hit entities on hit.

* Prevent miss events from firing when target is yourself or was deleted.

* Use .Value as Target is already known not to be null.

* uid changes

---------

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Vordenburg
2023-02-13 07:55:39 -05:00
committed by GitHub
parent 650ade0d4e
commit 4183b5f449
8 changed files with 95 additions and 82 deletions

View File

@@ -12,7 +12,7 @@ public sealed class MeleeHitEvent : HandledEntityEventArgs
/// <summary>
/// The base amount of damage dealt by the melee hit.
/// </summary>
public readonly DamageSpecifier BaseDamage = new();
public readonly DamageSpecifier BaseDamage;
/// <summary>
/// Modifier sets to apply to the hit event when it's all said and done.
@@ -31,18 +31,18 @@ public sealed class MeleeHitEvent : HandledEntityEventArgs
/// <summary>
/// A list containing every hit entity. Can be zero.
/// </summary>
public IEnumerable<EntityUid> HitEntities { get; }
public IReadOnlyList<EntityUid> HitEntities;
/// <summary>
/// Used to define a new hit sound in case you want to override the default GenericHit.
/// Also gets a pitch modifier added to it.
/// </summary>
public SoundSpecifier? HitSoundOverride {get; set;}
public SoundSpecifier? HitSoundOverride;
/// <summary>
/// The user who attacked with the melee weapon.
/// </summary>
public EntityUid User { get; }
public readonly EntityUid User;
/// <summary>
/// Check if this is true before attempting to do something during a melee attack other than changing/adding bonus damage. <br/>
@@ -59,4 +59,4 @@ public sealed class MeleeHitEvent : HandledEntityEventArgs
User = user;
BaseDamage = baseDamage;
}
}
}