public void clearCommands() { for (Iterator<Command> it = commands.iterator(); it.hasNext(); ) { Command command = it.next(); command.setRunning(false); } commands.clear(); }
public void addCommand(Command command) { command.setRunning(true); for (int i = 0; i < commands.size(); i++) { Command command1 = commands.get(i); if (command1.getPriority() < command.getPriority()) { commands.add(i, command); return; } } commands.add(command); }
public void update(float tpf) { if (!enabled) { return; } for (Iterator<Command> it = commands.iterator(); it.hasNext(); ) { Command command = it.next(); // do command and remove if returned true, else stop processing Command.State commandState = command.doCommand(tpf); switch (commandState) { case Finished: command.setRunning(false); it.remove(); break; case Blocking: return; case Continuing: break; } } }
public void removeCommand(Command command) { command.setRunning(false); commands.remove(command); }
public Command initializeCommand(Command command) { return command.initialize(world, playerId, entityId, spatial); }