Search in sources :

Example 1 with SkillData

use of am2.playerextensions.SkillData in project ArsMagica2 by Mithion.

the class GuiSkillTrees method mouseClicked.

@Override
protected void mouseClicked(int par1, int par2, int par3) {
    super.mouseClicked(par1, par2, par3);
    if (par3 == 0) {
        if (hoveredItem != null) {
            SkillData sk = SkillData.For(Minecraft.getMinecraft().thePlayer);
            if (!sk.isEntryKnown(hoveredItem)) {
                if (sk.getLearnState(hoveredItem, Minecraft.getMinecraft().thePlayer) == LearnStates.CAN_LEARN) {
                    sk.learn(hoveredItem.registeredItem);
                }
            }
        } else {
            if (this.activeTree != SkillTrees.Affinity)
                isDragging = true;
            lastMouseX = par1;
            lastMouseY = par2;
        }
    }
}
Also used : SkillData(am2.playerextensions.SkillData)

Example 2 with SkillData

use of am2.playerextensions.SkillData 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 3 with SkillData

use of am2.playerextensions.SkillData 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 SkillData

use of am2.playerextensions.SkillData in project ArsMagica2 by Mithion.

the class AMEventHandler method onEntityConstructing.

@SubscribeEvent
public void onEntityConstructing(EntityConstructing event) {
    if (event.entity instanceof EntityLivingBase) {
        event.entity.registerExtendedProperties(ExtendedProperties.identifier, new ExtendedProperties());
        ((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.maxManaBonus);
        ((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.maxBurnoutBonus);
        ((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.xpGainModifier);
        ((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.burnoutReductionRate);
        ((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.manaRegenTimeModifier);
        if (event.entity instanceof EntityPlayer) {
            event.entity.registerExtendedProperties(RiftStorage.identifier, new RiftStorage());
            event.entity.registerExtendedProperties(AffinityData.identifier, new AffinityData());
            event.entity.registerExtendedProperties(SkillData.identifier, new SkillData((EntityPlayer) event.entity));
        }
    } else if (event.entity instanceof EntityItemFrame) {
        AMCore.proxy.itemFrameWatcher.startWatchingFrame((EntityItemFrame) event.entity);
    }
}
Also used : RiftStorage(am2.playerextensions.RiftStorage) SkillData(am2.playerextensions.SkillData) EntityItemFrame(net.minecraft.entity.item.EntityItemFrame) AffinityData(am2.playerextensions.AffinityData) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ExtendedProperties(am2.playerextensions.ExtendedProperties) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 5 with SkillData

use of am2.playerextensions.SkillData 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

SkillData (am2.playerextensions.SkillData)4 LearnStates (am2.api.spell.enums.LearnStates)3 SkillPointTypes (am2.api.spell.enums.SkillPointTypes)3 ISkillData (am2.api.ISkillData)1 SkillTreeEntry (am2.api.SkillTreeEntry)1 ISpellComponent (am2.api.spell.component.interfaces.ISpellComponent)1 Affinity (am2.api.spell.enums.Affinity)1 AffinityData (am2.playerextensions.AffinityData)1 ExtendedProperties (am2.playerextensions.ExtendedProperties)1 RiftStorage (am2.playerextensions.RiftStorage)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 EntityItemFrame (net.minecraft.entity.item.EntityItemFrame)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 IIcon (net.minecraft.util.IIcon)1