/* Place all motionless objects (fire stations, police offices, ambulance teams and refuges) @param fire An array to be filled with fire stations @param police An array to be filled with police offices @param ambulance An array to be filled with ambulance centres @param refuge An array to be filled with refuges @param allBuildings All buildings in the map @return All ordinary buildings */ public static Building[] placeMotionlessObjects( FireStation[] fire, PoliceOffice[] police, AmbulanceCenter[] ambulance, Refuge[] refuge, Building[] allBuildings) { List remaining = new ArrayList(); for (int i = 0; i < allBuildings.length; ++i) remaining.add(allBuildings[i]); Collections.shuffle(remaining); System.out.println("Placing " + ambulance.length + " ambulance centers"); Iterator it = remaining.iterator(); for (int i = 0; i < ambulance.length; ++i) { Building location = (Building) it.next(); it.remove(); AmbulanceCenter a = new AmbulanceCenter(location); a.setID(location.getID()); ambulance[i] = a; // writeFixedObjectData(out,TYPE_AMBULANCE_CENTER,i,location); } System.out.println("Placing " + fire.length + " fire stations"); for (int i = 0; i < fire.length; ++i) { Building location = (Building) it.next(); it.remove(); FireStation a = new FireStation(location); a.setID(location.getID()); fire[i] = a; // writeFixedObjectData(out,TYPE_FIRE_STATION,i,location); // System.out.print("."); } System.out.println("Placing " + police.length + " police stations"); for (int i = 0; i < police.length; ++i) { Building location = (Building) it.next(); it.remove(); PoliceOffice a = new PoliceOffice(location); a.setID(location.getID()); police[i] = a; // writeFixedObjectData(out,TYPE_POLICE_OFFICE,i,location); // System.out.print("."); } System.out.println("Placing " + refuge.length + " refuges"); for (int i = 0; i < refuge.length; ++i) { Building location = (Building) it.next(); it.remove(); Refuge a = new Refuge(location); a.setID(location.getID()); refuge[i] = a; // writeFixedObjectData(out,TYPE_REFUGE,i,location); // System.out.print("."); } // System.out.println(); return (Building[]) remaining.toArray(new Building[0]); }