Massive amount of bugfixes / Multi-liquid support / Broken build

This commit is contained in:
Anuken
2018-07-06 23:24:14 -04:00
parent 64f1fbe400
commit d988bb1821
74 changed files with 633 additions and 511 deletions
@@ -9,6 +9,7 @@ import com.badlogic.gdx.utils.Queue;
import io.anuke.annotations.Annotations.Loc;
import io.anuke.annotations.Annotations.Remote;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.content.Mechs;
import io.anuke.mindustry.entities.effect.ItemDrop;
import io.anuke.mindustry.entities.effect.ScorchDecal;
import io.anuke.mindustry.entities.traits.*;
@@ -660,6 +661,8 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
dead = true;
trail.clear();
health = maxHealth();
mech = (mobile ? Mechs.starterMobile : Mechs.starterDesktop);
placeQueue.clear();
add();
}
@@ -1,6 +1,7 @@
package io.anuke.mindustry.entities;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import io.anuke.annotations.Annotations.Loc;
import io.anuke.annotations.Annotations.Remote;
import io.anuke.mindustry.content.fx.Fx;
@@ -10,11 +11,12 @@ import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.gen.CallBlocks;
import io.anuke.mindustry.net.In;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.consumers.Consume;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.Wall;
import io.anuke.mindustry.world.blocks.modules.InventoryModule;
import io.anuke.mindustry.world.blocks.modules.LiquidModule;
import io.anuke.mindustry.world.blocks.modules.PowerModule;
import io.anuke.mindustry.world.modules.InventoryModule;
import io.anuke.mindustry.world.modules.LiquidModule;
import io.anuke.mindustry.world.modules.PowerModule;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.entities.EntityGroup;
@@ -42,6 +44,8 @@ public class TileEntity extends BaseEntity implements TargetTrait {
public InventoryModule items;
public LiquidModule liquids;
public Array<Consume> consumers = new Array<>();
private boolean dead = false;
private boolean sleeping;
private float sleepTime;
@@ -55,14 +59,10 @@ public class TileEntity extends BaseEntity implements TargetTrait {
health = tile.block().health;
timer = new Timer(tile.block().timers);
tile.block().setConsumers(consumers);
if(added){
//if(!tile.block().autoSleep) { //TODO only autosleep when creating a fresh block!
add();
/*}else{
sleeping = true;
sleepingEntities ++;
}*/
add();
}
return this;
@@ -160,6 +160,9 @@ public class TileEntity extends BaseEntity implements TargetTrait {
}
tile.block().update(tile);
for(Consume cons : consumers){
cons.update(this);
}
}
}
@@ -197,6 +197,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
}
public void avoidOthers(float avoidRange){
if(Net.client()) return;
EntityPhysics.getNearby(getGroup(), x, y, avoidRange*2f, t -> {
if(t == this || (t instanceof Unit && (((Unit) t).isDead() || (((Unit) t).isFlying() != isFlying()) || ((Unit) t).getCarrier() == this) || getCarrier() == t)) return;
@@ -57,7 +57,7 @@ public class ItemTransfer extends TimedEntity implements DrawTrait{
for (int i = 0; i < Mathf.clamp(amount/3, 1, 8); i++) {
Timers.run(i*3, () -> create(item, x, y, tile, () -> {}));
}
tile.entity.items.addItem(item, amount);
tile.entity.items.add(item, amount);
}
public static void create(Item item, float fromx, float fromy, PosTrait to, Runnable done){
@@ -181,7 +181,7 @@ public class Drone extends FlyingUnit implements BuilderTrait {
if(entity == null){
return;
}
targetItem = Mathf.findMin(toMine, (a, b) -> -Integer.compare(entity.items.getItem(a), entity.items.getItem(b)));
targetItem = Mathf.findMin(toMine, (a, b) -> -Integer.compare(entity.items.get(a), entity.items.get(b)));
}
protected boolean findItemDrop(){
@@ -247,7 +247,7 @@ public class Drone extends FlyingUnit implements BuilderTrait {
//if it's missing requirements, try and mine them
for(ItemStack stack : entity.recipe.requirements){
if(!core.items.hasItem(stack.item, stack.amount) && toMine.contains(stack.item)){
if(!core.items.has(stack.item, stack.amount) && toMine.contains(stack.item)){
targetItem = stack.item;
getPlaceQueue().clear();
setState(mine);