Colored wall block
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 760 B |
@@ -611,3 +611,4 @@
|
||||
63071=crux-floor-8|block-crux-floor-8-ui
|
||||
63070=crux-floor-9|block-crux-floor-9-ui
|
||||
63069=crux-floor-10|block-crux-floor-10-ui
|
||||
63068=colored-wall|block-colored-wall-ui
|
||||
|
||||
@@ -58,8 +58,14 @@ public class Blocks{
|
||||
//boulders
|
||||
shaleBoulder, sandBoulder, daciteBoulder, boulder, snowBoulder, basaltBoulder, carbonBoulder, ferricBoulder, beryllicBoulder, yellowStoneBoulder,
|
||||
arkyicBoulder, crystalCluster, vibrantCrystalCluster, crystalBlocks, crystalOrbs, crystallineBoulder, redIceBoulder, rhyoliteBoulder, redStoneBoulder,
|
||||
|
||||
metalFloor, metalFloorDamaged, metalFloor2, metalFloor3, metalFloor4, metalFloor5, basalt, magmarock, hotrock, snowWall, saltWall,
|
||||
darkPanel1, darkPanel2, darkPanel3, darkPanel4, darkPanel5, darkPanel6, darkMetal, cruxFloor1, cruxFloor2, cruxFloor3, cruxFloor4, cruxFloor5, cruxFloor6, cruxFloor7, cruxFloor8, cruxFloor9, cruxFloor10, coloredFloor,
|
||||
//new metal floors
|
||||
darkPanel1, darkPanel2, darkPanel3, darkPanel4, darkPanel5, darkPanel6, darkMetal, cruxFloor1, cruxFloor2, cruxFloor3, cruxFloor4, cruxFloor5, cruxFloor6, cruxFloor7, cruxFloor8, cruxFloor9, cruxFloor10,
|
||||
|
||||
//colored
|
||||
coloredFloor, coloredWall,
|
||||
|
||||
pebbles, tendrils,
|
||||
|
||||
//ores
|
||||
@@ -883,6 +889,14 @@ public class Blocks{
|
||||
inEditor = false;
|
||||
}};
|
||||
|
||||
coloredWall = new ColoredWall("colored-wall"){{
|
||||
autotile = true;
|
||||
//there is no proper support for displaying colors or placing with colors
|
||||
inEditor = false;
|
||||
//TODO: should this apply darkness?
|
||||
//fillsTile = false;
|
||||
}};
|
||||
|
||||
Seq.with(metalFloor, metalFloorDamaged, metalFloor2, metalFloor3, metalFloor4, metalFloor5, darkPanel1, darkPanel2, darkPanel3, darkPanel4, darkPanel5, darkPanel6)
|
||||
.each(b -> b.asFloor().wall = darkMetal);
|
||||
|
||||
|
||||
@@ -566,6 +566,11 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
return forceDark;
|
||||
}
|
||||
|
||||
/** If true, the 'map edge' darkness will be applied to this block. */
|
||||
public boolean isDarkened(Tile tile){
|
||||
return solid && ((!synthetic() && fillsTile) || checkForceDark(tile));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
@@ -940,6 +945,9 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
return (envEnabled & env) != 0 && (envDisabled & env) == 0 && (envRequired == 0 || (envRequired & env) == envRequired);
|
||||
}
|
||||
|
||||
/** Called when this block is set on the specified tile. */
|
||||
public void blockChanged(Tile tile){}
|
||||
|
||||
/** Called when building of this block begins. */
|
||||
public void placeBegan(Tile tile, Block previous){
|
||||
|
||||
@@ -951,7 +959,7 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
}
|
||||
|
||||
/** Called when building of this block ends. */
|
||||
public void placeEnded(Tile tile, @Nullable Unit builder){
|
||||
public void placeEnded(Tile tile, @Nullable Unit builder, @Nullable Object config){
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
}
|
||||
|
||||
public boolean isDarkened(){
|
||||
return block.solid && ((!block.synthetic() && block.fillsTile) || block.checkForceDark(this));
|
||||
return block.isDarkened(this);
|
||||
}
|
||||
|
||||
public Floor floor(){
|
||||
@@ -280,6 +280,8 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
|
||||
changed();
|
||||
changing = false;
|
||||
|
||||
block.blockChanged(this);
|
||||
}
|
||||
|
||||
public void setBlock(Block type, Team team){
|
||||
|
||||
@@ -77,10 +77,8 @@ public class ConstructBlock extends Block{
|
||||
|
||||
if(block instanceof OverlayFloor overlay){
|
||||
tile.setOverlay(overlay);
|
||||
overlay.placed(tile, config);
|
||||
}else if(block instanceof Floor floor){
|
||||
tile.setFloor(floor);
|
||||
floor.placed(tile, config);
|
||||
}else{
|
||||
tile.setBlock(block, team, rotation);
|
||||
}
|
||||
@@ -114,7 +112,7 @@ public class ConstructBlock extends Block{
|
||||
if(shouldPlay()) block.placeSound.at(tile, block.placePitchChange ? calcPitch(true) : 1f);
|
||||
}
|
||||
|
||||
block.placeEnded(tile, builder);
|
||||
block.placeEnded(tile, builder, config);
|
||||
|
||||
Events.fire(new BlockBuildEndEvent(tile, builder, team, false, config));
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
|
||||
@@ -135,7 +136,7 @@ public class ColoredFloor extends Floor{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placed(Tile tile, @Nullable Object config){
|
||||
public void placeEnded(Tile tile, @Nullable Unit builder, @Nullable Object config){
|
||||
//config is assumed to be an integer RGBA color
|
||||
if(config instanceof Integer i){
|
||||
tile.extraData = i;
|
||||
|
||||
74
core/src/mindustry/world/blocks/environment/ColoredWall.java
Normal file
74
core/src/mindustry/world/blocks/environment/ColoredWall.java
Normal file
@@ -0,0 +1,74 @@
|
||||
package mindustry.world.blocks.environment;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class ColoredWall extends StaticWall{
|
||||
/** If the alpha value of the color is set to this value, different colors are ignored and no border is drawn. */
|
||||
public static final int flagIgnoreDifferentColor = 1;
|
||||
/** If the alpha value of the color is set to this value, the wall will have darkness applied, as other walls do. */
|
||||
public static final int flagApplyDarkness = 2;
|
||||
|
||||
public Color defaultColor = Color.white;
|
||||
protected int defaultColorRgba;
|
||||
|
||||
public ColoredWall(String name){
|
||||
super(name);
|
||||
saveData = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
super.init();
|
||||
defaultColorRgba = defaultColor.rgba();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBase(Tile tile){
|
||||
//make sure to mask out the alpha channel - it's generally undesirable, and leads to invisible blocks when the data is not initialized
|
||||
Draw.color(tile.extraData | 0xff);
|
||||
super.drawBase(tile);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blockChanged(Tile tile){
|
||||
//reset to white
|
||||
tile.extraData = defaultColorRgba;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeEnded(Tile tile, @Nullable Unit builder, @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.block() == this && ((tile.extraData & flagIgnoreDifferentColor) != 0 || tile.extraData == other.extraData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDarkened(Tile tile){
|
||||
return (tile.extraData & flagApplyDarkness) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int minimapColor(Tile tile){
|
||||
return tile.extraData | 0xff;
|
||||
}
|
||||
}
|
||||
@@ -290,9 +290,6 @@ 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;
|
||||
|
||||
@@ -44,7 +44,7 @@ public class RemoveOre extends OverlayFloor{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeEnded(Tile tile, @Nullable Unit builder){
|
||||
public void placeEnded(Tile tile, @Nullable Unit builder, Object config){
|
||||
tile.setOverlay(Blocks.air);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public class RemoveWall extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeEnded(Tile tile, @Nullable Unit builder){
|
||||
public void placeEnded(Tile tile, @Nullable Unit builder, Object config){
|
||||
tile.setBlock(Blocks.air);
|
||||
if(tile.overlay().wallOre){
|
||||
tile.setOverlay(Blocks.air);
|
||||
|
||||
@@ -4,6 +4,7 @@ import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.graphics.*;
|
||||
@@ -40,7 +41,7 @@ public class StaticWall extends Prop{
|
||||
|
||||
for(int i = 0; i < 8; i++){
|
||||
Tile other = tile.nearby(Geometry.d8[i]);
|
||||
if(other != null && other.block() == this){
|
||||
if(checkAutotileSame(tile, other)){
|
||||
bits |= (1 << i);
|
||||
}
|
||||
}
|
||||
@@ -65,6 +66,10 @@ public class StaticWall extends Prop{
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkAutotileSame(Tile tile, @Nullable Tile other){
|
||||
return other != null && other.block() == this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
Reference in New Issue
Block a user