This commit is contained in:
Anuken
2020-10-17 10:37:28 -04:00
parent 3a7ee50db3
commit 46ec457819
42 changed files with 142 additions and 118 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ public class BaseAI{
CoreBlock block = (CoreBlock)data.core().block;
//create AI core unit
if(!state.isEditor() && !Groups.unit.contains(u -> u.team() == data.team && u.type() == block.unitType)){
if(!state.isEditor() && !Groups.unit.contains(u -> u.team() == data.team && u.type == block.unitType)){
Unit unit = block.unitType.create(data.team);
unit.set(data.core());
unit.add();
+1 -1
View File
@@ -175,7 +175,7 @@ public class WaveSpawner{
}
private void spawnEffect(Unit unit){
Call.spawnEffect(unit.x, unit.y, unit.type());
Call.spawnEffect(unit.x, unit.y, unit.type);
Time.run(30f, unit::add);
}
+2 -2
View File
@@ -79,7 +79,7 @@ public class BuilderAI extends AIController{
float dist = Math.min(cons.dst(unit) - buildingRange, 0);
//make sure you can reach the request in time
if(dist / unit.type().speed < cons.buildCost * 0.9f){
if(dist / unit.type.speed < cons.buildCost * 0.9f){
following = b;
found = true;
}
@@ -112,7 +112,7 @@ public class BuilderAI extends AIController{
@Override
public AIController fallback(){
return unit.type().flying ? new FlyingAI() : new GroundAI();
return unit.type.flying ? new FlyingAI() : new GroundAI();
}
@Override
+2 -2
View File
@@ -12,7 +12,7 @@ public class FlyingAI extends AIController{
@Override
public void updateMovement(){
if(target != null && unit.hasWeapons() && command() == UnitCommand.attack){
if(unit.type().weapons.first().rotate){
if(unit.type.weapons.first().rotate){
moveTo(target, unit.range() * 0.8f);
unit.lookAt(target);
}else{
@@ -57,7 +57,7 @@ public class FlyingAI extends AIController{
vec.setAngle(Mathf.slerpDelta(unit.vel().angle(), vec.angle(), 0.6f));
}
vec.setLength(unit.type().speed);
vec.setLength(unit.type.speed);
unit.moveAt(vec);
}
+4 -4
View File
@@ -27,14 +27,14 @@ public class FormationAI extends AIController implements FormationMember{
@Override
public void updateUnit(){
UnitType type = unit.type();
UnitType type = unit.type;
if(leader.dead){
unit.resetController();
return;
}
if(unit.type().canBoost && unit.canPassOn()){
if(unit.type.canBoost && unit.canPassOn()){
unit.elevation = Mathf.approachDelta(unit.elevation, 0f, 0.08f);
}
@@ -43,7 +43,7 @@ public class FormationAI extends AIController implements FormationMember{
unit.aim(leader.aimX(), leader.aimY());
if(unit.type().rotateShooting){
if(unit.type.rotateShooting){
unit.lookAt(leader.aimX(), leader.aimY());
}else if(unit.moving()){
unit.lookAt(unit.vel.angle());
@@ -65,7 +65,7 @@ public class FormationAI extends AIController implements FormationMember{
CoreBuild core = unit.team.core();
if(core != null && com.mineTile().drop() != null && unit.within(core, unit.type().range) && !unit.acceptsItem(com.mineTile().drop())){
if(core != null && com.mineTile().drop() != null && unit.within(core, unit.type.range) && !unit.acceptsItem(com.mineTile().drop())){
if(core.acceptStack(unit.stack.item, unit.stack.amount, unit) > 0){
Call.transferItemTo(unit.stack.item, unit.stack.amount, unit.x, unit.y, core);
+4 -4
View File
@@ -45,13 +45,13 @@ public class GroundAI extends AIController{
}
}
if(unit.type().canBoost && !unit.onSolid()){
if(unit.type.canBoost && !unit.onSolid()){
unit.elevation = Mathf.approachDelta(unit.elevation, 0f, 0.08f);
}
if(!Units.invalidateTarget(target, unit, unit.range()) && unit.type().rotateShooting){
if(unit.type().hasWeapons()){
unit.lookAt(Predict.intercept(unit, target, unit.type().weapons.first().bullet.speed));
if(!Units.invalidateTarget(target, unit, unit.range()) && unit.type.rotateShooting){
if(unit.type.hasWeapons()){
unit.lookAt(Predict.intercept(unit, target, unit.type.weapons.first().bullet.speed));
}
}else if(unit.moving()){
unit.lookAt(unit.vel().angle());
+2 -2
View File
@@ -98,7 +98,7 @@ public class LogicAI extends AIController{
}
}
if(unit.type().canBoost && !unit.type().flying){
if(unit.type.canBoost && !unit.type.flying){
unit.elevation = Mathf.approachDelta(unit.elevation, Mathf.num(boost || unit.onSolid()), 0.08f);
}
@@ -129,7 +129,7 @@ public class LogicAI extends AIController{
@Override
protected boolean shouldShoot(){
return shoot && !(unit.type().canBoost && boost);
return shoot && !(unit.type.canBoost && boost);
}
//always aim for the main target
+6 -6
View File
@@ -19,7 +19,7 @@ public class MinerAI extends AIController{
if(!(unit instanceof Minerc miner) || core == null) return;
if(miner.mineTile() != null && !miner.mineTile().within(unit, unit.type().range)){
if(miner.mineTile() != null && !miner.mineTile().within(unit, unit.type.range)){
miner.mineTile(null);
}
@@ -36,7 +36,7 @@ public class MinerAI extends AIController{
}
//if inventory is full, drop it off.
if(unit.stack.amount >= unit.type().itemCapacity || (targetItem != null && !unit.acceptsItem(targetItem))){
if(unit.stack.amount >= unit.type.itemCapacity || (targetItem != null && !unit.acceptsItem(targetItem))){
mining = false;
}else{
if(retarget() && targetItem != null){
@@ -44,9 +44,9 @@ public class MinerAI extends AIController{
}
if(ore != null){
moveTo(ore, unit.type().range / 2f);
moveTo(ore, unit.type.range / 2f);
if(unit.within(ore, unit.type().range)){
if(unit.within(ore, unit.type.range)){
miner.mineTile(ore);
}
@@ -63,7 +63,7 @@ public class MinerAI extends AIController{
return;
}
if(unit.within(core, unit.type().range)){
if(unit.within(core, unit.type.range)){
if(core.acceptStack(unit.stack.item, unit.stack.amount, unit) > 0){
Call.transferItemTo(unit.stack.item, unit.stack.amount, unit.x, unit.y, core);
}
@@ -72,7 +72,7 @@ public class MinerAI extends AIController{
mining = true;
}
circle(core, unit.type().range / 1.8f);
circle(core, unit.type.range / 1.8f);
}
}
+3 -3
View File
@@ -12,7 +12,7 @@ public class RepairAI extends AIController{
if(target instanceof Building){
boolean shoot = false;
if(target.within(unit, unit.type().range)){
if(target.within(unit, unit.type.range)){
unit.aim(target);
shoot = true;
}
@@ -23,8 +23,8 @@ public class RepairAI extends AIController{
}
if(target != null){
if(!target.within(unit, unit.type().range * 0.65f) && target instanceof Building){
moveTo(target, unit.type().range * 0.65f);
if(!target.within(unit, unit.type.range * 0.65f) && target instanceof Building){
moveTo(target, unit.type.range * 0.65f);
}
unit.lookAt(target);
+5 -5
View File
@@ -21,7 +21,7 @@ public class SuicideAI extends GroundAI{
}
if(retarget()){
target = target(unit.x, unit.y, unit.range(), unit.type().targetAir, unit.type().targetGround);
target = target(unit.x, unit.y, unit.range(), unit.type.targetAir, unit.type.targetGround);
}
Building core = unit.closestEnemyCore();
@@ -30,11 +30,11 @@ public class SuicideAI extends GroundAI{
if(!Units.invalidateTarget(target, unit, unit.range()) && unit.hasWeapons()){
rotate = true;
shoot = unit.within(target, unit.type().weapons.first().bullet.range() +
shoot = unit.within(target, unit.type.weapons.first().bullet.range() +
(target instanceof Building ? ((Building)target).block.size * Vars.tilesize / 2f : ((Hitboxc)target).hitSize() / 2f));
if(unit.type().hasWeapons()){
unit.aimLook(Predict.intercept(unit, target, unit.type().weapons.first().bullet.speed));
if(unit.type.hasWeapons()){
unit.aimLook(Predict.intercept(unit, target, unit.type.weapons.first().bullet.speed));
}
//do not move toward walls or transport blocks
@@ -65,7 +65,7 @@ public class SuicideAI extends GroundAI{
if(!blocked){
moveToTarget = true;
//move towards target directly
unit.moveAt(vec.set(target).sub(unit).limit(unit.type().speed));
unit.moveAt(vec.set(target).sub(unit).limit(unit.type.speed));
}
}