Search in sources :

Example 6 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 7 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 8 with SkillTreeEntry

use of am2.api.SkillTreeEntry in project ArsMagica2 by Mithion.

the class GuiSkillTrees method drawSkillTree.

private void drawSkillTree() {
    int l = (width - xSize) / 2;
    int i1 = (height - ySize) / 2 + GuiButtonSkillTreeTab.buttonHeight;
    SkillData sk = SkillData.For(Minecraft.getMinecraft().thePlayer);
    for (SkillTreeEntry entry : skillTree) {
        if (entry.prerequisites == null || entry.prerequisites.length == 0)
            continue;
        for (SkillTreeEntry prerequisite : entry.prerequisites) {
            int color = 0;
            if (sk.isEntryKnown(prerequisite) || sk.getLearnState(prerequisite, Minecraft.getMinecraft().thePlayer) == LearnStates.DISABLED) {
                color = 0x006600;
            } else {
                continue;
            }
            line2d(l + entry.x - offsetX * 2 + 16, i1 + entry.y - offsetY * 2 + 16, l + entry.x - offsetX * 2 + 16, i1 + prerequisite.y - offsetY * 2 + 16, color);
            line2d(l + entry.x - offsetX * 2 + 16, i1 + prerequisite.y - offsetY * 2 + 16, l + prerequisite.x - offsetX * 2 + 16, i1 + prerequisite.y - offsetY * 2 + 16, color);
        }
    }
    for (SkillTreeEntry entry : skillTree) {
        if (entry.prerequisites == null || entry.prerequisites.length == 0)
            continue;
        for (SkillTreeEntry prerequisite : entry.prerequisites) {
            int color = 0;
            LearnStates state = sk.getLearnState(entry, Minecraft.getMinecraft().thePlayer);
            if ((sk.isEntryKnown(prerequisite) && (state == LearnStates.CAN_LEARN || state == LearnStates.LEARNED)) || sk.getLearnState(prerequisite, Minecraft.getMinecraft().thePlayer) == LearnStates.DISABLED) {
                continue;
            } else {
                color = 0x220000;
            }
            line2d(l + entry.x - offsetX * 2 + 16, i1 + entry.y - offsetY * 2 + 16, l + entry.x - offsetX * 2 + 16, i1 + prerequisite.y - offsetY * 2 + 16, color);
            line2d(l + entry.x - offsetX * 2 + 16, i1 + prerequisite.y - offsetY * 2 + 16, l + prerequisite.x - offsetX * 2 + 16, i1 + prerequisite.y - offsetY * 2 + 16, color);
        }
    }
    SkillTreeEntry hovered = null;
    for (SkillTreeEntry entry : skillTree) {
        if (entry.registeredItem == null)
            continue;
        String name = SkillManager.instance.getSkillName(entry.registeredItem);
        if (name == null)
            name = "";
        IIcon IIcon = SpellIconManager.instance.getIcon(name);
        LearnStates state = sk.getLearnState(entry, Minecraft.getMinecraft().thePlayer);
        if (state == LearnStates.LEARNED) {
            GL11.glColor3f(1.0f, 1.0f, 1.0f);
        } else if (state == LearnStates.CAN_LEARN) {
            float min = 0.2f;
            float delta = 0.45f * (1f - (Math.abs(AMGuiHelper.instance.getFastTicker() - 20f) / 20f));
            float colorShift = 0.25f;
            SkillPointTypes type = SkillTreeManager.instance.getSkillPointTypeForPart(entry.registeredItem);
            if (type == SkillPointTypes.SILVER) {
                GL11.glColor3f(min + delta + colorShift, min + delta + colorShift, min + delta + colorShift);
            } else {
                GL11.glColor3f(min + delta + ((type == SkillPointTypes.RED) ? colorShift : 0f), min + delta + ((type == SkillPointTypes.GREEN) ? colorShift : 0f), min + delta + ((type == SkillPointTypes.BLUE) ? colorShift : 0f));
            }
        } else {
            GL11.glColor3f(0.1f, 0.1f, 0.1f);
        }
        DrawConstrainedIconAtXY(IIcon, l + entry.x - offsetX * 2, i1 + entry.y - offsetY * 2, IIcondims, IIcondims, false);
        if (state == LearnStates.LOCKED) {
            GL11.glColor4f(0.3f, 0.3f, 0.3f, 0.8f);
            DrawConstrainedIconAtXY(AMGuiIcons.padlock, l + entry.x - offsetX * 2 + 8.5f, i1 + entry.y - offsetY * 2 + 8, 15, 15, true);
        } else if (state == LearnStates.DISABLED) {
            GL11.glColor4f(1.0f, 0.3f, 0.3f, 0.8f);
            DrawConstrainedIconAtXY(AMGuiIcons.padlock, l + entry.x - offsetX * 2 + 8.5f, i1 + entry.y - offsetY * 2 + 8, 15, 15, true);
        }
        GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
        if (lastMouseX > l && lastMouseX < l + xSize && lastMouseY > i1 && lastMouseY < i1 + ySize) {
            if (lastMouseX > l + entry.x - offsetX * 2 && lastMouseX < l + entry.x - offsetX * 2 + IIcondims) {
                if (lastMouseY > i1 + entry.y - offsetY * 2 && lastMouseY < i1 + entry.y - offsetY * 2 + IIcondims) {
                    hovered = entry;
                }
            }
        }
    }
    hoveredItem = hovered;
}
Also used : SkillData(am2.playerextensions.SkillData) LearnStates(am2.api.spell.enums.LearnStates) IIcon(net.minecraft.util.IIcon) SkillTreeEntry(am2.api.SkillTreeEntry) SkillPointTypes(am2.api.spell.enums.SkillPointTypes)

Example 9 with SkillTreeEntry

use of am2.api.SkillTreeEntry in project ArsMagica2 by Mithion.

the class SkillTreeManager method getDisabledSkillIDs.

public int[] getDisabledSkillIDs() {
    ArrayList<Integer> disableds = new ArrayList<Integer>();
    for (SkillTreeEntry entry : offenseTree) if (!entry.enabled)
        disableds.add(SkillManager.instance.getShiftedPartID(entry.registeredItem));
    for (SkillTreeEntry entry : defenseTree) if (!entry.enabled)
        disableds.add(SkillManager.instance.getShiftedPartID(entry.registeredItem));
    for (SkillTreeEntry entry : utilityTree) if (!entry.enabled)
        disableds.add(SkillManager.instance.getShiftedPartID(entry.registeredItem));
    for (SkillTreeEntry entry : talentTree) if (!entry.enabled)
        disableds.add(SkillManager.instance.getShiftedPartID(entry.registeredItem));
    int[] toReturn = new int[disableds.size()];
    for (int i = 0; i < disableds.size(); ++i) toReturn[i] = disableds.get(i);
    return toReturn;
}
Also used : ArrayList(java.util.ArrayList) SkillTreeEntry(am2.api.SkillTreeEntry) ISkillTreeEntry(am2.api.spell.component.interfaces.ISkillTreeEntry)

Example 10 with SkillTreeEntry

use of am2.api.SkillTreeEntry in project ArsMagica2 by Mithion.

the class SkillData method getLearnState.

@Override
public LearnStates getLearnState(SkillTreeEntry entry, EntityPlayer player) {
    SkillData sk = SkillData.For(player);
    if (sk.isEntryKnown(entry)) {
        return LearnStates.LEARNED;
    }
    SkillPointTypes pointType = SkillTreeManager.instance.getSkillPointTypeForPart(entry.registeredItem);
    LearnStates state = entry.enabled ? (sk.getSpellPoints(pointType) > 0 ? LearnStates.CAN_LEARN : LearnStates.CANNOT_LEARN) : LearnStates.DISABLED;
    if (state == LearnStates.CAN_LEARN) {
        if (!RecursivePrerequisiteCheck(sk, entry)) {
            state = LearnStates.CANNOT_LEARN;
        }
    }
    if (sk.getPrimaryTree() != SkillTrees.None && entry.tree != SkillTrees.Talents && sk.getPrimaryTree() != entry.tree && entry.tier >= AMCore.config.getSkillTreeSecondaryTierCap()) {
        state = LearnStates.LOCKED;
    }
    return state;
}
Also used : ISkillData(am2.api.ISkillData) LearnStates(am2.api.spell.enums.LearnStates) SkillPointTypes(am2.api.spell.enums.SkillPointTypes)

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