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
//region erekir - flying
/*
avert = new ErekirUnitType("avert"){{
lowAltitude = false;
flying = true;
@@ -2936,8 +2935,6 @@ public class UnitTypes{
);
}};
*/
quell = new ErekirUnitType("quell"){{
aiController = FlyingFollowAI::new;
envDisabled = 0;
@@ -36,16 +36,17 @@ public class MinimapRenderer{
});
Events.on(TileChangeEvent.class, event -> {
//TODO don't update when the minimap is off?
if(!ui.editor.isShown()){
update(event.tile);
//update floor below block.
if(event.tile.block().solid && event.tile.y > 0){
Tile tile = world.tile(event.tile.x, event.tile.y - 1);
if(tile.block() == Blocks.air){
update(tile);
}
if(event.tile.block().solid && event.tile.y > 0 && event.tile.isCenter()){
event.tile.getLinkedTiles(t -> {
Tile tile = world.tile(t.x, t.y - 1);
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
if(block.isMultiblock()){
int offsetx = -(block.size - 1) / 2;
int offsety = -(block.size - 1) / 2;
int offset = -(block.size - 1) / 2;
Building entity = this.build;
Block block = this.block;
@@ -245,8 +244,8 @@ public class Tile implements Position, QuadTreeObject, Displayable{
for(int pass = 0; pass < 2; pass++){
for(int dx = 0; dx < block.size; dx++){
for(int dy = 0; dy < block.size; dy++){
int worldx = dx + offsetx + x;
int worldy = dy + offsety + y;
int worldx = dx + offset + x;
int worldy = dy + offset + y;
if(!(worldx == x && worldy == y)){
Tile other = world.tile(worldx, worldy);
@@ -434,12 +433,10 @@ public class Tile implements Position, QuadTreeObject, Displayable{
*/
public void getLinkedTiles(Cons<Tile> cons){
if(block.isMultiblock()){
int size = block.size;
int offsetx = -(size - 1) / 2;
int offsety = -(size - 1) / 2;
int size = block.size, o = block.sizeOffset;
for(int dx = 0; dx < size; dx++){
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);
}
}
@@ -474,11 +471,10 @@ public class Tile implements Position, QuadTreeObject, Displayable{
*/
public void getLinkedTilesAs(Block block, Cons<Tile> tmpArray){
if(block.isMultiblock()){
int offsetx = -(block.size - 1) / 2;
int offsety = -(block.size - 1) / 2;
for(int dx = 0; dx < block.size; dx++){
for(int dy = 0; dy < block.size; dy++){
Tile other = world.tile(x + dx + offsetx, y + dy + offsety);
int size = block.size, o = block.sizeOffset;
for(int dx = 0; dx < size; dx++){
for(int dy = 0; dy < size; dy++){
Tile other = world.tile(x + dx + o, y + dy + o);
if(other != null) tmpArray.get(other);
}
}