Refactor ability handling: replace damage handler with ability extenders for improved lifecycle management and damage routing

This commit is contained in:
Kam committed 2026-02-14 21:06:12 -05:00
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();