More pathfinding fixes

This commit is contained in:
Anuken
2018-08-07 18:19:02 -04:00
parent 21ba6e257c
commit 8dea45d9d5
8 changed files with 32 additions and 21 deletions

View File

@@ -90,7 +90,7 @@ public class Vars{
//whether turrets have infinite ammo (only with debug)
public static boolean infiniteAmmo = true;
//whether to show paths of enemies
public static boolean showPaths = false;
public static boolean showPaths = true;
//if false, player is always hidden
public static boolean showPlayer = true;
//whether to hide ui, only on debug

View File

@@ -6,7 +6,6 @@ import com.badlogic.gdx.utils.ObjectSet;
import com.badlogic.gdx.utils.ObjectSet.ObjectSetIterator;
import com.badlogic.gdx.utils.Queue;
import com.badlogic.gdx.utils.TimeUtils;
import io.anuke.mindustry.content.blocks.Blocks;
import io.anuke.mindustry.game.EventType.TileChangeEvent;
import io.anuke.mindustry.game.EventType.WorldLoadEvent;
import io.anuke.mindustry.game.Team;
@@ -89,8 +88,8 @@ public class Pathfinder{
}
private boolean passable(Tile tile, Team team){
return (tile.block() == Blocks.air && !tile.floor().isLiquid && !tile.hasCliffs() && !tile.floor().solid && !(tile.floor().isLiquid && (tile.floor().damageTaken > 0 || tile.floor().drownTime > 0)))
|| (tile.breakable() && (tile.getTeam() != team)) || !tile.solid();
return (!tile.solid() && !(tile.floor().isLiquid && (tile.floor().damageTaken > 0 || tile.floor().drownTime > 0)))
|| (tile.breakable() && (tile.target().getTeam() != team));
}
private void update(Tile tile, Team team){

View File

@@ -109,8 +109,8 @@ public class Recipes implements ContentList{
new Recipe(distribution, StorageBlocks.vault, new ItemStack(Items.carbide, 500), new ItemStack(Items.thorium, 350));
//DRILLS, PRODUCERS
new Recipe(production, ProductionBlocks.tungstenDrill, new ItemStack(Items.tungsten, 40));
new Recipe(production, ProductionBlocks.carbideDrill, new ItemStack(Items.tungsten, 50), new ItemStack(Items.carbide, 40));
new Recipe(production, ProductionBlocks.tungstenDrill, new ItemStack(Items.tungsten, 50));
new Recipe(production, ProductionBlocks.carbideDrill, new ItemStack(Items.tungsten, 60), new ItemStack(Items.carbide, 50));
new Recipe(production, ProductionBlocks.laserdrill, new ItemStack(Items.tungsten, 70), new ItemStack(Items.carbide, 90), new ItemStack(Items.silicon, 60), new ItemStack(Items.titanium, 50));
new Recipe(production, ProductionBlocks.blastdrill, new ItemStack(Items.tungsten, 130), new ItemStack(Items.carbide, 180), new ItemStack(Items.silicon, 120), new ItemStack(Items.titanium, 100), new ItemStack(Items.thorium, 60));

View File

@@ -263,10 +263,10 @@ public class Renderer extends RendererModule{
drawAndInterpolate(playerGroup, p -> true, Player::drawBuildRequests);
overlays.drawTop();
Graphics.flushSurface();
if(showPaths && debug) drawDebug();
Graphics.flushSurface();
batch.end();
if(showFog){

View File

@@ -265,8 +265,9 @@ public abstract class GroundUnit extends BaseUnit{
protected void moveAwayFromCore(){
Tile tile = world.tileWorld(x, y);
Tile targetTile = world.pathfinder().getTargetTile(Vars.state.teams.enemiesOf(team).first(), tile);
TileEntity core = getClosestCore();
if(tile == targetTile) return;
if(tile == targetTile || core == null || distanceTo(core) < 90f) return;
vec.trns(baseRotation, type.speed);

View File

@@ -149,7 +149,18 @@ public class DesktopInput extends InputHandler{
ui.listfrag.toggle();
}
if(player.isDead() || state.is(State.menu) || ui.hasDialog()) return;
if(state.is(State.menu) || ui.hasDialog()) return;
boolean controller = KeyBinds.getSection(section).device.type == DeviceType.controller;
//zoom and rotate things
if(Inputs.getAxisActive("zoom") && (Inputs.keyDown(section, "zoom_hold") || controller)){
renderer.scaleCamera((int) Inputs.getAxisTapped(section, "zoom"));
}
renderer.minimap().zoomBy(-(int) Inputs.getAxisTapped(section, "zoom_minimap"));
if(player.isDead()) return;
if(recipe != null && !Settings.getBool("desktop-place-help", false)){
ui.showInfo("Desktop controls have been changed.\nTo deselect a block or stop building, [accent]use the middle mouse button[].");
@@ -175,14 +186,6 @@ public class DesktopInput extends InputHandler{
selectScale = 0f;
}
boolean controller = KeyBinds.getSection(section).device.type == DeviceType.controller;
//zoom and rotate things
if(Inputs.getAxisActive("zoom") && (Inputs.keyDown(section, "zoom_hold") || controller)){
renderer.scaleCamera((int) Inputs.getAxisTapped(section, "zoom"));
}
renderer.minimap().zoomBy(-(int) Inputs.getAxisTapped(section, "zoom_minimap"));
rotation = Mathf.mod(rotation + (int) Inputs.getAxisTapped(section, "rotate"), 4);
Tile cursor = tileAt(control.gdxInput().getX(), control.gdxInput().getY());

View File

@@ -42,8 +42,10 @@ public class HudFragment extends Fragment{
private boolean shown = true;
private float dsize = 58;
private float isize = 40;
private float coreAttackTime;
private float lastCoreHP;
private float coreAttackOpacity = 0f;
public void build(Group parent){
@@ -155,11 +157,16 @@ public class HudFragment extends Fragment{
}
lastCoreHP = curr;
t.getColor().a = Mathf.clamp(coreAttackTime / 30f);
t.getColor().a = coreAttackOpacity;
if(coreAttackTime > 0){
coreAttackOpacity = Mathf.lerpDelta(coreAttackOpacity, 1f, 0.1f);
}else{
coreAttackOpacity = Mathf.lerpDelta(coreAttackOpacity, 0f, 0.1f);
}
coreAttackTime -= Timers.delta();
return coreAttackTime > 0;
return coreAttackOpacity > 0;
});
t.table("clear", top -> top.add("$text.coreattack").pad(6)
.update(label -> label.setColor(Hue.mix(Color.ORANGE, Color.SCARLET, Mathf.absin(Timers.time(), 2f, 1f)))));

View File

@@ -40,6 +40,7 @@ import java.io.IOException;
public class UnitPad extends Block{
protected float gracePeriodMultiplier = 16f;
protected float speedupTime = 60f * 60f * 16;
protected float maxSpeedup = 7f;
protected UnitType type;
protected float produceTime = 1000f;
@@ -165,7 +166,7 @@ public class UnitPad extends Block{
}
//check if grace period had passed
}else if(entity.warmup > produceTime*gracePeriodMultiplier * Vars.state.difficulty.spawnerScaling){
float speedMultiplier = Math.min(0.1f + (entity.warmup - produceTime * gracePeriodMultiplier * Vars.state.difficulty.spawnerScaling) / speedupTime, 4f);
float speedMultiplier = Math.min(0.1f + (entity.warmup - produceTime * gracePeriodMultiplier * Vars.state.difficulty.spawnerScaling) / speedupTime, maxSpeedup);
//otherwise, it's an enemy, cheat by not requiring resources
entity.buildTime += Timers.delta() * speedMultiplier;
entity.speedScl = Mathf.lerpDelta(entity.speedScl, 1f, 0.05f);