Consumer fixes / Removed unit factory target tag / Rank tweak

This commit is contained in:
Anuken
2019-03-03 10:55:56 -05:00
parent 627b78043b
commit 02fad0a9cc
7 changed files with 11 additions and 10 deletions

View File

@@ -25,7 +25,7 @@ public class Stats{
/**Friendly buildings destroyed.*/
public int buildingsDestroyed;
public RankResult calculateRank(Zone zone, Rules rules, boolean launched){
public RankResult calculateRank(Zone zone, boolean launched){
float score = 0;
//each new launch period adds onto the rank 1.5 'points'
@@ -35,14 +35,14 @@ public class Stats{
int capacity = zone.loadout.core().itemCapacity;
//weigh used fractions of
//weigh used fractions
float frac = 0f;
Array<Item> obtainable = Array.with(zone.resources).select(i -> i.type == ItemType.material);
for(Item item : obtainable){
frac += Mathf.clamp((float)itemsDelivered.get(item, 0) / capacity) / (float)obtainable.size;
}
score += frac*3f;
score += frac*2.4f;
if(!launched){
score *= 0.5f;

View File

@@ -70,7 +70,7 @@ public class GameOverDialog extends FloatingDialog{
}
if(world.isZone()){
RankResult result = state.stats.calculateRank(world.getZone(), state.rules, state.launched);
RankResult result = state.stats.calculateRank(world.getZone(), state.launched);
cont.add(Core.bundle.format("stat.rank", result.rank + result.modifier));
cont.row();
}

View File

@@ -122,7 +122,8 @@ public class PowerGraph{
}
public void distributePower(float needed, float produced){
if(Mathf.isEqual(needed, 0f)){ return; }
//distribute even if not needed. this is because some might be requiring power but not requesting it; it updates consumers
//if(Mathf.isEqual(needed, 0f)) return;
float coverage = Math.min(1, produced / needed);
for(Tile consumer : consumers){

View File

@@ -85,7 +85,7 @@ public class Drill extends Block{
bars.add("drillspeed", e -> {
DrillEntity entity = (DrillEntity)e;
return new Bar(() -> Core.bundle.format("blocks.outputspeed", Strings.toFixed(entity.lastDrillSpeed * 60, 2)), () -> Pal.ammo, () -> entity.warmup);
return new Bar(() -> Core.bundle.format("blocks.outputspeed", Strings.toFixed(entity.lastDrillSpeed * 60 * entity.timeScale, 2)), () -> Pal.ammo, () -> entity.warmup);
});
}

View File

@@ -51,7 +51,7 @@ public class UnitFactory extends Block{
hasPower = true;
hasItems = true;
solid = false;
flags = EnumSet.of(BlockFlag.producer, BlockFlag.target);
flags = EnumSet.of(BlockFlag.producer);
consumes.require(ConsumeItems.class);
}

View File

@@ -26,7 +26,7 @@ public class ConsumeItems extends Consume{
@Override
public void build(Tile tile, Table table){
for(ItemStack stack : items){
table.add(new ReqImage(new ItemImage(stack.item.icon(Icon.large), stack.amount), () -> valid(tile.block(), tile.entity))).size(8*4).padRight(5);
table.add(new ReqImage(new ItemImage(stack.item.icon(Icon.large), stack.amount), () -> tile.entity != null && tile.entity.items != null && tile.entity.items.has(stack.item, stack.amount))).size(8*4).padRight(5);
}
}