Made tiles not clear overlay on setFloor + cleanup/refactor
This commit is contained in:
@@ -77,8 +77,10 @@ public class ConstructBlock extends Block{
|
||||
|
||||
if(block instanceof OverlayFloor overlay){
|
||||
tile.setOverlay(overlay);
|
||||
overlay.placed(tile, config);
|
||||
}else if(block instanceof Floor floor){
|
||||
tile.setFloorUnder(floor);
|
||||
tile.setFloor(floor);
|
||||
floor.placed(tile, config);
|
||||
}else{
|
||||
tile.setBlock(block, team, rotation);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import arc.graphics.g2d.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
|
||||
@@ -133,6 +134,22 @@ public class ColoredFloor extends Floor{
|
||||
tile.extraData = defaultColorRgba;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placed(Tile tile, @Nullable Object config){
|
||||
//config is assumed to be an integer RGBA color
|
||||
if(config instanceof Integer i){
|
||||
tile.extraData = i;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
if(plan.config instanceof Integer i){
|
||||
Draw.tint(Tmp.c1.set(i | 0xff));
|
||||
}
|
||||
drawDefaultPlanRegion(plan, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkAutotileSame(Tile tile, @Nullable Tile other){
|
||||
return other != null && other.floor().blendGroup == blendGroup && ((tile.extraData & 0xff) == flagIgnoreDifferentColor || tile.extraData == other.extraData);
|
||||
|
||||
@@ -275,6 +275,9 @@ public class Floor extends Block{
|
||||
/** Called when this floor is set on the specified tile. */
|
||||
public void floorChanged(Tile tile){}
|
||||
|
||||
/** Called when this floor or overlay is placed on a tile. The config may be null. */
|
||||
public void placed(Tile tile, @Nullable Object config){}
|
||||
|
||||
/** @return whether to index this floor by flag */
|
||||
public boolean shouldIndex(Tile tile){
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user