mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-10 10:47:13 +07:00
Bugfixes / Allow placing blocks in shallow liquids
This commit is contained in:
parent
4cb92cdb06
commit
8f5f27755d
Binary file not shown.
Binary file not shown.
@ -88,6 +88,14 @@ public class EditorTile extends Tile{
|
||||
protected void changed(){
|
||||
entity = null;
|
||||
|
||||
if(wall == null){
|
||||
wall = Blocks.air;
|
||||
}
|
||||
|
||||
if(floor == null){
|
||||
floor = (Floor)Blocks.air;
|
||||
}
|
||||
|
||||
Block block = block();
|
||||
|
||||
if(block.hasEntity()){
|
||||
|
@ -166,7 +166,7 @@ public class WaveInfoDialog extends FloatingDialog{
|
||||
t.table(p -> {
|
||||
p.add("$waves.every").padRight(4);
|
||||
p.addField(group.spacing + "", TextFieldFilter.digitsOnly, text -> {
|
||||
if(Strings.canParsePostiveInt(text)){
|
||||
if(Strings.canParsePostiveInt(text) && Strings.parseInt(text) > 0){
|
||||
group.spacing = Strings.parseInt(text);
|
||||
updateWaves();
|
||||
}
|
||||
@ -228,7 +228,7 @@ public class WaveInfoDialog extends FloatingDialog{
|
||||
dialog.hide();
|
||||
buildGroups();
|
||||
}).pad(2).margin(12f).fillX();
|
||||
if(++i % 2 == 0)dialog.cont.row();
|
||||
if(++i % 3 == 0)dialog.cont.row();
|
||||
}
|
||||
dialog.show();
|
||||
}
|
||||
|
@ -69,25 +69,25 @@ public class MapIO{
|
||||
|
||||
public static Pixmap generatePreview(Map map) throws IOException{
|
||||
Time.mark();
|
||||
Pixmap floor = new Pixmap(map.width, map.height, Format.RGBA8888);
|
||||
Pixmap wall = new Pixmap(map.width, map.height, Format.RGBA8888);
|
||||
Pixmap floors = new Pixmap(map.width, map.height, Format.RGBA8888);
|
||||
Pixmap walls = new Pixmap(map.width, map.height, Format.RGBA8888);
|
||||
int black = Color.rgba8888(Color.BLACK);
|
||||
CachedTile tile = new CachedTile(){
|
||||
@Override
|
||||
public void setFloor(Floor type){
|
||||
floor.drawPixel(x, floor.getHeight() - 1 - y, colorFor(type, Blocks.air, Blocks.air, getTeam()));
|
||||
floors.drawPixel(x, floors.getHeight() - 1 - y, colorFor(type, Blocks.air, Blocks.air, getTeam()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOreByte(byte b){
|
||||
if(b != 0) floor.drawPixel(x, floor.getHeight() - 1 - y, colorFor(floor(), Blocks.air, content.block(b), getTeam()));
|
||||
if(b != 0) floors.drawPixel(x, floors.getHeight() - 1 - y, colorFor(floor(), Blocks.air, content.block(b), getTeam()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void changed(){
|
||||
super.changed();
|
||||
int c = colorFor(Blocks.air, block(), Blocks.air, getTeam());
|
||||
if(c != black) wall.drawPixel(x, floor.getHeight() - 1 - y, c);
|
||||
if(c != black) walls.drawPixel(x, floors.getHeight() - 1 - y, c);
|
||||
}
|
||||
};
|
||||
readTiles(map, (x, y) -> {
|
||||
@ -95,9 +95,9 @@ public class MapIO{
|
||||
tile.y = (short)y;
|
||||
return tile;
|
||||
});
|
||||
floor.drawPixmap(wall, 0, 0);
|
||||
wall.dispose();
|
||||
return floor;
|
||||
floors.drawPixmap(walls, 0, 0);
|
||||
walls.dispose();
|
||||
return floors;
|
||||
}
|
||||
|
||||
public static Pixmap generatePreview(Tile[][] tiles){
|
||||
|
@ -16,13 +16,13 @@ import io.anuke.arc.scene.ui.ImageButton;
|
||||
import io.anuke.arc.scene.ui.TextButton;
|
||||
import io.anuke.arc.scene.ui.layout.Stack;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.scene.ui.layout.Unit;
|
||||
import io.anuke.arc.scene.utils.Elements;
|
||||
import io.anuke.arc.util.Align;
|
||||
import io.anuke.arc.util.Scaling;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.arc.util.Tmp;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.game.EventType.PlayEvent;
|
||||
import io.anuke.mindustry.game.EventType.StateChangeEvent;
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
@ -49,16 +49,6 @@ public class HudFragment extends Fragment{
|
||||
private float coreAttackTime;
|
||||
private float lastCoreHP;
|
||||
private float coreAttackOpacity = 0f;
|
||||
private Table goshDarnHeckingFlippedTableWhyDoesThisHappen;
|
||||
|
||||
{
|
||||
Events.on(PlayEvent.class, event -> {
|
||||
if(goshDarnHeckingFlippedTableWhyDoesThisHappen != null){
|
||||
goshDarnHeckingFlippedTableWhyDoesThisHappen.invalidateHierarchy();
|
||||
goshDarnHeckingFlippedTableWhyDoesThisHappen.pack();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void build(Group parent){
|
||||
|
||||
@ -67,8 +57,13 @@ public class HudFragment extends Fragment{
|
||||
cont.top().left().visible(() -> !state.is(State.menu));
|
||||
|
||||
if(mobile){
|
||||
cont.table(select -> {
|
||||
goshDarnHeckingFlippedTableWhyDoesThisHappen = select;
|
||||
|
||||
{
|
||||
Table select = new Table(){
|
||||
public float getPrefWidth(){ return Unit.dp.scl(dsize*4 + 3); }
|
||||
public float getPrefHeight(){ return Unit.dp.scl(dsize); }
|
||||
};
|
||||
|
||||
select.left();
|
||||
select.defaults().size(dsize).left();
|
||||
|
||||
@ -111,7 +106,8 @@ public class HudFragment extends Fragment{
|
||||
}).get();
|
||||
|
||||
select.addImage("blank").color(Pal.accent).width(3f).fillY();
|
||||
}).left();
|
||||
cont.add(select).prefSize(dsize*4 + 3, dsize).left();
|
||||
}
|
||||
|
||||
cont.row();
|
||||
cont.addImage("blank").height(3f).color(Pal.accent).fillX();
|
||||
|
@ -153,7 +153,7 @@ public class Build{
|
||||
Tile other = world.tile(x + dx + offsetx, y + dy + offsety);
|
||||
if(other == null || (other.block() != Blocks.air && !other.block().alwaysReplace) ||
|
||||
!other.floor().placeableOn ||
|
||||
(other.floor().isLiquid && !type.floating)){
|
||||
(other.floor().isDeep() && !type.floating)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -162,7 +162,7 @@ public class Build{
|
||||
}else{
|
||||
return tile.interactable(team)
|
||||
&& contactsGround(tile.x, tile.y, type)
|
||||
&& (!tile.floor().isLiquid || type.floating)
|
||||
&& (!tile.floor().isDeep() || type.floating)
|
||||
&& tile.floor().placeableOn
|
||||
&& ((type.canReplace(tile.block())
|
||||
&& !(type == tile.block() && rotation == tile.getRotation() && type.rotate)) || tile.block().alwaysReplace || tile.block() == Blocks.air)
|
||||
@ -174,19 +174,19 @@ public class Build{
|
||||
if(block.isMultiblock()){
|
||||
for(Point2 point : Edges.getInsideEdges(block.size)){
|
||||
Tile tile = world.tile(x + point.x, y + point.y);
|
||||
if(tile != null && !tile.floor().isLiquid) return true;
|
||||
if(tile != null && !tile.floor().isDeep()) return true;
|
||||
}
|
||||
|
||||
for(Point2 point : Edges.getEdges(block.size)){
|
||||
Tile tile = world.tile(x + point.x, y + point.y);
|
||||
if(tile != null && !tile.floor().isLiquid) return true;
|
||||
if(tile != null && !tile.floor().isDeep()) return true;
|
||||
}
|
||||
}else{
|
||||
for(Point2 point : Geometry.d4){
|
||||
Tile tile = world.tile(x + point.x, y + point.y);
|
||||
if(tile != null && !tile.floor().isLiquid) return true;
|
||||
if(tile != null && !tile.floor().isDeep()) return true;
|
||||
}
|
||||
return world.tile(x, y) != null && !world.tile(x, y).floor().isLiquid;
|
||||
return world.tile(x, y) != null && !world.tile(x, y).floor().isDeep();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -34,8 +34,8 @@ public class Tile implements Position, TargetTrait{
|
||||
/** Tile entity, usually null. */
|
||||
public TileEntity entity;
|
||||
public short x, y;
|
||||
private Block wall;
|
||||
private Floor floor;
|
||||
protected Block wall;
|
||||
protected Floor floor;
|
||||
/** Rotation, 0-3. Also used to store offload location, in which case it can be any number. */
|
||||
private byte rotation;
|
||||
/** Team ordinal. */
|
||||
|
@ -118,6 +118,9 @@ public class Floor extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDeep(){
|
||||
return drownTime > 0;
|
||||
}
|
||||
|
||||
public void drawNonLayer(Tile tile){
|
||||
Mathf.random.setSeed(tile.pos());
|
||||
|
@ -198,7 +198,7 @@ public class ServerControl implements ApplicationListener{
|
||||
|
||||
if(lastTask != null) lastTask.cancel();
|
||||
|
||||
Map result = world.maps.all().find(map -> map.name().equalsIgnoreCase(arg[0]));
|
||||
Map result = world.maps.all().find(map -> map.name().equalsIgnoreCase(arg[0].replace('_', ' ')));
|
||||
|
||||
if(result == null){
|
||||
err("No map with name &y'{0}'&lr found.", arg[0]);
|
||||
|
Loading…
Reference in New Issue
Block a user