Certain team-specific rules
This commit is contained in:
@@ -14,7 +14,6 @@ import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.defense.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.blocks.storage.CoreBlock.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@@ -48,10 +47,13 @@ public class BaseAI{
|
||||
|
||||
for(int i = 0; i < attempts; i++){
|
||||
int range = 150;
|
||||
CoreEntity core = data.cores.random();
|
||||
|
||||
Position pos = randomPosition();
|
||||
//when there are no random positions, do nothing.
|
||||
if(pos == null) return;
|
||||
|
||||
Tmp.v1.rnd(Mathf.random(range));
|
||||
int wx = (int)(core.tileX() + Tmp.v1.x), wy = (int)(core.tileY() + Tmp.v1.y);
|
||||
int wx = (int)(world.toTile(pos.getX()) + Tmp.v1.x), wy = (int)(world.toTile(pos.getY()) + Tmp.v1.y);
|
||||
Tile tile = world.tiles.getc(wx, wy);
|
||||
|
||||
Seq<BasePart> parts = null;
|
||||
@@ -74,7 +76,17 @@ public class BaseAI{
|
||||
}
|
||||
}
|
||||
|
||||
boolean tryPlace(BasePart part, int x, int y){
|
||||
/** @return a random position from which to seed building. */
|
||||
private Position randomPosition(){
|
||||
if(data.hasCore()){
|
||||
return data.cores.random();
|
||||
}else if(data.team == state.rules.waveTeam){
|
||||
return spawner.getSpawns().random();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean tryPlace(BasePart part, int x, int y){
|
||||
int rotation = Mathf.range(2);
|
||||
axis.set((int)(part.schematic.width / 2f), (int)(part.schematic.height / 2f));
|
||||
Schematic result = Schematics.rotate(part.schematic, rotation);
|
||||
@@ -131,7 +143,7 @@ public class BaseAI{
|
||||
return true;
|
||||
}
|
||||
|
||||
void tryWalls(){
|
||||
private void tryWalls(){
|
||||
Block wall = Blocks.copperWall;
|
||||
Tile spawn = state.rules.defaultTeam.core() != null ? state.rules.defaultTeam.core().tile : data.team.core().tile;
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ public class BuilderAI extends AIController{
|
||||
}
|
||||
|
||||
//approach request if building
|
||||
if(builder.buildRequest() != null){
|
||||
BuildRequest req = builder.buildRequest();
|
||||
if(builder.buildPlan() != null){
|
||||
BuildPlan req = builder.buildPlan();
|
||||
|
||||
boolean valid =
|
||||
(req.tile().entity instanceof BuildEntity && req.tile().<BuildEntity>ent().cblock == req.block) ||
|
||||
@@ -37,7 +37,7 @@ public class BuilderAI extends AIController{
|
||||
moveTo(req.tile(), buildingRange - 20f);
|
||||
}else{
|
||||
//discard invalid request
|
||||
builder.requests().removeFirst();
|
||||
builder.plans().removeFirst();
|
||||
}
|
||||
}else{
|
||||
//find new request
|
||||
@@ -50,7 +50,7 @@ public class BuilderAI extends AIController{
|
||||
blocks.removeFirst();
|
||||
}else if(Build.validPlace(content.block(block.block), unit.team(), block.x, block.y, block.rotation)){ //it's valid.
|
||||
//add build request.
|
||||
BuildRequest req = new BuildRequest(block.x, block.y, block.rotation, content.block(block.block));
|
||||
BuildPlan req = new BuildPlan(block.x, block.y, block.rotation, content.block(block.block));
|
||||
if(block.config != null){
|
||||
req.configure(block.config);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user