This commit is contained in:
Anuken
2020-05-02 12:58:54 -04:00
parent fed4d10ec6
commit 25f07e7bcb
4 changed files with 19 additions and 8 deletions

View File

@ -87,12 +87,22 @@ public class Annotations{
//endregion //endregion
//region misc. utility //region misc. utility
/** Automatically loads block regions annotated with this. */
@Target(ElementType.FIELD) @Target(ElementType.FIELD)
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
public @interface Load{ public @interface Load{
/**
* The region name to load. Variables can be used:
* "@" -> block name
* "$size" -> block size
* "#" "#1" "#2" -> index number, for arrays
* */
String value(); String value();
/** 1D Array length, if applicable. */
int length() default 1; int length() default 1;
/** 2D array lengths. */
int[] lengths() default {}; int[] lengths() default {};
/** Fallback string used to replace "@" (the block name) if the region isn't found. */
String fallback() default "error"; String fallback() default "error";
} }

View File

@ -1,31 +1,31 @@
package mindustry.ai.types; package mindustry.ai.types;
import arc.util.ArcAnnotate.*; import arc.util.ArcAnnotate.*;
import arc.util.*;
import mindustry.entities.units.*; import mindustry.entities.units.*;
import mindustry.gen.*; import mindustry.gen.*;
public class MimicAI extends AIController{ public class FormationAI extends AIController{
public @Nullable Unitc control; public @Nullable Unitc control;
public MimicAI(@Nullable Unitc control){ public FormationAI(@Nullable Unitc control){
this.control = control; this.control = control;
} }
public MimicAI(){ public FormationAI(){
} }
@Override @Override
public void update(){ public void update(){
if(control != null){ if(control != null){
unit.controlWeapons(control.isRotate(), control.isShooting()); unit.controlWeapons(control.isRotate(), control.isShooting());
//TODO this isn't accurate // unit.moveAt(Tmp.v1.set(deltaX, deltaY).limit(unit.type().speed));
unit.moveAt(Tmp.v1.set(control.vel()).limit(unit.type().speed));
if(control.isShooting()){ if(control.isShooting()){
unit.aimLook(control.aimX(), control.aimY()); unit.aimLook(control.aimX(), control.aimY());
}else{ }else{
unit.lookAt(unit.vel().angle()); unit.lookAt(unit.vel().angle());
} }
} }
} }

View File

@ -120,7 +120,8 @@ public class PhysicsProcess implements AsyncProcess{
//save last position //save last position
ref.position.set(entity); ref.position.set(entity);
entity.vel().add(ref.velocity).sub(ref.lastVelocity); //add delta velocity - this doesn't work very well yet
//entity.vel().add(ref.velocity).sub(ref.lastVelocity);
} }
} }

View File

@ -186,7 +186,7 @@ public class DesktopInput extends InputHandler{
Fx.commandSend.at(player); Fx.commandSend.at(player);
Units.nearby(player.team(), player.x(), player.y(), 200f, u -> { Units.nearby(player.team(), player.x(), player.y(), 200f, u -> {
if(u.isAI()){ if(u.isAI()){
u.controller(new MimicAI(player.unit())); u.controller(new FormationAI(player.unit()));
} }
}); });
} }