From 39f6bc30b7552bd8be142bdfba846f1fb0fbd79a Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 1 May 2020 20:38:12 -0400 Subject: [PATCH] Unit factory tweaks / AI fixes --- core/src/mindustry/ai/types/GroundAI.java | 16 +++++++-------- core/src/mindustry/content/Blocks.java | 4 ++-- .../world/blocks/units/UnitFactory.java | 20 +++++++++++++++++++ gradle.properties | 2 +- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/core/src/mindustry/ai/types/GroundAI.java b/core/src/mindustry/ai/types/GroundAI.java index 51b3afe426..6fb8addb03 100644 --- a/core/src/mindustry/ai/types/GroundAI.java +++ b/core/src/mindustry/ai/types/GroundAI.java @@ -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; diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 1b87bbf3eb..c2a0e79b0b 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -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); diff --git a/core/src/mindustry/world/blocks/units/UnitFactory.java b/core/src/mindustry/world/blocks/units/UnitFactory.java index 18386cc501..f15824af18 100644 --- a/core/src/mindustry/world/blocks/units/UnitFactory.java +++ b/core/src/mindustry/world/blocks/units/UnitFactory.java @@ -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; diff --git a/gradle.properties b/gradle.properties index 2ac30ac1e1..6df1946a71 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=a8d2cb198a6f34654766bf3da73a084d6810e210 +archash=1a6e4dc2f032b4d40e3183060fdd4d9a422fbd34