Search in sources :

Example 1 with ISkillTreeEntry

use of am2.api.spell.component.interfaces.ISkillTreeEntry 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 2 with ISkillTreeEntry

use of am2.api.spell.component.interfaces.ISkillTreeEntry 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 ISkillTreeEntry

use of am2.api.spell.component.interfaces.ISkillTreeEntry 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 4 with ISkillTreeEntry

use of am2.api.spell.component.interfaces.ISkillTreeEntry in project ArsMagica2 by Mithion.

the class CompendiumEntryRitual method getCompendiumGui.

@Override
@SideOnly(Side.CLIENT)
protected GuiArcaneCompendium getCompendiumGui(String searchID, int meta) {
    if (this.ritualShape != null) {
        try {
            Field f = RitualShapeHelper.class.getField(ritualShape);
            MultiblockStructureDefinition def = (MultiblockStructureDefinition) f.get(RitualShapeHelper.instance);
            ISkillTreeEntry entry = SkillManager.instance.getSkill(ritualController);
            if (entry instanceof IRitualInteraction) {
                IRitualInteraction controller = (IRitualInteraction) entry;
                return new GuiArcaneCompendium(searchID, def, controller);
            }
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
    return new GuiArcaneCompendium(searchID);
}
Also used : Field(java.lang.reflect.Field) GuiArcaneCompendium(am2.guis.GuiArcaneCompendium) ISkillTreeEntry(am2.api.spell.component.interfaces.ISkillTreeEntry) IRitualInteraction(am2.api.spell.component.interfaces.IRitualInteraction) MultiblockStructureDefinition(am2.api.blocks.MultiblockStructureDefinition) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 5 with ISkillTreeEntry

use of am2.api.spell.component.interfaces.ISkillTreeEntry in project ArsMagica2 by Mithion.

the class SetSkillKnown method processCommand.

@Override
public void processCommand(ICommandSender var1, String[] var2) {
    if (var2.length != 2 && var2.length != 1) {
        throw new WrongUsageException(this.getCommandUsage(var1), new Object[0]);
    }
    EntityPlayer player = null;
    String skill = "";
    if (var2.length == 2) {
        player = getPlayer(var1, var2[0]);
        skill = var2[1];
    } else {
        player = getCommandSenderAsPlayer(var1);
        skill = var2[0];
    }
    if (player == null)
        return;
    ISkillTreeEntry entry = SkillManager.instance.getSkill(skill);
    SkillData.For(player).learn(entry);
    func_152373_a(var1, this, "Unlocking " + skill + " for " + player.getCommandSenderName(), new Object[0]);
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) ISkillTreeEntry(am2.api.spell.component.interfaces.ISkillTreeEntry) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Aggregations

ISkillTreeEntry (am2.api.spell.component.interfaces.ISkillTreeEntry)12 SkillTreeEntry (am2.api.SkillTreeEntry)6 ISpellComponent (am2.api.spell.component.interfaces.ISpellComponent)2 ISpellModifier (am2.api.spell.component.interfaces.ISpellModifier)2 ISpellPart (am2.api.spell.component.interfaces.ISpellPart)2 ISpellShape (am2.api.spell.component.interfaces.ISpellShape)2 SideOnly (cpw.mods.fml.relauncher.SideOnly)2 ArrayList (java.util.ArrayList)2 Block (net.minecraft.block.Block)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 ItemBlock (net.minecraft.item.ItemBlock)2 MultiblockStructureDefinition (am2.api.blocks.MultiblockStructureDefinition)1 SkillLearnedEvent (am2.api.events.SkillLearnedEvent)1 SpellRecipeItemsEvent (am2.api.events.SpellRecipeItemsEvent)1 IRitualInteraction (am2.api.spell.component.interfaces.IRitualInteraction)1 ContainerInscriptionTable (am2.containers.ContainerInscriptionTable)1 GuiArcaneCompendium (am2.guis.GuiArcaneCompendium)1 ItemSpellPart (am2.items.ItemSpellPart)1 RecipeArsMagica (am2.items.RecipeArsMagica)1 AMDataReader (am2.network.AMDataReader)1