Cleanup: Make separate event for the equip/unequip target (#37333)

* Cleanup

* Update
This commit is contained in:
Winkarst
2025-05-12 06:14:32 +03:00
committed by GitHub
parent 92d0ea3128
commit 63b04c4769
3 changed files with 62 additions and 80 deletions

View File

@@ -286,23 +286,21 @@ public abstract partial class InventorySystem
}
var attemptEvent = new IsEquippingAttemptEvent(actor, target, itemUid, slotDefinition);
RaiseLocalEvent(target, attemptEvent, true);
RaiseLocalEvent(actor, attemptEvent, true);
if (attemptEvent.Cancelled)
{
reason = attemptEvent.Reason ?? reason;
return false;
}
if (actor != target)
var targetAttemptEvent = new IsEquippingTargetAttemptEvent(actor, target, itemUid, slotDefinition);
RaiseLocalEvent(target, targetAttemptEvent, true);
if (targetAttemptEvent.Cancelled)
{
//reuse the event. this is gucci, right?
attemptEvent.Reason = null;
RaiseLocalEvent(actor, attemptEvent, true);
if (attemptEvent.Cancelled)
{
reason = attemptEvent.Reason ?? reason;
return false;
}
reason = targetAttemptEvent.Reason ?? reason;
return false;
}
var itemAttemptEvent = new BeingEquippedAttemptEvent(actor, target, itemUid, slotDefinition);
@@ -524,23 +522,21 @@ public abstract partial class InventorySystem
}
var attemptEvent = new IsUnequippingAttemptEvent(actor, target, itemUid, slotDefinition);
RaiseLocalEvent(target, attemptEvent, true);
RaiseLocalEvent(actor, attemptEvent, true);
if (attemptEvent.Cancelled)
{
reason = attemptEvent.Reason ?? reason;
return false;
}
if (actor != target)
var targetAttemptEvent = new IsUnequippingTargetAttemptEvent(actor, target, itemUid, slotDefinition);
RaiseLocalEvent(target, targetAttemptEvent, true);
if (targetAttemptEvent.Cancelled)
{
//reuse the event. this is gucci, right?
attemptEvent.Reason = null;
RaiseLocalEvent(actor, attemptEvent, true);
if (attemptEvent.Cancelled)
{
reason = attemptEvent.Reason ?? reason;
return false;
}
reason = targetAttemptEvent.Reason ?? reason;
return false;
}
var itemAttemptEvent = new BeingUnequippedAttemptEvent(actor, target, itemUid, slotDefinition);