private boolean isColonized(BaseStar star) { for (BaseColony colony : star.getColonies()) { if (colony.getEmpireKey() != null) { return true; } } return false; }
private void placePlanets() { int width = getWidth(); float planetStart = 150 * getPixelScale(); float distanceBetweenPlanets = width - planetStart; distanceBetweenPlanets /= mPlanetInfos.length; for (int i = 0; i < mPlanetInfos.length; i++) { PlanetInfo planetInfo = mPlanetInfos[i]; float distanceFromSun = planetStart + (distanceBetweenPlanets * i) + (distanceBetweenPlanets / 2.0f); float x = 0; float y = -1 * distanceFromSun; float angle = (0.5f / (mPlanetInfos.length + 1)); angle = (float) ((angle * i * Math.PI) + angle * Math.PI); Vector2 centre = new Vector2(x, y); centre.rotate(angle); centre.y *= -1; planetInfo.centre = centre; planetInfo.distanceFromSun = distanceFromSun; List<BaseColony> colonies = mStar.getColonies(); if (colonies != null && !colonies.isEmpty()) { for (BaseColony colony : colonies) { if (colony.getPlanetIndex() == mPlanetInfos[i].planet.getIndex()) { planetInfo.colony = (Colony) colony; planetInfo.buildings = new ArrayList<Building>(); for (BaseBuilding building : colony.getBuildings()) { BuildingDesign design = (BuildingDesign) DesignManager.i.getDesign(DesignKind.BUILDING, building.getDesignID()); if (design.showInSolarSystem()) { planetInfo.buildings.add((Building) building); } } if (!planetInfo.buildings.isEmpty()) { Collections.sort(planetInfo.buildings, mBuildingDesignComparator); } } } } mPlanetInfos[i] = planetInfo; } updateSelection(); }