mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-21 04:32:39 +00:00
Removed static class from AbilityController and made animations built into the enum
This commit is contained in:
1 parent
39b6304bed
commit
246baa9f55
3 files changed
+34
-77
No files matched your search
@@ -47,7 +47,6 @@ public class AbilityController implements IAbilityHandler {
|
||||
public AbilityController() {
|
||||
Instance = this;
|
||||
registerBuiltins();
|
||||
new Animations();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -320,67 +319,4 @@ public class AbilityController implements IAbilityHandler {
|
||||
registerType("cnpc:hazard", AbilityHazard::new);
|
||||
registerType("cnpc:trap", AbilityTrap::new);
|
||||
}
|
||||
|
||||
public static class Animations {
|
||||
public HashMap<Integer, Map<AbilityPhase, Animation>> animations;
|
||||
|
||||
public static Animations Instance;
|
||||
|
||||
public Animations() {
|
||||
Instance = this;
|
||||
animations = new HashMap<>();
|
||||
load();
|
||||
}
|
||||
|
||||
public void load() {
|
||||
registerBuiltins();
|
||||
}
|
||||
|
||||
private void registerBuiltins() {
|
||||
animations.clear();
|
||||
|
||||
try {
|
||||
for (AbilityPhase phase : AbilityPhase.values()) {
|
||||
for (AbilityAnimation anim : AbilityAnimation.values()) {
|
||||
File file = anim.get(phase);
|
||||
|
||||
if (file == null) {
|
||||
// LogWriter.info("AnimationController: Ability Animations for " + anim.name() + " not found.");
|
||||
continue;
|
||||
}
|
||||
|
||||
Animation animation = new Animation();
|
||||
animation.readFromNBT(NBTJsonUtil.LoadFile(file));
|
||||
|
||||
animations
|
||||
.computeIfAbsent(anim.ordinal(), k -> new EnumMap<>(AbilityPhase.class))
|
||||
.put(phase, animation);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogWriter.except(e);
|
||||
}
|
||||
}
|
||||
|
||||
public IAnimation get(AbilityAnimation ability, AbilityPhase phase) {
|
||||
return get(ability.ordinal(), phase);
|
||||
}
|
||||
|
||||
public IAnimation get(int id, AbilityPhase phase) {
|
||||
return animations.get(id).get(phase);
|
||||
}
|
||||
|
||||
public boolean has(AbilityAnimation ability, AbilityPhase phase) {
|
||||
return get(ability.ordinal(), phase) != null;
|
||||
}
|
||||
|
||||
public boolean has(int id, AbilityPhase phase) {
|
||||
return get(id, phase) != null;
|
||||
}
|
||||
|
||||
public IAnimation[] getAnimations(AbilityAnimation ability) {
|
||||
ArrayList<IAnimation> animations = new ArrayList<>(this.animations.get(ability.ordinal()).values());
|
||||
return animations.toArray(new IAnimation[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user