Search in sources :

Example 1 with SkillPointTypes

use of am2.api.spell.enums.SkillPointTypes in project ArsMagica2 by Mithion.

the class SkillData method learn.

public void learn(int id, int type) {
    if (entity.worldObj.isRemote) {
        AMDataWriter writer = new AMDataWriter();
        writer.add(SPELL_LEARNED);
        writer.add(this.entity.getEntityId());
        writer.add(id);
        writer.add(type);
        AMNetHandler.INSTANCE.sendPacketToServer(AMPacketIDs.SYNC_SPELL_KNOWLEDGE, writer.generate());
        MinecraftForge.EVENT_BUS.post(new SkillLearnedEvent(player, SkillManager.instance.getSkill(id)));
    } else {
        SkillPointTypes skillType = SkillTreeManager.instance.getSkillPointTypeForPart(id);
        boolean learned = false;
        switch(type) {
            case 0:
                if (!isShapeKnown(id) && getSpellPoints(skillType) > 0) {
                    setShapeKnown(id);
                    decrementSpellPoints(skillType);
                    learned = true;
                }
                updateFlags |= KNOWN_SHAPE_UPDATE;
                break;
            case 1:
                if (!isComponentKnown(id) && getSpellPoints(skillType) > 0) {
                    setComponentKnown(id);
                    decrementSpellPoints(skillType);
                    learned = true;
                }
                updateFlags |= KNOWN_COMPONENT_UPDATE;
                break;
            case 2:
                if (!isModifierKnown(id) && getSpellPoints(skillType) > 0) {
                    setModifierKnown(id);
                    decrementSpellPoints(skillType);
                    learned = true;
                }
                updateFlags |= KNOWN_MODIFIER_UPDATE;
                break;
            case 3:
                if (!isTalentKnown(id) && getSpellPoints(skillType) > 0) {
                    setTalentKnown(id);
                    decrementSpellPoints(skillType);
                    learned = true;
                }
                updateFlags |= KNOWN_TALENTS_UPDATE;
                break;
        }
        if (entity instanceof EntityPlayerMP && learned && skillType == SkillPointTypes.SILVER) {
            AMNetHandler.INSTANCE.sendSilverSkillPointPacket((EntityPlayerMP) entity);
        }
    }
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) SkillLearnedEvent(am2.api.events.SkillLearnedEvent) AMDataWriter(am2.network.AMDataWriter) SkillPointTypes(am2.api.spell.enums.SkillPointTypes)

Example 2 with SkillPointTypes

use of am2.api.spell.enums.SkillPointTypes 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 3 with SkillPointTypes

use of am2.api.spell.enums.SkillPointTypes 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 4 with SkillPointTypes

use of am2.api.spell.enums.SkillPointTypes in project ArsMagica2 by Mithion.

the class GuiSkillTrees method drawScreen.

@Override
public void drawScreen(int par1, int par2, float par3) {
    SkillData sk = SkillData.For(Minecraft.getMinecraft().thePlayer);
    int l = (width - xSize) / 2;
    int i1 = (height - ySize) / 2;
    if (AMCore.config.getSkillTreeSecondaryTierCap() < SkillTreeManager.instance.getHighestTier() && (sk.getPrimaryTree() == null || sk.getPrimaryTree() == SkillTrees.None) && sk.getSpellPoints(SkillPointTypes.BLUE) > 0) {
        String s = StatCollector.translateToLocal("am2.gui.lockWarning");
        fontRendererObj.drawSplitString(s, l - 120, i1 + 20, 110, 0xbf6325);
    }
    if (isDragging) {
        int dx = lastMouseX - par1;
        int dy = lastMouseY - par2;
        this.offsetX += dx;
        this.offsetY += dy;
        if (this.offsetX < 0)
            this.offsetX = 0;
        if (this.offsetX > 180)
            this.offsetX = 180;
        if (this.offsetY < 0)
            this.offsetY = 0;
        if (this.offsetY > 180)
            this.offsetY = 180;
    }
    lastMouseX = par1;
    lastMouseY = par2;
    GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
    if (activeTree == SkillTrees.Offense)
        Minecraft.getMinecraft().renderEngine.bindTexture(rl_offense);
    else if (activeTree == SkillTrees.Defense)
        Minecraft.getMinecraft().renderEngine.bindTexture(rl_defense);
    else if (activeTree == SkillTrees.Utility)
        Minecraft.getMinecraft().renderEngine.bindTexture(rl_utility);
    else if (activeTree == SkillTrees.Talents || activeTree == SkillTrees.Affinity)
        Minecraft.getMinecraft().renderEngine.bindTexture(rl_talents);
    else
        return;
    drawTexturedModalRect_Classic(l + 5, i1 + GuiButtonSkillTreeTab.buttonHeight + 5, offsetX, offsetY, 200, 200, 75, 75);
    if (activeTree == SkillTrees.Affinity) {
        drawAffinity();
    } else {
        drawSkillTree();
    }
    GL11.glColor3f(1.0f, 1.0f, 1.0f);
    Minecraft.getMinecraft().renderEngine.bindTexture(rl_background);
    drawTexturedModalRect(l, i1 + GuiButtonSkillTreeTab.buttonHeight, 0, 0, 210, 210);
    drawTexturedModalRect(l + xSize - 29, i1, 210, 0, 37, 37);
    String quantity = String.format("%d", sk.getSpellPoints(SkillPointTypes.BLUE));
    Minecraft.getMinecraft().fontRenderer.drawString(quantity, l + xSize - 24 - (Minecraft.getMinecraft().fontRenderer.getStringWidth(quantity) / 2), i1 + 5, 0x0000FF);
    quantity = String.format("%d", sk.getSpellPoints(SkillPointTypes.GREEN));
    Minecraft.getMinecraft().fontRenderer.drawString(quantity, l + xSize - 12 - (Minecraft.getMinecraft().fontRenderer.getStringWidth(quantity) / 2), i1 + 5, 0x00FF00);
    quantity = String.format("%d", sk.getSpellPoints(SkillPointTypes.RED));
    Minecraft.getMinecraft().fontRenderer.drawString(quantity, l + xSize - 18 - (Minecraft.getMinecraft().fontRenderer.getStringWidth(quantity) / 2), i1 + 15, 0xFF0000);
    super.drawScreen(par1, par2, par3);
    if (hoveredItem != null) {
        ArrayList<String> text = new ArrayList<String>();
        FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
        String s = SkillManager.instance.getDisplayName(hoveredItem.registeredItem);
        LearnStates state = sk.getLearnState(hoveredItem, Minecraft.getMinecraft().thePlayer);
        if (state == LearnStates.LEARNED)
            s += " (" + StatCollector.translateToLocal("am2.gui.known") + ")";
        else if (state == LearnStates.CAN_LEARN)
            s += " (" + StatCollector.translateToLocal("am2.gui.notLearned") + ")";
        else if (state == LearnStates.DISABLED)
            s = StatCollector.translateToLocal("am2.gui.cfgDisabled");
        //else fr = Minecraft.getMinecraft().standardGalacticFontRenderer;
        text.add(s);
        SkillPointTypes type = SkillTreeManager.instance.getSkillPointTypeForPart(hoveredItem.registeredItem);
        if (hoveredItem.registeredItem instanceof ISpellComponent) {
            EnumSet<Affinity> aff = ((ISpellComponent) hoveredItem.registeredItem).getAffinity();
            int affX = lastMouseX + 14;
            int affY = lastMouseY - 34;
            drawGradientAround(affX - 2, affY - 2, 18 * aff.size() + 2, 18);
            for (Affinity a : aff) {
                if (a == Affinity.NONE)
                    continue;
                DrawIconAtXY(a.representItem.getIconFromDamage(a.representMeta), "item", affX, affY, 16, 16, false);
                affX += 18;
            }
        }
        if (!AMCore.config.colourblindMode()) {
            drawHoveringText(text, lastMouseX, lastMouseY, fr, state == LearnStates.LEARNED ? 0xFFFFFF : type == SkillPointTypes.SILVER ? 0x888888 : type == SkillPointTypes.BLUE ? 0x4444FF : type == SkillPointTypes.GREEN ? 0x44FF44 : 0xFF4444);
        } else {
            text.add(StatCollector.translateToLocal("am2.gui." + type.toString().toLowerCase() + "Point"));
            drawHoveringText(text, lastMouseX, lastMouseY, fr, 0xFFFFFF);
        }
    }
    if (hoveredAffinity != null) {
        List list = AffinityData.For(Minecraft.getMinecraft().thePlayer).getColoredAffinityEffects(hoveredAffinity);
        //list.add(0, "\247f" + hoveredAffinity.name());
        drawHoveringText(list, lastMouseX, lastMouseY, fontRendererObj, 0xFFFFFF);
    }
}
Also used : SkillData(am2.playerextensions.SkillData) LearnStates(am2.api.spell.enums.LearnStates) ISpellComponent(am2.api.spell.component.interfaces.ISpellComponent) ArrayList(java.util.ArrayList) Affinity(am2.api.spell.enums.Affinity) ArrayList(java.util.ArrayList) List(java.util.List) FontRenderer(net.minecraft.client.gui.FontRenderer) SkillPointTypes(am2.api.spell.enums.SkillPointTypes)

Example 5 with SkillPointTypes

use of am2.api.spell.enums.SkillPointTypes in project ArsMagica2 by Mithion.

the class SkillData method respec.

public void respec() {
    LogHelper.info("Respeccing %s", player.getCommandSenderName());
    int[] addPoints = new int[4];
    addPoints[0] = this.spellPoints[0];
    addPoints[1] = this.spellPoints[1];
    addPoints[2] = this.spellPoints[2];
    //placeholder for silver points; these are not refunded.
    addPoints[3] = this.spellPoints[3];
    for (Integer i : shapesKnown) {
        SkillPointTypes type = SkillTreeManager.instance.getSkillPointTypeForPart(SkillManager.instance.getSkill(i));
        addPoints[type.ordinal()]++;
    }
    for (Integer i : componentsKnown) {
        SkillPointTypes type = SkillTreeManager.instance.getSkillPointTypeForPart(SkillManager.instance.getSkill(i));
        addPoints[type.ordinal()]++;
    }
    for (Integer i : modifiersKnown) {
        SkillPointTypes type = SkillTreeManager.instance.getSkillPointTypeForPart(SkillManager.instance.getSkill(i));
        addPoints[type.ordinal()]++;
    }
    for (Integer i : talentsKnown) {
        SkillPointTypes type = SkillTreeManager.instance.getSkillPointTypeForPart(SkillManager.instance.getSkill(i));
        addPoints[type.ordinal()]++;
    }
    clearAllKnowledge();
    this.spellPoints[0] = addPoints[0];
    this.spellPoints[1] = addPoints[1];
    this.spellPoints[2] = addPoints[2];
}
Also used : SkillPointTypes(am2.api.spell.enums.SkillPointTypes)

Aggregations

SkillPointTypes (am2.api.spell.enums.SkillPointTypes)5 LearnStates (am2.api.spell.enums.LearnStates)3 SkillTreeEntry (am2.api.SkillTreeEntry)2 SkillData (am2.playerextensions.SkillData)2 ArrayList (java.util.ArrayList)2 ISkillData (am2.api.ISkillData)1 SkillLearnedEvent (am2.api.events.SkillLearnedEvent)1 ISkillTreeEntry (am2.api.spell.component.interfaces.ISkillTreeEntry)1 ISpellComponent (am2.api.spell.component.interfaces.ISpellComponent)1 Affinity (am2.api.spell.enums.Affinity)1 AMDataWriter (am2.network.AMDataWriter)1 InvalidParameterException (java.security.InvalidParameterException)1 List (java.util.List)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 IIcon (net.minecraft.util.IIcon)1