Search in sources :

Example 1 with SkillTreeEntry

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!");
        }
    }
}
Also used : SkillTreeEntry(am2.api.SkillTreeEntry) ISkillTreeEntry(am2.api.spell.component.interfaces.ISkillTreeEntry)

Example 2 with SkillTreeEntry

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;
}
Also used : ISkillTreeEntry(am2.api.spell.component.interfaces.ISkillTreeEntry) SkillTreeEntry(am2.api.SkillTreeEntry) ISkillTreeEntry(am2.api.spell.component.interfaces.ISkillTreeEntry)

Example 3 with SkillTreeEntry

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);
}
Also used : InvalidParameterException(java.security.InvalidParameterException) ArrayList(java.util.ArrayList) SkillTreeEntry(am2.api.SkillTreeEntry) ISkillTreeEntry(am2.api.spell.component.interfaces.ISkillTreeEntry)

Example 4 with SkillTreeEntry

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;
}
Also used : ISkillTreeEntry(am2.api.spell.component.interfaces.ISkillTreeEntry) SkillTreeEntry(am2.api.SkillTreeEntry) ISkillTreeEntry(am2.api.spell.component.interfaces.ISkillTreeEntry)

Example 5 with SkillTreeEntry

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;
            }
        }
    }
}
Also used : ISkillTreeEntry(am2.api.spell.component.interfaces.ISkillTreeEntry) SkillTreeEntry(am2.api.SkillTreeEntry) ISkillTreeEntry(am2.api.spell.component.interfaces.ISkillTreeEntry)

Aggregations

SkillTreeEntry (am2.api.SkillTreeEntry)9 ISkillTreeEntry (am2.api.spell.component.interfaces.ISkillTreeEntry)8 LearnStates (am2.api.spell.enums.LearnStates)2 SkillPointTypes (am2.api.spell.enums.SkillPointTypes)2 ArrayList (java.util.ArrayList)2 ISkillData (am2.api.ISkillData)1 SkillData (am2.playerextensions.SkillData)1 InvalidParameterException (java.security.InvalidParameterException)1 IIcon (net.minecraft.util.IIcon)1