This commit is contained in:
@@ -117,11 +117,6 @@ public class SectorInfo{
|
||||
export.get(item, ExportStat::new).counter += amount;
|
||||
}
|
||||
|
||||
/** Subtracts from export statistics. */
|
||||
public void handleItemImport(Item item, int amount){
|
||||
export.get(item, ExportStat::new).counter -= amount;
|
||||
}
|
||||
|
||||
public float getExport(Item item){
|
||||
return export.get(item, ExportStat::new).mean;
|
||||
}
|
||||
@@ -270,6 +265,26 @@ public class SectorInfo{
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
/** @return a newly allocated map with import statistics. Use sparingly. */
|
||||
public ObjectMap<Item, ExportStat> importStats(){
|
||||
//build empty import stats
|
||||
ObjectMap<Item, ExportStat> imports = new ObjectMap<>();
|
||||
//for all sectors on all planets that have bases and export to this sector
|
||||
for(Planet planet : content.planets()){
|
||||
for(Sector sector : planet.sectors){
|
||||
Sector dest = sector.info.getRealDestination();
|
||||
if(sector.hasBase() && sector.info != this && dest != null && dest.info == this){
|
||||
//add their exports to our imports
|
||||
sector.info.export.each((item, stat) -> {
|
||||
imports.get(item, ExportStat::new).mean += stat.mean;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return imports;
|
||||
}
|
||||
|
||||
public static class ExportStat{
|
||||
public transient float counter;
|
||||
public transient WindowedMean means = new WindowedMean(valueWindow);
|
||||
|
||||
Reference in New Issue
Block a user