package net.sourceforge.pain.logic.event.console.command.builder; import net.sourceforge.pain.*; import net.sourceforge.pain.console.*; import net.sourceforge.pain.data.*; import net.sourceforge.pain.data.prototype.*; import net.sourceforge.pain.data.type.*; import net.sourceforge.pain.logic.event.console.*; import net.sourceforge.pain.logic.fn.*; import java.util.*; /** * PAiN Date: 05.06.2003 Time: 1:40:02 */ public final class BC_Reset extends BuilderCommand { public void processBuilderCommand(BuilderShell p, String args) throws Exception { Prototype role = p.builder.getEditedRole(); PrototypeInfo resettedPrototype; if (role == null || (resettedPrototype = (PrototypeInfo) role.getRole(PrototypeInfo.class)) == null) { MessageOutFn.outln(p.console, "No active prototype found!"); return; } if (args == null || args.length() < 3) { showHelp(p.console); return; } String result[] = new String[2]; ConsoleInputEvent.parseCommand(args, result); String uniqueSpaceId = result[0]; String resetGroupId = result[1]; if (resetGroupId == null) { showHelp(p.console); return; } IndexedSpace is = Core.getWorld().getIndexedSpacesRegistry().getSpace(uniqueSpaceId); if (is == null) { MessageOutFn.outln(p.console, "Indexed Space is not found: '" + uniqueSpaceId + "'"); return; } Space space = is.asSpace(); ResetGroupRegistry resetGroupRegistry = Core.getWorld().getResetGroupRegistry(); ResetGroup rg = resetGroupRegistry.getResetGroup(resetGroupId); if (rg == null) { MessageOutFn.outln(p.console, "Reset group not found: '" + resetGroupId + "'"); MessageOutFn.outln(p.console, "Available reset groups:"); Collection resetGroups = resetGroupRegistry.getResetGroups(); for (Iterator it = resetGroups.iterator(); it.hasNext();) { rg = (ResetGroup) it.next(); MessageOutFn.outln(p.console, "\t" + rg.getGroupId() + " \t\t" + rg.getGroupInfo()); } MessageOutFn.outln(p.console, "Total: " + resetGroups.size()); return; } SpaceReset spaceReset = (SpaceReset) ObjectFactory.create(SpaceReset.class); spaceReset.setResettedPrototype(resettedPrototype); spaceReset.setLocation(space); RelocateFn.addToSpace(space, spaceReset.asLocated()); rg.addReset(spaceReset.asReset()); p.builder.setEditedRole(null); p.builder.getPrototypes().remove(resettedPrototype); MessageOutFn.outln(p.console, "Prototype :" + resettedPrototype.getName() + " was resetted in " + space.getName()); MessageOutFn.outln(p.console, "Reset group used:" + rg.getGroupInfo()); } public void showHelp(Console console) { MessageOutFn.outln(console, "Builder command RESET resets the edited prototype."); MessageOutFn.outln(console, "Usage: reset <unique_room_id> <reset_group_id>"); } }