Functional in-game map edits and loading
This commit is contained in:
@@ -133,10 +133,7 @@ public class EditorTile extends Tile{
|
||||
Block block = block();
|
||||
|
||||
if(block.hasEntity()){
|
||||
entity = block.newEntity();
|
||||
entity.tile = this;
|
||||
entity.block = block;
|
||||
entity.health = block.health;
|
||||
entity = block.newEntity().init(this, false);
|
||||
entity.cons = new ConsumeModule(entity);
|
||||
if(block.hasItems) entity.items = new ItemModule();
|
||||
if(block.hasLiquids) entity.liquids = new LiquidModule();
|
||||
|
||||
@@ -18,6 +18,7 @@ import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.scene.ui.layout.Unit;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.core.Platform;
|
||||
import io.anuke.mindustry.game.Gamemode;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
@@ -26,6 +27,7 @@ import io.anuke.mindustry.maps.Map;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Block.Icon;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.OverlayFloor;
|
||||
import io.anuke.mindustry.world.blocks.storage.CoreBlock;
|
||||
|
||||
@@ -210,6 +212,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
}
|
||||
|
||||
public void resumeEditing(){
|
||||
state.set(State.menu);
|
||||
shownWithMap = true;
|
||||
show();
|
||||
editor.renderer().updateAll();
|
||||
@@ -219,7 +222,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
menu.hide();
|
||||
ui.loadAnd(() -> {
|
||||
hide();
|
||||
//logic.reset();
|
||||
logic.reset();
|
||||
state.rules = Gamemode.editor.get();
|
||||
world.setMap(new Map(StringMap.of(
|
||||
"name", "Editor Playtesting",
|
||||
@@ -227,6 +230,15 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
"height", editor.height()
|
||||
)));
|
||||
world.endMapLoad();
|
||||
//add entities so they update. is this really needed?
|
||||
for(int x = 0; x < world.width(); x++){
|
||||
for(int y = 0; y < world.height(); y++){
|
||||
Tile tile = world.rawTile(x, y);
|
||||
if(tile.entity != null){
|
||||
tile.entity.add();
|
||||
}
|
||||
}
|
||||
}
|
||||
logic.play();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -806,10 +806,15 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
|
||||
}
|
||||
|
||||
public void beginRespawning(SpawnerTrait spawner){
|
||||
this.spawner = spawner;
|
||||
this.lastSpawner = spawner;
|
||||
this.dead = true;
|
||||
setNet(spawner.getX(), spawner.getY());
|
||||
if(state.isEditor()){
|
||||
dead = false;
|
||||
set(spawner.getX(), spawner.getY());
|
||||
}else{
|
||||
this.spawner = spawner;
|
||||
this.lastSpawner = spawner;
|
||||
this.dead = true;
|
||||
setNet(spawner.getX(), spawner.getY());
|
||||
}
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
Reference in New Issue
Block a user