Crash fixes / Resource-steal fixed / No-build while shooting fixed

This commit is contained in:
Anuken
2018-08-14 12:16:21 -04:00
parent 2ae5c96690
commit 59ec09e82c
7 changed files with 15 additions and 18 deletions

View File

@@ -365,9 +365,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
public void drawOver(){
if(dead) return;
if(!isShooting()){
drawBuilding(this);
}
drawBuilding(this);
if(mech.flying || boostHeat > 0.001f){
float wobblyness = 0.6f;
@@ -478,9 +476,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
avoidOthers(8f);
}
if(!isShooting()){
updateBuilding(this);
}
updateBuilding(this);
x = Mathf.clamp(x, 0, world.width() * tilesize);
y = Mathf.clamp(y, 0, world.height() * tilesize);

View File

@@ -189,6 +189,7 @@ public class NetworkIO{
Map currentMap = new Map(map, new MapMeta(0, new ObjectMap<>(), width, height, null), true, () -> null);
currentMap.meta.tags.clear();
currentMap.meta.tags.putAll(tags);
world.setSector(null);
world.setMap(currentMap);
Tile[][] tiles = world.createTiles(width, height);

View File

@@ -121,7 +121,7 @@ public abstract class BaseBlock{
Tile other = proximity.get((i + dump) % proximity.size);
Tile in = Edges.getFacingEdge(tile, other);
if(other.block().hasLiquids && canDumpLiquid(tile, other, liquid)){
if(other.getTeamID() == tile.getTeamID() && other.block().hasLiquids && canDumpLiquid(tile, other, liquid)){
float ofract = other.entity.liquids.get(liquid) / other.block().liquidCapacity;
float fract = tile.entity.liquids.get(liquid) / liquidCapacity;
@@ -149,7 +149,7 @@ public abstract class BaseBlock{
next = next.target();
if(next.block().hasLiquids && tile.entity.liquids.get(liquid) > 0f){
if(next.getTeamID() == tile.getTeamID() && next.block().hasLiquids && tile.entity.liquids.get(liquid) > 0f){
if(next.block().acceptLiquid(next, tile, liquid, 0f)){
float ofract = next.entity.liquids.get(liquid) / next.block().liquidCapacity;
@@ -199,7 +199,7 @@ public abstract class BaseBlock{
incrementDump(tile, proximity.size);
Tile other = proximity.get((i + dump) % proximity.size);
Tile in = Edges.getFacingEdge(tile, other);
if(other.block().acceptItem(item, other, in) && canDump(tile, other, item)){
if(other.getTeamID() == tile.getTeamID() && other.block().acceptItem(item, other, in) && canDump(tile, other, item)){
other.block().handleItem(item, other, in);
return;
}
@@ -239,7 +239,7 @@ public abstract class BaseBlock{
for(int ii = 0; ii < Item.all().size; ii++){
Item item = Item.getByID(ii);
if(entity.items.has(item) && other.block().acceptItem(item, other, in) && canDump(tile, other, item)){
if(other.getTeamID() == tile.getTeamID() && entity.items.has(item) && other.block().acceptItem(item, other, in) && canDump(tile, other, item)){
other.block().handleItem(item, other, in);
tile.entity.items.remove(item, 1);
incrementDump(tile, proximity.size);
@@ -248,7 +248,7 @@ public abstract class BaseBlock{
}
}else{
if(other.block().acceptItem(todump, other, in) && canDump(tile, other, todump)){
if(other.getTeamID() == tile.getTeamID() && other.block().acceptItem(todump, other, in) && canDump(tile, other, todump)){
other.block().handleItem(todump, other, in);
tile.entity.items.remove(todump, 1);
incrementDump(tile, proximity.size);
@@ -274,7 +274,7 @@ public abstract class BaseBlock{
/** Try offloading an item to a nearby container in its facing direction. Returns true if success.*/
public boolean offloadDir(Tile tile, Item item){
Tile other = tile.getNearby(tile.getRotation());
if(other != null && other.block().acceptItem(item, other, tile)){
if(other != null && other.getTeamID() == tile.getTeamID() && other.block().acceptItem(item, other, tile)){
other.block().handleItem(item, other, tile);
return true;
}

View File

@@ -225,7 +225,7 @@ public class BuildBlock extends Block{
int accumulated = (int) (accumulator[i]); //get amount
if(amount > 0){ //if it's positive, add it to the core
if(amount > 0 && accumulated > 0){ //if it's positive, add it to the core
int accepting = core.tile.block().acceptStack(requirements[i].item, accumulated, core.tile, builder);
core.tile.block().handleStack(requirements[i].item, accepting, core.tile, builder);

View File

@@ -53,7 +53,7 @@ public class PowerDistributor extends PowerBlock{
protected boolean shouldDistribute(Tile tile, Tile other){
other = other.target();
//only generators can distribute to other generators
return (!(other.block() instanceof PowerGenerator) || tile.block() instanceof PowerGenerator)
return other.getTeamID() == tile.getTeamID() && (!(other.block() instanceof PowerGenerator) || tile.block() instanceof PowerGenerator)
&& other.entity != null
&& other.block().hasPower
&& other.entity.power.amount / other.block().powerCapacity < tile.entity.power.amount / powerCapacity;

View File

@@ -60,7 +60,7 @@ public class PowerNode extends PowerBlock{
entity.links.add(other.packedPosition());
}
if(other.block() instanceof PowerNode){
if(other.getTeamID() == tile.getTeamID() && other.block() instanceof PowerNode){
DistributorEntity oe = other.entity();
if(!oe.links.contains(tile.packedPosition())){
@@ -224,12 +224,12 @@ public class PowerNode extends PowerBlock{
}
protected boolean shouldDistribute(Tile tile, Tile other){
return other.entity.power.amount / other.block().powerCapacity <= tile.entity.power.amount / powerCapacity &&
return other.getTeamID() == tile.getTeamID() && other.entity.power.amount / other.block().powerCapacity <= tile.entity.power.amount / powerCapacity &&
!(other.block() instanceof PowerGenerator); //do not distribute to power generators
}
protected boolean shouldLeechPower(Tile tile, Tile other){
return !(other.block() instanceof PowerNode)
return other.getTeamID() == tile.getTeamID() && !(other.block() instanceof PowerNode)
&& other.block() instanceof PowerDistributor //only suck power from batteries and power generators
&& other.entity.power.amount / other.block().powerCapacity > tile.entity.power.amount / powerCapacity;
}

View File

@@ -103,7 +103,7 @@ public class CoreBlock extends StorageBlock{
@Override
public float handleDamage(Tile tile, float amount){
return amount;
return debug ? 0 : amount;
}
@Override