Add user to AttemptMeleeEvent, add ThrowItemAttemptEvent (#30193)

* Add user to AttemptMeleeEvent, add ThrowItemAttemptEvent

* Add xmldoc
This commit is contained in:
DrSmugleaf
2024-07-20 01:06:52 -07:00
committed by GitHub
parent 1208928564
commit 297baaca23
3 changed files with 16 additions and 2 deletions

View File

@@ -120,7 +120,13 @@ namespace Content.Shared.ActionBlocker
var ev = new ThrowAttemptEvent(user, itemUid); var ev = new ThrowAttemptEvent(user, itemUid);
RaiseLocalEvent(user, ev); RaiseLocalEvent(user, ev);
return !ev.Cancelled; if (ev.Cancelled)
return false;
var itemEv = new ThrowItemAttemptEvent(user);
RaiseLocalEvent(itemUid, ref itemEv);
return !itemEv.Cancelled;
} }
public bool CanSpeak(EntityUid uid) public bool CanSpeak(EntityUid uid)

View File

@@ -13,6 +13,14 @@
public EntityUid ItemUid { get; } public EntityUid ItemUid { get; }
} }
/// <summary>
/// Raised on the item entity that is thrown.
/// </summary>
/// <param name="User">The user that threw this entity.</param>
/// <param name="Cancelled">Whether or not the throw should be cancelled.</param>
[ByRefEvent]
public record struct ThrowItemAttemptEvent(EntityUid User, bool Cancelled = false);
/// <summary> /// <summary>
/// Raised when we try to pushback an entity from throwing /// Raised when we try to pushback an entity from throwing
/// </summary> /// </summary>

View File

@@ -4,4 +4,4 @@ namespace Content.Shared.Weapons.Melee.Events;
/// Raised directed on a weapon when attempt a melee attack. /// Raised directed on a weapon when attempt a melee attack.
/// </summary> /// </summary>
[ByRefEvent] [ByRefEvent]
public record struct AttemptMeleeEvent(bool Cancelled, string? Message); public record struct AttemptMeleeEvent(EntityUid User, bool Cancelled = false, string? Message = null);