Unit assembly drones + more visuals

This commit is contained in:
Anuken
2021-12-15 14:51:42 -05:00
parent b5ce9e1a38
commit 00ed0d017c
16 changed files with 242 additions and 98 deletions
@@ -0,0 +1,22 @@
package mindustry.ai.types;
import arc.math.geom.*;
import mindustry.entities.units.*;
import mindustry.gen.*;
import mindustry.world.blocks.units.UnitAssembler.*;
public class AssemblerAI extends AIController{
public Vec2 targetPos = new Vec2();
@Override
public void updateMovement(){
//TODO
if(!targetPos.isZero()){
moveTo(targetPos, 8f, 11f);
}
if(unit instanceof BuildingTetherc tether && tether.building() instanceof UnitAssemblerBuild assembler){
unit.lookAt(assembler.getUnitSpawn());
}
}
}
-28
View File
@@ -1,7 +1,6 @@
package mindustry.ai.types;
import arc.math.*;
import arc.math.geom.*;
import arc.struct.*;
import arc.util.*;
import mindustry.ai.*;
@@ -113,33 +112,6 @@ public class LogicAI extends AIController{
return radars.add(radar);
}
@Override
public void moveTo(Position target, float circleLength, float smooth){
if(target == null) return;
vec.set(target).sub(unit);
float length = circleLength <= 0.001f ? 1f : Mathf.clamp((unit.dst(target) - circleLength) / smooth, -1f, 1f);
vec.setLength(unit.speed() * length);
if(length < -0.5f){
vec.rotate(180f);
}else if(length < 0){
vec.setZero();
}
//do not move when infinite vectors are used.
if(vec.isNaN() || vec.isInfinite()) return;
if(unit.type.omniMovement){
unit.approach(vec);
}else{
unit.rotateMove(vec);
}
}
@Override
public boolean checkTarget(Teamc target, float x, float y, float range){
return false;