Fixed multiblock minimap shadows

This commit is contained in:
Anuken
2022-02-20 11:55:35 -05:00
parent 989249e7dc
commit 02966a0911
3 changed files with 16 additions and 22 deletions
@@ -2917,7 +2917,6 @@ public class UnitTypes{
//endregion //endregion
//region erekir - flying //region erekir - flying
/*
avert = new ErekirUnitType("avert"){{ avert = new ErekirUnitType("avert"){{
lowAltitude = false; lowAltitude = false;
flying = true; flying = true;
@@ -2936,8 +2935,6 @@ public class UnitTypes{
); );
}}; }};
*/
quell = new ErekirUnitType("quell"){{ quell = new ErekirUnitType("quell"){{
aiController = FlyingFollowAI::new; aiController = FlyingFollowAI::new;
envDisabled = 0; envDisabled = 0;
@@ -36,16 +36,17 @@ public class MinimapRenderer{
}); });
Events.on(TileChangeEvent.class, event -> { Events.on(TileChangeEvent.class, event -> {
//TODO don't update when the minimap is off?
if(!ui.editor.isShown()){ if(!ui.editor.isShown()){
update(event.tile); update(event.tile);
//update floor below block. //update floor below block.
if(event.tile.block().solid && event.tile.y > 0){ if(event.tile.block().solid && event.tile.y > 0 && event.tile.isCenter()){
Tile tile = world.tile(event.tile.x, event.tile.y - 1); event.tile.getLinkedTiles(t -> {
if(tile.block() == Blocks.air){ Tile tile = world.tile(t.x, t.y - 1);
update(tile); if(tile.block() == Blocks.air){
} update(tile);
}
});
} }
} }
}); });
+9 -13
View File
@@ -236,8 +236,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
//set up multiblock //set up multiblock
if(block.isMultiblock()){ if(block.isMultiblock()){
int offsetx = -(block.size - 1) / 2; int offset = -(block.size - 1) / 2;
int offsety = -(block.size - 1) / 2;
Building entity = this.build; Building entity = this.build;
Block block = this.block; Block block = this.block;
@@ -245,8 +244,8 @@ public class Tile implements Position, QuadTreeObject, Displayable{
for(int pass = 0; pass < 2; pass++){ for(int pass = 0; pass < 2; pass++){
for(int dx = 0; dx < block.size; dx++){ for(int dx = 0; dx < block.size; dx++){
for(int dy = 0; dy < block.size; dy++){ for(int dy = 0; dy < block.size; dy++){
int worldx = dx + offsetx + x; int worldx = dx + offset + x;
int worldy = dy + offsety + y; int worldy = dy + offset + y;
if(!(worldx == x && worldy == y)){ if(!(worldx == x && worldy == y)){
Tile other = world.tile(worldx, worldy); Tile other = world.tile(worldx, worldy);
@@ -434,12 +433,10 @@ public class Tile implements Position, QuadTreeObject, Displayable{
*/ */
public void getLinkedTiles(Cons<Tile> cons){ public void getLinkedTiles(Cons<Tile> cons){
if(block.isMultiblock()){ if(block.isMultiblock()){
int size = block.size; int size = block.size, o = block.sizeOffset;
int offsetx = -(size - 1) / 2;
int offsety = -(size - 1) / 2;
for(int dx = 0; dx < size; dx++){ for(int dx = 0; dx < size; dx++){
for(int dy = 0; dy < size; dy++){ for(int dy = 0; dy < size; dy++){
Tile other = world.tile(x + dx + offsetx, y + dy + offsety); Tile other = world.tile(x + dx + o, y + dy + o);
if(other != null) cons.get(other); if(other != null) cons.get(other);
} }
} }
@@ -474,11 +471,10 @@ public class Tile implements Position, QuadTreeObject, Displayable{
*/ */
public void getLinkedTilesAs(Block block, Cons<Tile> tmpArray){ public void getLinkedTilesAs(Block block, Cons<Tile> tmpArray){
if(block.isMultiblock()){ if(block.isMultiblock()){
int offsetx = -(block.size - 1) / 2; int size = block.size, o = block.sizeOffset;
int offsety = -(block.size - 1) / 2; for(int dx = 0; dx < size; dx++){
for(int dx = 0; dx < block.size; dx++){ for(int dy = 0; dy < size; dy++){
for(int dy = 0; dy < block.size; dy++){ Tile other = world.tile(x + dx + o, y + dy + o);
Tile other = world.tile(x + dx + offsetx, y + dy + offsety);
if(other != null) tmpArray.get(other); if(other != null) tmpArray.get(other);
} }
} }