// Only used for text based gui public void examine() { System.out.println("*** " + name + " ***"); System.out.println("Hull: " + hull + "/" + maxHull); System.out.println("Systems"); for (AbstractShipSystem system : systems.values()) { system.examine(); } System.out.println("--------------------"); System.out.println("********************"); }
public void update(double dt) { ShipUpdateEvent event = new ShipUpdateEvent(this, dt); EVENT_BUS.post(event); for (AbstractShipSystem system : systems.values()) { if (system != null) system.update(dt); } for (Crew crewMember : crew) { crewMember.update(dt); } for (int i = 0; i < crew.size(); i++) { if (crew.get(i).isDead()) { crew.get(i).remove(); crew.remove(i); i--; } } this.chargeFtlDrive(dt); }
public void update(double dt) { CrewUpdateEvent event = new CrewUpdateEvent(dt, this); if (homeShip != null) { FTLGame.instance().getShip(homeShip).EVENT_BUS.post(event); } if (state == CrewStates.WALKING) { pathfinder.update(dt, this); posX = pathfinder.getX(); posY = pathfinder.getY(); if (pathfinder.state == 0) { state = CrewStates.IDLE; } } else if (state == CrewStates.REPAIRING) { AbstractShipSystem system = room.getSystem(); if (system != null) { system.repair(dt, this); if (system.getDamage() == 0) { state = CrewStates.IDLE; } } } else if (state == CrewStates.MANNING) { AbstractShipSystem system = room.getSystem(); if (system.getDamage() > 0) { system.unmann(); state = CrewStates.REPAIRING; } else if (!system.isPowered()) { system.unmann(); state = CrewStates.IDLE; } } else if (state == CrewStates.FIGHTING) { // TODO: Fight } else if (state == CrewStates.IDLE) { AbstractShipSystem system = room.getSystem(); // System.out.println(name + " " + system.isPowered()); if (system != null && system.getDamage() > 0) { state = CrewStates.REPAIRING; } else if (system != null && system.canMann() && !system.isManned() && system.isPowered()) { int stationX = system.getStationX(); int stationY = system.getStationY(); if (stationX + getRoom().getX() == getX() && stationY + getRoom().getY() == getY()) { system.mann(this); state = CrewStates.MANNING; } else { if (!room.getTile(stationX, stationY).getProperties().containsValue("crew")) move(getRoom(), stationX, stationY); } } } }
public void addSystem(String name, AbstractShipSystem system, String room) { systems.put(name, system); getRoom(room).addSystem(system); system.setRoom(getRoom(room)); }