Unit factory tweaks / AI fixes

This commit is contained in:
Anuken 2020-05-01 20:38:12 -04:00
parent 35bd6a40c5
commit 39f6bc30b7
4 changed files with 31 additions and 11 deletions

View file

@ -30,16 +30,16 @@ public class GroundAI extends AIController{
Tilec core = unit.closestEnemyCore();
if(core == null) return;
if(core != null){
float dst = unit.dst(core);
float dst = unit.dst(core);
if(dst < unit.range() / 1.1f){
target = core;
}
if(dst < unit.range() / 1.1f){
target = core;
}
if(dst > unit.range() * 0.5f){
moveToCore(PathTarget.enemyCores);
if(dst > unit.range() * 0.5f){
moveToCore(PathTarget.enemyCores);
}
}
boolean rotate = false, shoot = false;

View file

@ -1673,8 +1673,8 @@ public class Blocks implements ContentList{
groundFactory = new UnitFactory("ground-factory"){{
requirements(Category.units, ItemStack.with(Items.copper, 30, Items.lead, 70));
plans = new UnitPlan[]{
new UnitPlan(UnitTypes.dagger, 200f, ItemStack.with(Items.silicon, 10)),
new UnitPlan(UnitTypes.titan, 400f, ItemStack.with(Items.silicon, 20, Items.thorium, 20)),
new UnitPlan(UnitTypes.dagger, 500f, ItemStack.with(Items.silicon, 10)),
new UnitPlan(UnitTypes.titan, 800f, ItemStack.with(Items.silicon, 20, Items.titanium, 10)),
};
size = 3;
consumes.power(1.2f);

View file

@ -1,8 +1,10 @@
package mindustry.world.blocks.units;
import arc.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.scene.style.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.*;
@ -94,6 +96,7 @@ public class UnitFactory extends Block{
super.setStats();
stats.remove(BlockStat.itemCapacity);
//TODO
//stats.add(BlockStat.productionTime, produceTime / 60f, StatUnit.seconds);
}
@ -150,6 +153,23 @@ public class UnitFactory extends Block{
ItemSelection.buildTable(table, units, () -> currentPlan == -1 ? null : plans[currentPlan].unit, unit -> tile.configure(units.indexOf(unit)));
}
@Override
public void display(Table table){
super.display(table);
TextureRegionDrawable reg = new TextureRegionDrawable();
table.row();
table.table(t -> {
t.image().update(i -> {
i.setDrawable(currentPlan == -1 ? Icon.cancel : reg.set(plans[currentPlan].unit.icon(Cicon.medium)));
i.setScaling(Scaling.fit);
i.setColor(currentPlan == -1 ? Color.lightGray : Color.white);
}).size(32).padBottom(-4).padRight(2);
t.label(() -> currentPlan == -1 ? "$none" : plans[currentPlan].unit.localizedName).color(Color.lightGray);
});
}
@Override
public Object config(){
return currentPlan;

View file

@ -1,3 +1,3 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=a8d2cb198a6f34654766bf3da73a084d6810e210
archash=1a6e4dc2f032b4d40e3183060fdd4d9a422fbd34