Moved rotation to Building

This commit is contained in:
Anuken
2020-07-29 10:19:07 -04:00
parent 749b9f5b30
commit 8729410cd8
49 changed files with 154 additions and 202 deletions

View File

@@ -50,7 +50,7 @@ public class DrawOperation{
}else if(type == OpType.block.ordinal()){
return tile.blockID();
}else if(type == OpType.rotation.ordinal()){
return tile.rotation();
return tile.build == null ? 0 : (byte)tile.build.rotation;
}else if(type == OpType.team.ordinal()){
return (byte)tile.getTeamID();
}else if(type == OpType.overlay.ordinal()){
@@ -65,9 +65,9 @@ public class DrawOperation{
tile.setFloor((Floor)content.block(to));
}else if(type == OpType.block.ordinal()){
Block block = content.block(to);
tile.setBlock(block, tile.team(), tile.rotation());
tile.setBlock(block, tile.team(), tile.build == null ? 0 : tile.build.rotation);
}else if(type == OpType.rotation.ordinal()){
tile.rotation(to);
if(tile.build != null) tile.build.rotation = to;
}else if(type == OpType.team.ordinal()){
tile.setTeam(Team.get(to));
}else if(type == OpType.overlay.ordinal()){

View File

@@ -71,18 +71,6 @@ public class EditorTile extends Tile{
super.setTeam(team);
}
@Override
public void rotation(int rotation){
if(state.isGame()){
super.rotation(rotation);
return;
}
if(rotation == rotation()) return;
op(OpType.rotation, rotation());
super.rotation(rotation);
}
@Override
public void setOverlay(Block overlay){
if(state.isGame()){
@@ -109,9 +97,9 @@ public class EditorTile extends Tile{
}
@Override
protected void changeEntity(Team team, Prov<Building> entityprov){
protected void changeEntity(Team team, Prov<Building> entityprov, int rotation){
if(state.isGame()){
super.changeEntity(team, entityprov);
super.changeEntity(team, entityprov, rotation);
return;
}
@@ -123,7 +111,7 @@ public class EditorTile extends Tile{
Block block = block();
if(block.hasEntity()){
build = entityprov.get().init(this, team, false);
build = entityprov.get().init(this, team, false, rotation);
build.cons(new ConsumeModule(build));
if(block.hasItems) build.items = new ItemModule();
if(block.hasLiquids) build.liquids(new LiquidModule());

View File

@@ -6,6 +6,7 @@ import arc.graphics.*;
import arc.math.*;
import arc.struct.*;
import mindustry.content.*;
import mindustry.editor.DrawOperation.*;
import mindustry.game.*;
import mindustry.gen.*;
import mindustry.io.*;
@@ -140,8 +141,9 @@ public class MapEditor{
if(drawBlock.synthetic()){
tile.setTeam(drawTeam);
}
if(drawBlock.rotate){
tile.rotation((byte)rotation);
if(drawBlock.rotate && tile.build != null && tile.build.rotation != rotation){
addTileOp(TileOp.get(tile.x, tile.y, (byte)OpType.rotation.ordinal(), (byte)rotation));
tile.build.rotation = (byte)rotation;
}
}
};

View File

@@ -51,7 +51,7 @@ public class MapGenerateDialog extends BaseDialog{
private CachedTile ctile = new CachedTile(){
//nothing.
@Override
protected void changeEntity(Team team, Prov<Building> entityprov){
protected void changeEntity(Team team, Prov<Building> entityprov, int rotation){
}
};
@@ -123,7 +123,7 @@ public class MapGenerateDialog extends BaseDialog{
Tile tile = editor.tile(x, y);
input.apply(x, y, tile.floor(), tile.block(), tile.overlay());
filter.apply(input);
writeTiles[x][y].set(input.floor, input.block, input.ore, tile.team(), tile.rotation());
writeTiles[x][y].set(input.floor, input.block, input.ore, tile.team());
}
}
@@ -134,7 +134,6 @@ public class MapGenerateDialog extends BaseDialog{
Tile tile = editor.tile(x, y);
GenTile write = writeTiles[x][y];
tile.rotation(write.rotation);
tile.setFloor((Floor)content.block(write.floor));
tile.setBlock(content.block(write.block));
tile.setTeam(Team.get(write.team));
@@ -365,7 +364,7 @@ public class MapGenerateDialog extends BaseDialog{
GenTile tile = buffer1[px][py];
input.apply(x, y, content.block(tile.floor), content.block(tile.block), content.block(tile.ore));
filter.apply(input);
buffer2[px][py].set(input.floor, input.block, input.ore, Team.get(tile.team), tile.rotation);
buffer2[px][py].set(input.floor, input.block, input.ore, Team.get(tile.team));
});
pixmap.each((px, py) -> buffer1[px][py].set(buffer2[px][py]));
@@ -402,15 +401,14 @@ public class MapGenerateDialog extends BaseDialog{
}
private class GenTile{
public byte team, rotation;
public byte team;
public short block, floor, ore;
public void set(Block floor, Block wall, Block ore, Team team, int rotation){
public void set(Block floor, Block wall, Block ore, Team team){
this.floor = floor.id;
this.block = wall.id;
this.ore = ore.id;
this.team = (byte)team.id;
this.rotation = (byte)rotation;
}
public void set(GenTile other){
@@ -418,11 +416,10 @@ public class MapGenerateDialog extends BaseDialog{
this.block = other.block;
this.ore = other.ore;
this.team = other.team;
this.rotation = other.rotation;
}
public GenTile set(Tile other){
set(other.floor(), other.block(), other.overlay(), other.team(), other.rotation());
set(other.floor(), other.block(), other.overlay(), other.team());
return this;
}
@@ -430,7 +427,6 @@ public class MapGenerateDialog extends BaseDialog{
ctile.setFloor((Floor)content.block(floor));
ctile.setBlock(content.block(block));
ctile.setOverlay(content.block(ore));
ctile.rotation(rotation);
ctile.setTeam(Team.get(team));
return ctile;
}

View File

@@ -113,7 +113,7 @@ public class MapRenderer implements Disposable{
if(wall.rotate){
mesh.draw(idxWall, region,
wx * tilesize + wall.offset, wy * tilesize + wall.offset,
region.getWidth() * Draw.scl, region.getHeight() * Draw.scl, tile.rotdeg() - 90);
region.getWidth() * Draw.scl, region.getHeight() * Draw.scl, tile.build == null ? 0 : tile.build.rotdeg() - 90);
}else{
float width = region.getWidth() * Draw.scl, height = region.getHeight() * Draw.scl;