mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-09 20:29:06 +07:00
parent
6e5ad304e4
commit
0e6d9ea933
@ -52,6 +52,7 @@ public class BaseAI{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void update(){
|
public void update(){
|
||||||
|
|
||||||
if(data.team.rules().aiCoreSpawn && timer.get(timerSpawn, 60 * 2.5f) && data.hasCore()){
|
if(data.team.rules().aiCoreSpawn && timer.get(timerSpawn, 60 * 2.5f) && data.hasCore()){
|
||||||
CoreBlock block = (CoreBlock)data.core().block;
|
CoreBlock block = (CoreBlock)data.core().block;
|
||||||
int coreUnits = Groups.unit.count(u -> u.team == data.team && u.type == block.unitType);
|
int coreUnits = Groups.unit.count(u -> u.team == data.team && u.type == block.unitType);
|
||||||
@ -90,49 +91,51 @@ public class BaseAI{
|
|||||||
}else{
|
}else{
|
||||||
var field = pathfinder.getField(state.rules.waveTeam, Pathfinder.costGround, Pathfinder.fieldCore);
|
var field = pathfinder.getField(state.rules.waveTeam, Pathfinder.costGround, Pathfinder.fieldCore);
|
||||||
|
|
||||||
int[][] weights = field.weights;
|
if(field.weights != null){
|
||||||
for(int i = 0; i < pathStep; i++){
|
int[][] weights = field.weights;
|
||||||
int minCost = Integer.MAX_VALUE;
|
for(int i = 0; i < pathStep; i++){
|
||||||
int cx = calcTile.x, cy = calcTile.y;
|
int minCost = Integer.MAX_VALUE;
|
||||||
boolean foundAny = false;
|
int cx = calcTile.x, cy = calcTile.y;
|
||||||
for(Point2 p : Geometry.d4){
|
boolean foundAny = false;
|
||||||
int nx = cx + p.x, ny = cy + p.y;
|
for(Point2 p : Geometry.d4){
|
||||||
|
int nx = cx + p.x, ny = cy + p.y;
|
||||||
|
|
||||||
Tile other = world.tile(nx, ny);
|
Tile other = world.tile(nx, ny);
|
||||||
if(other != null && weights[nx][ny] < minCost && weights[nx][ny] != -1){
|
if(other != null && weights[nx][ny] < minCost && weights[nx][ny] != -1){
|
||||||
minCost = weights[nx][ny];
|
minCost = weights[nx][ny];
|
||||||
calcTile = other;
|
calcTile = other;
|
||||||
foundAny = true;
|
foundAny = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//didn't find anything, break out of loop, this will trigger a clear later
|
||||||
|
if(!foundAny){
|
||||||
|
calcCount = Integer.MAX_VALUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
calcPath.add(calcTile.pos());
|
||||||
|
for(Point2 p : Geometry.d8){
|
||||||
|
calcPath.add(Point2.pack(p.x + calcTile.x, p.y + calcTile.y));
|
||||||
|
}
|
||||||
|
|
||||||
|
//found the end.
|
||||||
|
if(calcTile.build instanceof CoreBuild b && b.team == state.rules.defaultTeam){
|
||||||
|
//clean up calculations and flush results
|
||||||
|
calculating = false;
|
||||||
|
calcCount = 0;
|
||||||
|
path.clear();
|
||||||
|
path.addAll(calcPath);
|
||||||
|
calcPath.clear();
|
||||||
|
calcTile = null;
|
||||||
|
totalCalcs ++;
|
||||||
|
foundPath = true;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
calcCount ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
//didn't find anything, break out of loop, this will trigger a clear later
|
|
||||||
if(!foundAny){
|
|
||||||
calcCount = Integer.MAX_VALUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
calcPath.add(calcTile.pos());
|
|
||||||
for(Point2 p : Geometry.d8){
|
|
||||||
calcPath.add(Point2.pack(p.x + calcTile.x, p.y + calcTile.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
//found the end.
|
|
||||||
if(calcTile.build instanceof CoreBuild b && b.team == state.rules.defaultTeam){
|
|
||||||
//clean up calculations and flush results
|
|
||||||
calculating = false;
|
|
||||||
calcCount = 0;
|
|
||||||
path.clear();
|
|
||||||
path.addAll(calcPath);
|
|
||||||
calcPath.clear();
|
|
||||||
calcTile = null;
|
|
||||||
totalCalcs ++;
|
|
||||||
foundPath = true;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
calcCount ++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ import mindustry.gen.*;
|
|||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.graphics.g3d.*;
|
import mindustry.graphics.g3d.*;
|
||||||
import mindustry.input.*;
|
import mindustry.input.*;
|
||||||
import mindustry.io.legacy.*;
|
|
||||||
import mindustry.maps.*;
|
import mindustry.maps.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
@ -165,16 +164,6 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//load legacy research
|
|
||||||
if(Core.settings.has("unlocks") && !Core.settings.has("junction-unlocked")){
|
|
||||||
Core.app.post(() -> {
|
|
||||||
ui.showCustomConfirm("@research", "@research.legacy", "@research.load", "@research.discard", () -> {
|
|
||||||
LegacyIO.readResearch();
|
|
||||||
Core.settings.remove("unlocks");
|
|
||||||
}, () -> Core.settings.remove("unlocks"));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
rebuildButtons();
|
rebuildButtons();
|
||||||
mode = look;
|
mode = look;
|
||||||
selected = hovered = launchSector = null;
|
selected = hovered = launchSector = null;
|
||||||
|
@ -143,10 +143,15 @@ public class UnitFactory extends UnitBlock{
|
|||||||
@Override
|
@Override
|
||||||
public Object senseObject(LAccess sensor){
|
public Object senseObject(LAccess sensor){
|
||||||
if(sensor == LAccess.config) return currentPlan == -1 ? null : plans.get(currentPlan).unit;
|
if(sensor == LAccess.config) return currentPlan == -1 ? null : plans.get(currentPlan).unit;
|
||||||
if(sensor == LAccess.progress) return Mathf.clamp(fraction());
|
|
||||||
return super.senseObject(sensor);
|
return super.senseObject(sensor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double sense(LAccess sensor){
|
||||||
|
if(sensor == LAccess.progress) return Mathf.clamp(fraction());
|
||||||
|
return super.sense(sensor);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildConfiguration(Table table){
|
public void buildConfiguration(Table table){
|
||||||
Seq<UnitType> units = Seq.with(plans).map(u -> u.unit).filter(u -> u.unlockedNow() && !u.isBanned());
|
Seq<UnitType> units = Seq.with(plans).map(u -> u.unit).filter(u -> u.unlockedNow() && !u.isBanned());
|
||||||
|
Loading…
Reference in New Issue
Block a user