mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 12:15:11 +00:00
Refactor ability handling: replace damage handler with ability extenders for improved lifecycle management and damage routing
This commit is contained in:
1 parent
f8c75dd79b
commit
0f774a68fc
7 files changed
+184
-53
No files matched your search
@@ -171,6 +171,13 @@ public class DataAbilities {
|
||||
// Fire tick event for scripts
|
||||
fireTickEvent(currentAbility, target);
|
||||
|
||||
// Fire extender tick hook (e.g., per-tick resource drain)
|
||||
if (!AbilityController.Instance.fireOnAbilityTick(currentAbility, npc, target,
|
||||
currentAbility.getPhase(), currentAbility.getCurrentTick())) {
|
||||
interruptCurrentAbility(null, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle phase-specific logic
|
||||
switch (currentAbility.getPhase()) {
|
||||
case WINDUP:
|
||||
@@ -342,6 +349,9 @@ public class DataAbilities {
|
||||
// Remove any remaining telegraphs (for abilities that keep telegraph during active)
|
||||
removeTelegraph(currentAbility);
|
||||
|
||||
// Fire extender complete hook
|
||||
AbilityController.Instance.fireOnAbilityComplete(currentAbility, npc, target, false);
|
||||
|
||||
// Call onComplete callback
|
||||
currentAbility.onComplete(npc, target);
|
||||
|
||||
@@ -501,6 +511,11 @@ public class DataAbilities {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Fire extender start hook (e.g., resource cost checks)
|
||||
if (!AbilityController.Instance.fireOnAbilityStart(ability, npc, target)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
currentAbility = ability;
|
||||
lastTarget = target;
|
||||
ability.start(target);
|
||||
@@ -750,6 +765,9 @@ public class DataAbilities {
|
||||
releaseRotationControl();
|
||||
releaseLockedPosition();
|
||||
|
||||
// Fire extender complete hook (interrupted)
|
||||
AbilityController.Instance.fireOnAbilityComplete(currentAbility, npc, lastTarget, true);
|
||||
|
||||
// Fire interrupt event
|
||||
AbilityEvent.InterruptEvent interruptEvent = new AbilityEvent.InterruptEvent(
|
||||
npc.wrappedNPC, currentAbility, lastTarget, source, damage);
|
||||
|
||||
Reference in new issue
Block a user