Fixed infinite red square, glitchy shadows
This commit is contained in:
@@ -209,7 +209,9 @@ public class TileEntity extends BaseEntity implements TargetTrait {
|
||||
}
|
||||
|
||||
tile.block().update(tile);
|
||||
cons.update(this);
|
||||
if(cons != null){
|
||||
cons.update(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,12 @@ public interface BuilderTrait extends Entity{
|
||||
/**Build power, can be any float. 1 = builds recipes in normal time, 0 = doesn't build at all.*/
|
||||
float getBuildPower(Tile tile);
|
||||
|
||||
default void writeBuilding(DataOutput output) throws IOException{
|
||||
/**Whether this type of builder can begin creating new blocks.*/
|
||||
default boolean canCreateBlocks(){
|
||||
return true;
|
||||
}
|
||||
|
||||
default void writeBuilding(DataOutput output) throws IOException {
|
||||
BuildRequest request = getCurrentRequest();
|
||||
|
||||
if(request != null){
|
||||
@@ -172,9 +177,9 @@ public interface BuilderTrait extends Entity{
|
||||
Tile tile = world.tile(current.x, current.y);
|
||||
|
||||
if (!(tile.block() instanceof BuildBlock)) {
|
||||
if(!current.remove && Build.validPlace(unit.getTeam(), current.x, current.y, current.recipe.result, current.rotation)) {
|
||||
if(canCreateBlocks() && !current.remove && Build.validPlace(unit.getTeam(), current.x, current.y, current.recipe.result, current.rotation)) {
|
||||
Build.beginPlace(unit.getTeam(), current.x, current.y, current.recipe, current.rotation);
|
||||
}else if(current.remove && Build.validBreak(unit.getTeam(), current.x, current.y)){
|
||||
}else if(canCreateBlocks() && current.remove && Build.validBreak(unit.getTeam(), current.x, current.y)){
|
||||
Build.beginBreak(unit.getTeam(), current.x, current.y);
|
||||
}else{
|
||||
getPlaceQueue().removeFirst();
|
||||
|
||||
@@ -201,6 +201,11 @@ public class Drone extends FlyingUnit implements BuilderTrait {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCreateBlocks() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutput data) throws IOException {
|
||||
super.write(data);
|
||||
|
||||
@@ -10,6 +10,7 @@ import io.anuke.mindustry.entities.traits.TargetTrait;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.world.blocks.Floor;
|
||||
import io.anuke.mindustry.world.modules.ConsumeModule;
|
||||
import io.anuke.mindustry.world.modules.InventoryModule;
|
||||
import io.anuke.mindustry.world.modules.LiquidModule;
|
||||
import io.anuke.mindustry.world.modules.PowerModule;
|
||||
@@ -391,12 +392,13 @@ public class Tile implements PosTrait, TargetTrait {
|
||||
|
||||
if (block.hasEntity()) {
|
||||
entity = block.getEntity().init(this, block.update);
|
||||
if(block.consumes.hasAny()) entity.cons = new ConsumeModule();
|
||||
if(block.hasItems) entity.items = new InventoryModule();
|
||||
if(block.hasLiquids) entity.liquids = new LiquidModule();
|
||||
if(block.hasPower) entity.power = new PowerModule();
|
||||
entity.updateProximity();
|
||||
}
|
||||
|
||||
entity.updateProximity();
|
||||
updateOcclusion();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.world.BarType;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.modules.InventoryModule;
|
||||
import io.anuke.mindustry.world.meta.BlockBar;
|
||||
import io.anuke.mindustry.world.modules.InventoryModule;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
@@ -222,7 +222,7 @@ public class BuildBlock extends Block {
|
||||
progress = Mathf.clamp(progress - amount);
|
||||
|
||||
if(progress <= 0){
|
||||
CallBlocks.onDeconstructFinish(tile, recipe == null ? previous : recipe.result);
|
||||
CallBlocks.onDeconstructFinish(tile, this.recipe == null ? previous : this.recipe.result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public class Rock extends Block {
|
||||
regions = new TextureRegion[variants];
|
||||
|
||||
for (int i = 0; i < variants; i++) {
|
||||
shadowRegions[i] = Draw.region(name + "-shadow" + (i+1));
|
||||
shadowRegions[i] = Draw.region(name + "shadow" + (i+1));
|
||||
regions[i] = Draw.region(name + (i+1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,6 +93,10 @@ public class Consumers {
|
||||
return map.values();
|
||||
}
|
||||
|
||||
public boolean hasAny(){
|
||||
return map.size > 0;
|
||||
}
|
||||
|
||||
public void forEach(Consumer<Consume> cons){
|
||||
for(Consume c : all()){
|
||||
cons.accept(c);
|
||||
|
||||
Reference in New Issue
Block a user