Allowing multiple planets to have the same tech tree (#11017)
* Lists all planets having the same TechTree associated with them. As of right now, this problem arizes only with modded games. If you add planets in a specific order (e.g. StarA, PlanetA, PlanetB) and attach same tech tree to all of them - only items from the first planet (StarA) will be used and accounted for. You can see this if you try to attach Serpulo's TechTree to Planets.sun - no resources from Serpulo will be visible and usable in Serpulo's TechTree in ResearchWindow (or anywhere for that matter). * Removed spaces * Added braces, if anyone will need to expand the code later (ig)
This commit is contained in:
@@ -46,6 +46,7 @@ public class ResearchDialog extends BaseDialog{
|
||||
|
||||
public ItemSeq items;
|
||||
|
||||
private final Seq<Planet> rootPlanets = new Seq<>(false, 4);
|
||||
private boolean showTechSelect;
|
||||
private boolean needsRebuild;
|
||||
|
||||
@@ -214,21 +215,30 @@ public class ResearchDialog extends BaseDialog{
|
||||
ObjectMap<Sector, ItemSeq> cache = new ObjectMap<>();
|
||||
|
||||
{
|
||||
//first, find a planet associated with the current tech tree
|
||||
Planet rootPlanet = lastNode.planet != null ? lastNode.planet : content.planets().find(p -> p.techTree == lastNode);
|
||||
//first, find a planets associated with the current tech tree
|
||||
rootPlanets.clear();
|
||||
for(var planet : content.planets()){
|
||||
if(planet.techTree == lastNode){
|
||||
rootPlanets.add(planet);
|
||||
}
|
||||
}
|
||||
|
||||
//if there is no root, fall back to serpulo
|
||||
if(rootPlanet == null) rootPlanet = Planets.serpulo;
|
||||
if(rootPlanets.size == 0){
|
||||
rootPlanets.add(Planets.serpulo);
|
||||
}
|
||||
|
||||
//add global counts of each sector
|
||||
for(Sector sector : rootPlanet.sectors){
|
||||
if(sector.hasBase()){
|
||||
ItemSeq cached = sector.items();
|
||||
cache.put(sector, cached);
|
||||
cached.each((item, amount) -> {
|
||||
values[item.id] += Math.max(amount, 0);
|
||||
total += Math.max(amount, 0);
|
||||
});
|
||||
for(Planet planet : rootPlanets){
|
||||
for(Sector sector : planet.sectors){
|
||||
if(sector.hasBase()){
|
||||
ItemSeq cached = sector.items();
|
||||
cache.put(sector, cached);
|
||||
cached.each((item, amount) -> {
|
||||
values[item.id] += Math.max(amount, 0);
|
||||
total += Math.max(amount, 0);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user