Enhance ability selection and display: add toggleable ability handling, improve ability name color coding, and update ability selection messaging

This commit is contained in:
Kam committed 2026-02-15 19:21:30 -05:00
1 parent 45d05b9157
commit ce24c0a4ff
7 files changed
+86 -16

No files matched your search

@@ -14,6 +14,9 @@ public class AbilitySlot {
private Ability inlineAbility;
private String referenceId;
/** Per-slot enabled override for reference slots (null = use master's default). */
private Boolean enabledOverride;
private transient Ability cachedAbility;
private transient int cachedVersion = -1;
@@ -67,10 +70,32 @@ public class AbilitySlot {
}
cachedAbility = controller.resolveAbility(referenceId);
// Apply per-slot enabled override so NPC-specific enable/disable persists
if (cachedAbility != null && enabledOverride != null) {
cachedAbility.setEnabled(enabledOverride);
}
cachedVersion = currentVersion;
return cachedAbility;
}
/**
* Set the per-slot enabled override for reference slots.
* For inline slots, delegates directly to the ability.
*/
public void setEnabled(boolean enabled) {
if (!isReference()) {
if (inlineAbility != null) {
inlineAbility.setEnabled(enabled);
}
} else {
this.enabledOverride = enabled;
// Also update the cached ability immediately if present
if (cachedAbility != null) {
cachedAbility.setEnabled(enabled);
}
}
}
/**
* Get the inline ability directly (null for reference slots).
*/
@@ -104,6 +129,9 @@ public class AbilitySlot {
if (isReference()) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("Reference", referenceId);
if (enabledOverride != null) {
nbt.setBoolean("RefEnabled", enabledOverride);
}
return nbt;
}
return inlineAbility != null ? inlineAbility.writeNBT() : new NBTTagCompound();
@@ -113,7 +141,11 @@ public class AbilitySlot {
if (nbt == null) return null;
if (nbt.hasKey("Reference")) {
return reference(nbt.getString("Reference"));
AbilitySlot slot = reference(nbt.getString("Reference"));
if (nbt.hasKey("RefEnabled")) {
slot.enabledOverride = nbt.getBoolean("RefEnabled");
}
return slot;
}
// Inline ability