Formation cleanup
This commit is contained in:
@@ -11,4 +11,6 @@ import arc.math.geom.*;
|
||||
public interface FormationMember{
|
||||
/** Returns the target location of this formation member. */
|
||||
Vec3 formationPos();
|
||||
|
||||
float formationSize();
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ import arc.math.geom.*;
|
||||
*/
|
||||
public abstract class FormationPattern{
|
||||
public int slots;
|
||||
/** Spacing between members. */
|
||||
public float spacing = 20f;
|
||||
|
||||
/** Returns the location of the given slot index. */
|
||||
public abstract Vec3 calculateSlotLocation(Vec3 out, int slot);
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package mindustry.ai.formations.patterns;
|
||||
|
||||
import arc.math.geom.*;
|
||||
import mindustry.ai.formations.*;
|
||||
|
||||
public class ArrowFormation extends FormationPattern{
|
||||
//total triangular numbers
|
||||
private static final int totalTris = 30;
|
||||
//triangular number table
|
||||
private static final int[] triTable = new int[totalTris];
|
||||
|
||||
//calculat triangular numbers
|
||||
static{
|
||||
int sum = 0;
|
||||
for(int i = 0; i < totalTris; i++){
|
||||
triTable[i] = sum;
|
||||
sum += (i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 calculateSlotLocation(Vec3 out, int slot){
|
||||
//TODO
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import arc.math.geom.*;
|
||||
import mindustry.ai.formations.*;
|
||||
|
||||
public class SquareFormation extends FormationPattern{
|
||||
public float spacing = 20;
|
||||
|
||||
@Override
|
||||
public Vec3 calculateSlotLocation(Vec3 out, int slot){
|
||||
|
||||
@@ -60,6 +60,15 @@ public class FormationAI extends AIController implements FormationMember{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float formationSize(){
|
||||
if(unit instanceof Commanderc && ((Commanderc)unit).isCommanding()){
|
||||
//TODO return formation size
|
||||
//eturn ((Commanderc)unit).formation().
|
||||
}
|
||||
return unit.hitSize * 2f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBeingControlled(Unit player){
|
||||
return leader == player;
|
||||
|
||||
Reference in New Issue
Block a user