mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 19: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
@@ -147,6 +147,13 @@ public class PlayerAbilityData implements IPlayerAbilityData {
|
||||
// Tick advances time and possibly changes phase
|
||||
boolean phaseChanged = currentAbility.tick();
|
||||
|
||||
// Fire extender tick hook (e.g., per-tick resource drain)
|
||||
if (!AbilityController.Instance.fireOnAbilityTick(currentAbility, player, currentTarget,
|
||||
currentAbility.getPhase(), currentAbility.getCurrentTick())) {
|
||||
interruptCurrentAbility();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (currentAbility.getPhase()) {
|
||||
case WINDUP:
|
||||
if (phaseChanged && oldPhase == AbilityPhase.BURST_DELAY) {
|
||||
@@ -249,6 +256,9 @@ public class PlayerAbilityData implements IPlayerAbilityData {
|
||||
private void handleAbilityCompletion(EntityPlayer player) {
|
||||
if (currentAbility == null) return;
|
||||
|
||||
// Fire extender complete hook
|
||||
AbilityController.Instance.fireOnAbilityComplete(currentAbility, player, currentTarget, false);
|
||||
|
||||
currentAbility.onComplete(player, currentTarget);
|
||||
|
||||
// Release all locks
|
||||
@@ -318,6 +328,11 @@ public class PlayerAbilityData implements IPlayerAbilityData {
|
||||
// Check conditions (skip target-requiring ones)
|
||||
if (!ability.checkConditionsForPlayer(player)) return false;
|
||||
|
||||
// Fire extender start hook (e.g., resource cost checks)
|
||||
if (!AbilityController.Instance.fireOnAbilityStart(ability, player, null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Start the ability
|
||||
currentAbility = ability;
|
||||
currentAbilityKey = key;
|
||||
@@ -517,6 +532,9 @@ public class PlayerAbilityData implements IPlayerAbilityData {
|
||||
|
||||
public void interruptCurrentAbility() {
|
||||
if (currentAbility != null && currentAbility.isExecuting()) {
|
||||
// Fire extender complete hook (interrupted)
|
||||
AbilityController.Instance.fireOnAbilityComplete(currentAbility, playerData.player, currentTarget, true);
|
||||
|
||||
currentAbility.interrupt();
|
||||
stopAbilityAnimation();
|
||||
releaseRotationControl();
|
||||
|
||||
Reference in new issue
Block a user