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,8 +30,7 @@ public class GroundAI extends AIController{
Tilec core = unit.closestEnemyCore(); 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){ if(dst < unit.range() / 1.1f){
@@ -41,6 +40,7 @@ public class GroundAI extends AIController{
if(dst > unit.range() * 0.5f){ if(dst > unit.range() * 0.5f){
moveToCore(PathTarget.enemyCores); moveToCore(PathTarget.enemyCores);
} }
}
boolean rotate = false, shoot = false; boolean rotate = false, shoot = false;

View File

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

View File

@@ -1,8 +1,10 @@
package mindustry.world.blocks.units; package mindustry.world.blocks.units;
import arc.*; import arc.*;
import arc.graphics.*;
import arc.graphics.g2d.*; import arc.graphics.g2d.*;
import arc.math.*; import arc.math.*;
import arc.scene.style.*;
import arc.scene.ui.layout.*; import arc.scene.ui.layout.*;
import arc.struct.*; import arc.struct.*;
import arc.util.*; import arc.util.*;
@@ -94,6 +96,7 @@ public class UnitFactory extends Block{
super.setStats(); super.setStats();
stats.remove(BlockStat.itemCapacity); stats.remove(BlockStat.itemCapacity);
//TODO //TODO
//stats.add(BlockStat.productionTime, produceTime / 60f, StatUnit.seconds); //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))); 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 @Override
public Object config(){ public Object config(){
return currentPlan; return currentPlan;

View File

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