Tiled background for tiled logic display
BIN
core/assets-raw/sprites/blocks/logic/tile-logic-display-back.png
Normal file
|
After Width: | Height: | Size: 121 B |
|
Before Width: | Height: | Size: 121 B After Width: | Height: | Size: 241 B |
|
After Width: | Height: | Size: 394 B |
|
After Width: | Height: | Size: 331 B |
|
After Width: | Height: | Size: 446 B |
|
After Width: | Height: | Size: 402 B |
|
After Width: | Height: | Size: 339 B |
|
After Width: | Height: | Size: 322 B |
|
After Width: | Height: | Size: 335 B |
|
After Width: | Height: | Size: 352 B |
|
After Width: | Height: | Size: 378 B |
|
After Width: | Height: | Size: 452 B |
|
After Width: | Height: | Size: 341 B |
|
After Width: | Height: | Size: 366 B |
|
After Width: | Height: | Size: 350 B |
|
After Width: | Height: | Size: 376 B |
|
After Width: | Height: | Size: 350 B |
|
After Width: | Height: | Size: 415 B |
|
After Width: | Height: | Size: 427 B |
|
After Width: | Height: | Size: 352 B |
|
After Width: | Height: | Size: 331 B |
|
After Width: | Height: | Size: 390 B |
|
After Width: | Height: | Size: 411 B |
|
After Width: | Height: | Size: 392 B |
|
After Width: | Height: | Size: 419 B |
|
After Width: | Height: | Size: 407 B |
|
After Width: | Height: | Size: 370 B |
|
After Width: | Height: | Size: 357 B |
|
After Width: | Height: | Size: 383 B |
|
After Width: | Height: | Size: 401 B |
|
After Width: | Height: | Size: 363 B |
|
After Width: | Height: | Size: 407 B |
|
After Width: | Height: | Size: 407 B |
|
After Width: | Height: | Size: 340 B |
|
After Width: | Height: | Size: 405 B |
|
After Width: | Height: | Size: 466 B |
|
After Width: | Height: | Size: 431 B |
|
After Width: | Height: | Size: 402 B |
|
After Width: | Height: | Size: 394 B |
|
After Width: | Height: | Size: 365 B |
|
After Width: | Height: | Size: 375 B |
|
After Width: | Height: | Size: 378 B |
|
After Width: | Height: | Size: 385 B |
|
After Width: | Height: | Size: 424 B |
|
After Width: | Height: | Size: 372 B |
|
After Width: | Height: | Size: 361 B |
|
After Width: | Height: | Size: 344 B |
|
After Width: | Height: | Size: 353 B |
|
After Width: | Height: | Size: 396 B |
|
|
@ -1983,6 +1983,7 @@ block.logic-processor.name = Logic Processor
|
|||
block.hyper-processor.name = Hyper Processor
|
||||
block.logic-display.name = Logic Display
|
||||
block.large-logic-display.name = Large Logic Display
|
||||
block.tile-logic-display.name = Tiled Logic Display
|
||||
block.memory-cell.name = Memory Cell
|
||||
block.memory-bank.name = Memory Bank
|
||||
|
||||
|
|
@ -2282,6 +2283,7 @@ block.memory-cell.description = Stores information for a logic processor.
|
|||
block.memory-bank.description = Stores information for a logic processor. High capacity.
|
||||
block.logic-display.description = Displays arbitrary graphics from a logic processor.
|
||||
block.large-logic-display.description = Displays arbitrary graphics from a logic processor.
|
||||
block.tile-logic-display.description = Displays arbitrary graphics from a logic processor.\nSeamlessly connects to nearby tiled display blocks.
|
||||
block.interplanetary-accelerator.description = A massive electromagnetic railgun tower. Accelerates cores to escape velocity for interplanetary deployment.
|
||||
block.repair-turret.description = Continuously repairs the closest damaged unit in its vicinity. Optionally accepts coolant.
|
||||
|
||||
|
|
|
|||
|
|
@ -599,3 +599,4 @@
|
|||
63083=landing-pad|block-landing-pad-ui
|
||||
63082=stone-vent|block-stone-vent-ui
|
||||
63081=basalt-vent|block-basalt-vent-ui
|
||||
63080=tile-logic-display|block-tile-logic-display-ui
|
||||
|
|
|
|||
|
|
@ -4,11 +4,14 @@ import arc.*;
|
|||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.graphics.gl.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
|
|
@ -19,6 +22,27 @@ public class TileableLogicDisplay extends LogicDisplay{
|
|||
|
||||
//in tiles
|
||||
public int maxDisplayDimensions = 12;
|
||||
public @Load(value = "@-#", length = 47) TextureRegion[] tileRegion;
|
||||
public @Load("@-back") TextureRegion backRegion;
|
||||
|
||||
static final int[] bitmasks = {
|
||||
39, 36, 39, 36, 27, 16, 27, 24, 39, 36, 39, 36, 27, 16, 27, 24,
|
||||
38, 37, 38, 37, 17, 41, 17, 43, 38, 37, 38, 37, 26, 21, 26, 25,
|
||||
39, 36, 39, 36, 27, 16, 27, 24, 39, 36, 39, 36, 27, 16, 27, 24,
|
||||
38, 37, 38, 37, 17, 41, 17, 43, 38, 37, 38, 37, 26, 21, 26, 25,
|
||||
3, 4, 3, 4, 15, 40, 15, 20, 3, 4, 3, 4, 15, 40, 15, 20,
|
||||
5, 28, 5, 28, 29, 10, 29, 23, 5, 28, 5, 28, 31, 11, 31, 32,
|
||||
3, 4, 3, 4, 15, 40, 15, 20, 3, 4, 3, 4, 15, 40, 15, 20,
|
||||
2, 30, 2, 30, 9, 46, 9, 22, 2, 30, 2, 30, 14, 44, 14, 6,
|
||||
39, 36, 39, 36, 27, 16, 27, 24, 39, 36, 39, 36, 27, 16, 27, 24,
|
||||
38, 37, 38, 37, 17, 41, 17, 43, 38, 37, 38, 37, 26, 21, 26, 25,
|
||||
39, 36, 39, 36, 27, 16, 27, 24, 39, 36, 39, 36, 27, 16, 27, 24,
|
||||
38, 37, 38, 37, 17, 41, 17, 43, 38, 37, 38, 37, 26, 21, 26, 25,
|
||||
3, 0, 3, 0, 15, 42, 15, 12, 3, 0, 3, 0, 15, 42, 15, 12,
|
||||
5, 8, 5, 8, 29, 35, 29, 33, 5, 8, 5, 8, 31, 34, 31, 7,
|
||||
3, 0, 3, 0, 15, 42, 15, 12, 3, 0, 3, 0, 15, 42, 15, 12,
|
||||
2, 1, 2, 1, 9, 45, 9, 19, 2, 1, 2, 1, 14, 18, 14, 13,
|
||||
};
|
||||
|
||||
public TileableLogicDisplay(String name){
|
||||
super(name);
|
||||
|
|
@ -84,6 +108,8 @@ public class TileableLogicDisplay extends LogicDisplay{
|
|||
//size of display area
|
||||
public int tilesWidth = 1, tilesHeight = 1, originX, originY;
|
||||
|
||||
public int bits = 0;
|
||||
|
||||
@Override
|
||||
public void display(Table table){
|
||||
super.display(table);
|
||||
|
|
@ -93,9 +119,23 @@ public class TileableLogicDisplay extends LogicDisplay{
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProximityUpdate(){
|
||||
super.onProximityUpdate();
|
||||
|
||||
bits = 0;
|
||||
|
||||
for(int i = 0; i < 8; i++){
|
||||
Tile other = tile.nearby(Geometry.d8(i));
|
||||
if(other != null && other.block() == block && other.team() == team){
|
||||
bits |= (1 << i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.rect(block.region, x, y);
|
||||
Draw.rect(backRegion, x, y);
|
||||
|
||||
//don't even bother processing anything when displays are off.
|
||||
if(!Vars.renderer.drawDisplays) return;
|
||||
|
|
@ -113,6 +153,9 @@ public class TileableLogicDisplay extends LogicDisplay{
|
|||
processCommands();
|
||||
}
|
||||
|
||||
Draw.z(Layer.block + 0.001f);
|
||||
|
||||
//TODO this is slow, many texture switches
|
||||
Draw.blend(Blending.disabled);
|
||||
Draw.draw(Draw.z(), () -> {
|
||||
if(rootDisplay.buffer != null){
|
||||
|
|
@ -124,6 +167,10 @@ public class TileableLogicDisplay extends LogicDisplay{
|
|||
}
|
||||
});
|
||||
Draw.blend();
|
||||
|
||||
Draw.z(Layer.block + 0.002f);
|
||||
|
||||
Draw.rect(tileRegion[bitmasks[bits]], x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -135,11 +182,22 @@ public class TileableLogicDisplay extends LogicDisplay{
|
|||
}
|
||||
}
|
||||
|
||||
public void updateOthers(){
|
||||
for(int i = 0; i < 4; i++){
|
||||
Tile other = tile.nearby(Geometry.d8edge(i));
|
||||
if(other != null && other.block() == block && other.team() == team){
|
||||
other.build.onProximityUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProximityAdded(){
|
||||
super.onProximityAdded();
|
||||
|
||||
linkDisplays(this);
|
||||
|
||||
updateOthers();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -153,6 +211,8 @@ public class TileableLogicDisplay extends LogicDisplay{
|
|||
linkDisplays(tl);
|
||||
}
|
||||
}
|
||||
|
||||
updateOthers();
|
||||
}
|
||||
|
||||
public boolean isRoot(){
|
||||
|
|
|
|||