use of am2.api.SkillTreeEntry in project ArsMagica2 by Mithion.
the class SkillTreeManager method disableAllSkillsIn.
public void disableAllSkillsIn(int[] disabledSkills) {
// enable all skills
for (SkillTreeEntry entry : offenseTree) entry.enabled = true;
for (SkillTreeEntry entry : defenseTree) entry.enabled = true;
for (SkillTreeEntry entry : utilityTree) entry.enabled = true;
for (SkillTreeEntry entry : talentTree) entry.enabled = true;
// disable all server-disabled skills
for (int i : disabledSkills) {
SkillTreeEntry entry = getSkillTreeEntry(SkillManager.instance.getSkill(i));
if (entry != null) {
entry.enabled = false;
LogHelper.info("Disabling %s as per server configs", SkillManager.instance.getSkillName(entry.registeredItem));
} else {
LogHelper.warn("Could not disable skill ID %d as per server configs!");
}
}
}
use of am2.api.SkillTreeEntry in project ArsMagica2 by Mithion.
the class SkillTreeManager method getSkillTreeEntry.
public SkillTreeEntry getSkillTreeEntry(ISkillTreeEntry part) {
ArrayList<SkillTreeEntry> treeEntries = SkillTreeManager.instance.getTree(SkillTrees.Offense);
for (SkillTreeEntry st_entry : treeEntries) {
ISkillTreeEntry item = st_entry.registeredItem;
if (item != null && item == part) {
return st_entry;
}
}
treeEntries = SkillTreeManager.instance.getTree(SkillTrees.Defense);
for (SkillTreeEntry st_entry : treeEntries) {
ISkillTreeEntry item = st_entry.registeredItem;
if (item != null && item == part) {
return st_entry;
}
}
treeEntries = SkillTreeManager.instance.getTree(SkillTrees.Utility);
for (SkillTreeEntry st_entry : treeEntries) {
ISkillTreeEntry item = st_entry.registeredItem;
if (item != null && item == part) {
return st_entry;
}
}
treeEntries = SkillTreeManager.instance.getTree(SkillTrees.Talents);
for (SkillTreeEntry st_entry : treeEntries) {
ISkillTreeEntry item = st_entry.registeredItem;
if (item != null && item == part) {
return st_entry;
}
}
return null;
}
use of am2.api.SkillTreeEntry in project ArsMagica2 by Mithion.
the class SkillTreeManager method RegisterPart.
@Override
public void RegisterPart(ISkillTreeEntry item, int x, int y, SkillTrees tree, SkillPointTypes requiredPoint, ISkillTreeEntry... prerequisites) {
// get appropriate skill tree
ArrayList<SkillTreeEntry> treeListing = tree == SkillTrees.Defense ? defenseTree : tree == SkillTrees.Offense ? offenseTree : tree == SkillTrees.Utility ? utilityTree : talentTree;
// check for prereq
ArrayList<SkillTreeEntry> locatedPrerequisites = new ArrayList<SkillTreeEntry>();
if (prerequisites != null && prerequisites.length > 0) {
for (Object prerequisite : prerequisites) {
for (SkillTreeEntry entry : treeListing) {
if (entry.registeredItem == prerequisite) {
locatedPrerequisites.add(entry);
break;
}
}
}
if (locatedPrerequisites.size() == 0)
throw new InvalidParameterException(String.format("Unable to locate one or more prerequisite items in the specified tree (%s).", tree.toString()));
}
boolean enabled = true;
if (item == null) {
item = SkillManager.instance.missingComponent;
} else {
enabled = AMCore.skillConfig.isSkillEnabled(SkillManager.instance.getSkillName(item));
}
SkillTreeEntry newEntry = new SkillTreeEntry(x, y, tree, locatedPrerequisites.toArray(new SkillTreeEntry[locatedPrerequisites.size()]), item, enabled);
treeListing.add(newEntry);
skillPointTypeList.put(SkillManager.instance.getShiftedPartID(item), requiredPoint);
}
use of am2.api.SkillTreeEntry in project ArsMagica2 by Mithion.
the class GuiCompendiumIndex method checkSCMLimit.
private boolean checkSCMLimit(CompendiumEntry entry) {
if (entry instanceof CompendiumEntrySpellComponent || entry instanceof CompendiumEntrySpellModifier || entry instanceof CompendiumEntrySpellShape) {
ISkillTreeEntry part = SkillManager.instance.getSkill(entry.getID());
if (part == null)
return false;
SkillTreeEntry ste = SkillTreeManager.instance.getSkillTreeEntry(part);
if (ste == null)
return false;
return sk.isEntryKnown(ste) || sk.getLearnState(ste, Minecraft.getMinecraft().thePlayer) == LearnStates.CAN_LEARN;
}
return true;
}
use of am2.api.SkillTreeEntry in project ArsMagica2 by Mithion.
the class SkillData method setShapeKnown.
private void setShapeKnown(int shapeID) {
if (!isShapeKnown(shapeID)) {
shapesKnown.add(shapeID);
if (primaryTree == SkillTrees.None) {
ISkillTreeEntry part = SkillManager.instance.getSkill(shapeID);
SkillTreeEntry ste = SkillTreeManager.instance.getSkillTreeEntry(part);
if (ste != null && ste.tree != SkillTrees.Talents && ste.tree != SkillTrees.None) {
primaryTree = ste.tree;
}
}
}
}
Aggregations