mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 07:22:20 +00:00
Create IAbilityEffect + Concurrent Ability Support for Chained Abilities
This commit is contained in:
1 parent
1e45d96253
commit
e54a9a83bb
32 files changed
+1754
-382
No files matched your search
@@ -3,6 +3,7 @@ package kamkeel.npcs.util;
|
||||
import kamkeel.npcs.controllers.AbilityController;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
import kamkeel.npcs.controllers.data.ability.AbilityVariant;
|
||||
import kamkeel.npcs.controllers.data.ability.IEffectAction;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.controllers.AnimationController;
|
||||
import noppes.npcs.controllers.data.Animation;
|
||||
@@ -173,4 +174,37 @@ public class Register<T> {
|
||||
return new Register.Animations(modClass, animationsPath, namespace);
|
||||
}
|
||||
}
|
||||
|
||||
public static class EffectActions extends Register<IEffectAction> {
|
||||
|
||||
private EffectActions(String namespace) {
|
||||
super("effect_action", namespace);
|
||||
}
|
||||
|
||||
public IEffectAction register(String name, IEffectAction action) {
|
||||
String key = namespace + ":" + name.trim().toLowerCase().replaceAll(" ", "_");
|
||||
entries.put(key, () -> action);
|
||||
return action;
|
||||
}
|
||||
|
||||
public void register() {
|
||||
for (Map.Entry<String, Supplier<IEffectAction>> entry : entries.entrySet()) {
|
||||
AbilityController.Instance.registerEffectAction(entry.getValue().get());
|
||||
}
|
||||
}
|
||||
|
||||
public static Register.EffectActions create(String namespace, String displayName) {
|
||||
if (!REGISTERED_NAMESPACES.containsKey("effect_action"))
|
||||
REGISTERED_NAMESPACES.put("effect_action", new ArrayList<>());
|
||||
|
||||
if (REGISTERED_NAMESPACES.get("effect_action").contains(namespace)) {
|
||||
LogWriter.error("REGISTER EFFECT ACTIONS: Namespace " + namespace + " already registered!");
|
||||
}
|
||||
|
||||
REGISTERED_NAMESPACES.get("effect_action").add(namespace);
|
||||
NAMESPACE_DISPLAY_NAMES.put(namespace, displayName);
|
||||
|
||||
return new Register.EffectActions(namespace);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user