This commit is contained in:
Anuken
2020-08-20 09:46:08 -04:00
parent 5df2a3e625
commit 3498a34c56
11 changed files with 77 additions and 24 deletions

View File

@@ -7,9 +7,11 @@ import mindustry.game.*;
import mindustry.gen.*;
import mindustry.world.*;
import static mindustry.Vars.pathfinder;
import static mindustry.Vars.*;
public class GroundAI extends AIController{
//static final float commandCooldown = 60f * 10;
//float commandTimer = 60*3;
@Override
public void updateMovement(){
@@ -33,6 +35,21 @@ public class GroundAI extends AIController{
}else if(unit.moving()){
unit.lookAt(unit.vel().angle());
}
//auto-command works but it's very buggy
/*
if(unit instanceof Commanderc){
Commanderc c = (Commanderc)unit;
//try to command when missing members
if(c.controlling().size <= unit.type().commandLimit/2){
commandTimer -= Time.delta;
if(commandTimer <= 0){
c.commandNearby(new SquareFormation(), u -> !(u.controller() instanceof FormationAI) && !(u instanceof Commanderc));
commandTimer = commandCooldown;
}
}
}*/
}
protected void moveToCore(FlagTarget path){

View File

@@ -33,8 +33,10 @@ public class Fx{
float scl = 1f + e.fout() * 2f;
UnitType unit = e.data();
rect(unit.region, e.x, e.y,
unit.region.getWidth() * Draw.scl * scl, unit.region.getHeight() * Draw.scl * scl, 180f);
TextureRegion region = unit.icon(Cicon.full);
rect(region, e.x, e.y,
region.getWidth() * Draw.scl * scl, region.getHeight() * Draw.scl * scl, 180f);
}),

View File

@@ -331,6 +331,11 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
//endregion
//region handler methods
/** Called when this block is dropped as a payload. */
public void dropped(){
}
/** This is for logic blocks. */
public void handleString(Object value){

View File

@@ -1,10 +1,13 @@
package mindustry.entities.comp;
import arc.func.*;
import arc.math.geom.*;
import arc.struct.*;
import arc.util.ArcAnnotate.*;
import mindustry.ai.formations.*;
import mindustry.ai.types.*;
import mindustry.annotations.Annotations.*;
import mindustry.entities.*;
import mindustry.entities.units.*;
import mindustry.gen.*;
@@ -12,6 +15,7 @@ import mindustry.gen.*;
@Component
abstract class CommanderComp implements Unitc{
private static final Seq<FormationMember> members = new Seq<>();
private static final Seq<Unit> units = new Seq<>();
@Import float x, y, rotation;
@@ -44,6 +48,28 @@ abstract class CommanderComp implements Unitc{
clearCommand();
}
void commandNearby(FormationPattern pattern){
commandNearby(pattern, u -> true);
}
void commandNearby(FormationPattern pattern, Boolf<Unit> include){
Formation formation = new Formation(new Vec3(x, y, rotation), pattern);
formation.slotAssignmentStrategy = new DistanceAssignmentStrategy(pattern);
units.clear();
Units.nearby(team(), x, y, 200f, u -> {
if(u.isAI() && include.get(u) && u != base()){
units.add(u);
}
});
units.sort(u -> u.dst2(this));
units.truncate(type().commandLimit);
command(formation, units);
}
void command(Formation formation, Seq<Unit> units){
clearCommand();

View File

@@ -62,8 +62,8 @@ abstract class WaterMoveComp implements Posc, Velc, Hitboxc, Flyingc, Unitc{
Draw.z(Layer.debris);
Floor floor = floorOn();
Color color = Tmp.c1.set(floor.mapColor).mul(1.5f);
Floor floor = tileOn() == null ? Blocks.air.asFloor() : tileOn().floor();
Color color = Tmp.c1.set(floor.mapColor.equals(Color.black) ? Blocks.water.mapColor : floor.mapColor).mul(1.5f);
trailColor.lerp(color, Mathf.clamp(Time.delta * 0.04f));
tleft.draw(trailColor, type.trailScl);

View File

@@ -35,6 +35,12 @@ public class DefaultWaves{
max = 4;
}},
new SpawnGroup(UnitTypes.pulsar){{
begin = 13;
spacing = 3;
unitScaling = 0.5f;
}},
new SpawnGroup(UnitTypes.mace){{
begin = 7;
spacing = 3;

View File

@@ -14,7 +14,6 @@ import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.ArcAnnotate.*;
import arc.util.*;
import mindustry.ai.formations.*;
import mindustry.ai.formations.patterns.*;
import mindustry.annotations.Annotations.*;
import mindustry.content.*;
@@ -261,23 +260,9 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
if(commander.isCommanding()){
commander.clearCommand();
}else{
FormationPattern pattern = new SquareFormation();
Formation formation = new Formation(new Vec3(player.x, player.y, player.unit().rotation), pattern);
formation.slotAssignmentStrategy = new DistanceAssignmentStrategy(pattern);
units.clear();
commander.commandNearby(new SquareFormation());
Fx.commandSend.at(player);
Units.nearby(player.team(), player.x, player.y, 200f, u -> {
if(u.isAI()){
units.add(u);
}
});
units.sort(u -> u.dst2(player.unit()));
units.truncate(player.unit().type().commandLimit);
commander.command(formation, units);
}
}

View File

@@ -48,6 +48,7 @@ public class ForceProjector extends Block{
hasPower = true;
hasLiquids = true;
hasItems = true;
//TODO this isn't good enough, shields are still clipped
expanded = true;
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 0.1f)).boost().update(false);
}

View File

@@ -113,6 +113,11 @@ public class LogicBlock extends Block{
}
}
@Override
public void drawPlace(int x, int y, int rotation, boolean valid){
Drawf.circles(x*tilesize + offset, y*tilesize + offset, range);
}
@Override
public Object pointConfig(Object config, Cons<Point2> transformer){
if(config instanceof byte[]){
@@ -389,10 +394,7 @@ public class LogicBlock extends Block{
return other != null && other.isValid() && other.team == team && other.within(this, range + other.block.size*tilesize/2f) && !(other instanceof BuildEntity);
}
@Override
public void drawSelect(){
}
@Override
public void buildConfiguration(Table table){

View File

@@ -31,6 +31,7 @@ public class BlockPayload implements Payload{
public void place(Tile tile, int rotation){
tile.setBlock(entity.block(), entity.team(), rotation, () -> entity);
entity.dropped();
}
@Override

View File

@@ -306,6 +306,14 @@ public class PowerNode extends PowerBlock{
super.placed();
}
@Override
public void dropped(){
power.links.clear();
//create new power graph to manually unlink (this may be redundant)
power.graph = new PowerGraph();
power.graph.add(this);
}
@Override
public void updateTile(){
power.graph.update();