This commit is contained in:
Anuken
2022-02-18 19:12:36 -05:00
parent d4e26ea23c
commit 60720dbf8e
5 changed files with 33 additions and 15 deletions

View File

@@ -6,6 +6,7 @@ import arc.struct.*;
import arc.util.*;
import mindustry.*;
import mindustry.ai.*;
import mindustry.entities.*;
import mindustry.entities.units.*;
import mindustry.gen.*;
import mindustry.world.*;
@@ -167,13 +168,13 @@ public class CommandAI extends AIController{
@Override
public Teamc findTarget(float x, float y, float range, boolean air, boolean ground){
return attackTarget == null ? super.findTarget(x, y, range, air, ground) : attackTarget;
return attackTarget == null || !attackTarget.within(x, y, range + (attackTarget instanceof Sized s ? s.hitSize()/2f : 0f)) ? super.findTarget(x, y, range, air, ground) : attackTarget;
}
@Override
public boolean retarget(){
//retarget instantly when there is an explicit target, there is no performance cost
return attackTarget != null || timer.get(timerTarget, 20);
//retarget faster when there is an explicit target
return attackTarget != null ? timer.get(timerTarget, 10) : timer.get(timerTarget, 20);
}
public boolean hasCommand(){

View File

@@ -1880,6 +1880,7 @@ public class Blocks{
requirements(Category.distribution, with(Items.graphite, 8, Items.beryllium, 4));
health = 90;
speed = 4f;
regionRotated1 = 1;
}};
overflowDuct = new OverflowDuct("overflow-duct"){{

View File

@@ -439,7 +439,7 @@ public class UnitType extends UnlockableContent{
}
if(fogRadius < 0){
fogRadius = lightRadius * 1.5f / 8f;
fogRadius = lightRadius * 2f / 8f;
}
clipSize = Math.max(clipSize, lightRadius * 1.1f);

View File

@@ -223,7 +223,7 @@ public class CustomRulesDialog extends BaseDialog{
t.defaults().size(140f, 50f);
//TODO dynamic selection
//TODO dynamic selection of planets
for(Planet planet : new Planet[]{Planets.serpulo, Planets.erekir}){
t.button(planet.localizedName, style, () -> {
rules.env = planet.defaultEnv;

View File

@@ -7,6 +7,7 @@ import arc.math.*;
import arc.util.*;
import arc.util.io.*;
import mindustry.*;
import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.game.*;
@@ -16,6 +17,8 @@ import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.*;
import static mindustry.Vars.*;
public class UnitCargoLoader extends Block{
public UnitType unitType = UnitTypes.manifold;
public float buildTime = 60f * 8f;
@@ -65,6 +68,12 @@ public class UnitCargoLoader extends Block{
}
}
@Remote(called = Loc.server)
public static void cargoLoaderDroneSpawned(Tile tile, int id){
if(tile == null || !(tile.build instanceof UnitTransportSourceBuild build)) return;
build.spawned(id);
}
public class UnitTransportSourceBuild extends Building{
//needs to be "unboxed" after reading, since units are read after buildings.
public int readUnitId = -1;
@@ -92,21 +101,28 @@ public class UnitCargoLoader extends Block{
totalProgress += edelta();
if(buildProgress >= 1f){
unit = unitType.create(team);
if(unit instanceof BuildingTetherc bt){
bt.building(this);
if(!net.client()){
unit = unitType.create(team);
if(unit instanceof BuildingTetherc bt){
bt.building(this);
}
unit.set(x, y);
unit.rotation = 90f;
unit.add();
Call.cargoLoaderDroneSpawned(tile, unit.id);
}
unit.set(x, y);
unit.rotation = 90f;
unit.add();
Fx.spawn.at(unit);
buildProgress = 0f;
}
}
}
public void spawned(int id){
Fx.spawn.at(x, y);
buildProgress = 0f;
if(net.client()){
readUnitId = id;
}
}
@Override
public boolean acceptItem(Building source, Item item){
return items.total() < itemCapacity;