mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-14 01:37:36 +07:00
Fixed some power/save/pathfinding bugs
This commit is contained in:
@ -66,7 +66,7 @@ public class Pathfinder{
|
|||||||
if(other == null) continue;
|
if(other == null) continue;
|
||||||
|
|
||||||
if(values[dx][dy] < value && (target == null || values[dx][dy] < tl) &&
|
if(values[dx][dy] < value && (target == null || values[dx][dy] < tl) &&
|
||||||
!other.solid() &&
|
!other.solid() && other.floor().drownTime <= 0 &&
|
||||||
!(point.x != 0 && point.y != 0 && (world.solid(tile.x + point.x, tile.y) || world.solid(tile.x, tile.y + point.y)))){ //diagonal corner trap
|
!(point.x != 0 && point.y != 0 && (world.solid(tile.x + point.x, tile.y) || world.solid(tile.x, tile.y + point.y)))){ //diagonal corner trap
|
||||||
target = other;
|
target = other;
|
||||||
tl = values[dx][dy];
|
tl = values[dx][dy];
|
||||||
|
@ -7,7 +7,7 @@ import io.anuke.arc.collection.IntSet;
|
|||||||
import io.anuke.arc.graphics.Color;
|
import io.anuke.arc.graphics.Color;
|
||||||
import io.anuke.arc.math.RandomXS128;
|
import io.anuke.arc.math.RandomXS128;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.arc.util.io.ReusableByteArrayInputStream;
|
import io.anuke.arc.util.io.ReusableByteInStream;
|
||||||
import io.anuke.arc.util.serialization.Base64Coder;
|
import io.anuke.arc.util.serialization.Base64Coder;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
@ -50,7 +50,7 @@ public class NetClient implements ApplicationListener{
|
|||||||
/** List of entities that were removed, and need not be added while syncing. */
|
/** List of entities that were removed, and need not be added while syncing. */
|
||||||
private IntSet removed = new IntSet();
|
private IntSet removed = new IntSet();
|
||||||
/** Byte stream for reading in snapshots. */
|
/** Byte stream for reading in snapshots. */
|
||||||
private ReusableByteArrayInputStream byteStream = new ReusableByteArrayInputStream();
|
private ReusableByteInStream byteStream = new ReusableByteInStream();
|
||||||
private DataInputStream dataStream = new DataInputStream(byteStream);
|
private DataInputStream dataStream = new DataInputStream(byteStream);
|
||||||
|
|
||||||
public NetClient(){
|
public NetClient(){
|
||||||
|
@ -13,7 +13,7 @@ import io.anuke.arc.math.geom.Rectangle;
|
|||||||
import io.anuke.arc.math.geom.Vector2;
|
import io.anuke.arc.math.geom.Vector2;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.arc.util.io.ByteBufferOutput;
|
import io.anuke.arc.util.io.ByteBufferOutput;
|
||||||
import io.anuke.arc.util.io.CountableByteArrayOutputStream;
|
import io.anuke.arc.util.io.ReusableByteOutStream;
|
||||||
import io.anuke.mindustry.content.Blocks;
|
import io.anuke.mindustry.content.Blocks;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.entities.Entities;
|
import io.anuke.mindustry.entities.Entities;
|
||||||
@ -56,7 +56,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
private ByteBufferOutput outputBuffer = new ByteBufferOutput(writeBuffer);
|
private ByteBufferOutput outputBuffer = new ByteBufferOutput(writeBuffer);
|
||||||
|
|
||||||
/** Stream for writing player sync data to. */
|
/** Stream for writing player sync data to. */
|
||||||
private CountableByteArrayOutputStream syncStream = new CountableByteArrayOutputStream();
|
private ReusableByteOutStream syncStream = new ReusableByteOutStream();
|
||||||
/** Data stream for writing player sync data to. */
|
/** Data stream for writing player sync data to. */
|
||||||
private DataOutputStream dataStream = new DataOutputStream(syncStream);
|
private DataOutputStream dataStream = new DataOutputStream(syncStream);
|
||||||
|
|
||||||
|
@ -433,15 +433,17 @@ public class Block extends BlockStorage{
|
|||||||
}else{
|
}else{
|
||||||
current = entity -> entity.liquids.current();
|
current = entity -> entity.liquids.current();
|
||||||
}
|
}
|
||||||
bars.add("liquid", entity -> new Bar(() -> entity.liquids.get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.liquid") : current.get(entity).localizedName(), () -> current.get(entity).color, () -> entity.liquids.get(current.get(entity)) / liquidCapacity));
|
bars.add("liquid", entity -> new Bar(() -> entity.liquids.get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.liquid") : current.get(entity).localizedName(),
|
||||||
|
() -> current.get(entity).color, () -> entity.liquids.get(current.get(entity)) / liquidCapacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasPower && consumes.hasPower()){
|
if(hasPower && consumes.hasPower()){
|
||||||
boolean buffered = consumes.getPower().buffered;
|
ConsumePower cons = consumes.getPower();
|
||||||
float capacity = consumes.getPower().capacity;
|
boolean buffered = cons.buffered;
|
||||||
|
float capacity = cons.capacity;
|
||||||
|
|
||||||
bars.add("power", entity -> new Bar(() -> buffered ? Core.bundle.format("bar.poweramount", Float.isNaN(entity.power.satisfaction * capacity) ? "<ERROR>" : (int)(entity.power.satisfaction * capacity)) :
|
bars.add("power", entity -> new Bar(() -> buffered ? Core.bundle.format("bar.poweramount", Float.isNaN(entity.power.satisfaction * capacity) ? "<ERROR>" : (int)(entity.power.satisfaction * capacity)) :
|
||||||
Core.bundle.get("bar.power"), () -> Pal.powerBar, () -> entity.power.satisfaction));
|
Core.bundle.get("bar.power"), () -> Pal.powerBar, () -> Mathf.isZero(cons.requestedPower(entity)) && entity.power.graph.getPowerProduced() + entity.power.graph.getBatteryStored() > 0f ? 1f : entity.power.satisfaction));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasItems && configurable){
|
if(hasItems && configurable){
|
||||||
|
@ -382,7 +382,7 @@ public class Tile implements Position, TargetTrait{
|
|||||||
Point2 point = Geometry.d8[i];
|
Point2 point = Geometry.d8[i];
|
||||||
Tile tile = world.tile(x + point.x, y + point.y);
|
Tile tile = world.tile(x + point.x, y + point.y);
|
||||||
if(tile != null && tile.floor.isLiquid){
|
if(tile != null && tile.floor.isLiquid){
|
||||||
cost += 3;
|
cost += 4;
|
||||||
}
|
}
|
||||||
if(tile != null && tile.solid()){
|
if(tile != null && tile.solid()){
|
||||||
occluded = true;
|
occluded = true;
|
||||||
@ -390,17 +390,35 @@ public class Tile implements Position, TargetTrait{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//+24
|
||||||
|
|
||||||
if(occluded){
|
if(occluded){
|
||||||
cost += 2;
|
cost += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//+26
|
||||||
|
|
||||||
if(target().synthetic()){
|
if(target().synthetic()){
|
||||||
cost += Mathf.clamp(target().block().health / 10f, 0, 20);
|
cost += Mathf.clamp(target().block().health / 10f, 0, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//+46
|
||||||
|
|
||||||
if(floor.isLiquid){
|
if(floor.isLiquid){
|
||||||
cost += 10;
|
cost += 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//+56
|
||||||
|
|
||||||
|
if(floor.drownTime > 0){
|
||||||
|
cost += 70;
|
||||||
|
}
|
||||||
|
|
||||||
|
//+126
|
||||||
|
|
||||||
|
if(cost < 0){
|
||||||
|
cost = Byte.MAX_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void preChanged(){
|
protected void preChanged(){
|
||||||
|
@ -26,8 +26,8 @@ public abstract class PowerTurret extends CooledTurret{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasAmmo(Tile tile){
|
public boolean hasAmmo(Tile tile){
|
||||||
//only shoot if there's power
|
//you can always rotate, but never shoot if there's no power
|
||||||
return tile.entity.cons.valid();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -37,6 +37,6 @@ public abstract class PowerTurret extends CooledTurret{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float baseReloadSpeed(Tile tile){
|
protected float baseReloadSpeed(Tile tile){
|
||||||
return tile.entity.power.satisfaction;
|
return tile.isEnemyCheat() ? 1f : tile.entity.power.satisfaction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,6 @@ public class UnitFactory extends Block{
|
|||||||
entity.cons.trigger();
|
entity.cons.trigger();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaximumAccepted(Tile tile, Item item){
|
public int getMaximumAccepted(Tile tile, Item item){
|
||||||
return capacities[item.id];
|
return capacities[item.id];
|
||||||
@ -198,6 +197,7 @@ public class UnitFactory extends Block{
|
|||||||
@Override
|
@Override
|
||||||
public void write(DataOutput stream) throws IOException{
|
public void write(DataOutput stream) throws IOException{
|
||||||
stream.writeFloat(buildTime);
|
stream.writeFloat(buildTime);
|
||||||
|
stream.writeFloat(0f);
|
||||||
stream.writeInt(spawned);
|
stream.writeInt(spawned);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user