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;
}
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);
}
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;
}
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);
}
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]);
}
Aggregations