Editor map fix / Crafter renderer system
|
Before Width: | Height: | Size: 191 B After Width: | Height: | Size: 283 B |
|
Before Width: | Height: | Size: 766 B After Width: | Height: | Size: 772 B |
|
Before Width: | Height: | Size: 632 KiB After Width: | Height: | Size: 632 KiB |
|
Before Width: | Height: | Size: 126 KiB After Width: | Height: | Size: 131 KiB |
|
Before Width: | Height: | Size: 258 KiB After Width: | Height: | Size: 279 KiB |
|
Before Width: | Height: | Size: 285 KiB After Width: | Height: | Size: 286 KiB |
|
Before Width: | Height: | Size: 905 KiB After Width: | Height: | Size: 916 KiB |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 126 KiB After Width: | Height: | Size: 131 KiB |
|
Before Width: | Height: | Size: 252 KiB After Width: | Height: | Size: 271 KiB |
|
Before Width: | Height: | Size: 278 KiB After Width: | Height: | Size: 282 KiB |
|
Before Width: | Height: | Size: 955 KiB After Width: | Height: | Size: 962 KiB |
@@ -5,7 +5,6 @@ import arc.graphics.*;
|
|||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.*;
|
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.bullet.*;
|
import mindustry.entities.bullet.*;
|
||||||
@@ -28,6 +27,7 @@ import mindustry.world.blocks.sandbox.*;
|
|||||||
import mindustry.world.blocks.storage.*;
|
import mindustry.world.blocks.storage.*;
|
||||||
import mindustry.world.blocks.units.*;
|
import mindustry.world.blocks.units.*;
|
||||||
import mindustry.world.consumers.*;
|
import mindustry.world.consumers.*;
|
||||||
|
import mindustry.world.draw.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
public class Blocks implements ContentList{
|
public class Blocks implements ContentList{
|
||||||
@@ -527,19 +527,11 @@ public class Blocks implements ContentList{
|
|||||||
hasPower = hasLiquids = true;
|
hasPower = hasLiquids = true;
|
||||||
craftEffect = Fx.formsmoke;
|
craftEffect = Fx.formsmoke;
|
||||||
updateEffect = Fx.plasticburn;
|
updateEffect = Fx.plasticburn;
|
||||||
|
drawer = new DrawGlow();
|
||||||
|
|
||||||
consumes.liquid(Liquids.oil, 0.25f);
|
consumes.liquid(Liquids.oil, 0.25f);
|
||||||
consumes.power(3f);
|
consumes.power(3f);
|
||||||
consumes.item(Items.titanium, 2);
|
consumes.item(Items.titanium, 2);
|
||||||
|
|
||||||
int topRegion = re("-top");
|
|
||||||
|
|
||||||
drawer = entity -> {
|
|
||||||
Draw.rect(region, entity.x(), entity.y());
|
|
||||||
Draw.alpha(Mathf.absin(entity.totalProgress, 3f, 0.9f) * entity.warmup);
|
|
||||||
Draw.rect(re(topRegion), entity.x(), entity.y());
|
|
||||||
Draw.reset();
|
|
||||||
};
|
|
||||||
}};
|
}};
|
||||||
|
|
||||||
phaseWeaver = new GenericCrafter("phase-weaver"){{
|
phaseWeaver = new GenericCrafter("phase-weaver"){{
|
||||||
@@ -549,32 +541,11 @@ public class Blocks implements ContentList{
|
|||||||
craftTime = 120f;
|
craftTime = 120f;
|
||||||
size = 2;
|
size = 2;
|
||||||
hasPower = true;
|
hasPower = true;
|
||||||
|
drawer = new DrawWeave();
|
||||||
|
|
||||||
consumes.items(new ItemStack(Items.thorium, 4), new ItemStack(Items.sand, 10));
|
consumes.items(new ItemStack(Items.thorium, 4), new ItemStack(Items.sand, 10));
|
||||||
consumes.power(5f);
|
consumes.power(5f);
|
||||||
itemCapacity = 20;
|
itemCapacity = 20;
|
||||||
|
|
||||||
int bottomRegion = re("-bottom"), weaveRegion = re("-weave");
|
|
||||||
|
|
||||||
drawIcons = () -> new TextureRegion[]{Core.atlas.find(name + "-bottom"), Core.atlas.find(name), Core.atlas.find(name + "-weave")};
|
|
||||||
|
|
||||||
drawer = entity -> {
|
|
||||||
Draw.rect(re(bottomRegion), entity.x(), entity.y());
|
|
||||||
Draw.rect(re(weaveRegion), entity.x(), entity.y(), entity.totalProgress);
|
|
||||||
|
|
||||||
Draw.color(Pal.accent);
|
|
||||||
Draw.alpha(entity.warmup);
|
|
||||||
|
|
||||||
Lines.lineAngleCenter(
|
|
||||||
entity.x() + Mathf.sin(entity.totalProgress, 6f, Vars.tilesize / 3f * size),
|
|
||||||
entity.y(),
|
|
||||||
90,
|
|
||||||
size * Vars.tilesize / 2f);
|
|
||||||
|
|
||||||
Draw.reset();
|
|
||||||
|
|
||||||
Draw.rect(region, entity.x(), entity.y());
|
|
||||||
};
|
|
||||||
}};
|
}};
|
||||||
|
|
||||||
surgeSmelter = new GenericSmelter("alloy-smelter"){{
|
surgeSmelter = new GenericSmelter("alloy-smelter"){{
|
||||||
@@ -600,29 +571,11 @@ public class Blocks implements ContentList{
|
|||||||
rotate = false;
|
rotate = false;
|
||||||
solid = true;
|
solid = true;
|
||||||
outputsLiquid = true;
|
outputsLiquid = true;
|
||||||
|
drawer = new DrawMixer();
|
||||||
|
|
||||||
consumes.power(1f);
|
consumes.power(1f);
|
||||||
consumes.item(Items.titanium);
|
consumes.item(Items.titanium);
|
||||||
consumes.liquid(Liquids.water, 0.2f);
|
consumes.liquid(Liquids.water, 0.2f);
|
||||||
|
|
||||||
int liquidRegion = re("-liquid"), topRegion = re("-top"), bottomRegion = re("-bottom");
|
|
||||||
|
|
||||||
drawIcons = () -> new TextureRegion[]{Core.atlas.find(name + "-bottom"), Core.atlas.find(name + "-top")};
|
|
||||||
|
|
||||||
drawer = entity -> {
|
|
||||||
float rotation = rotate ? entity.rotdeg() : 0;
|
|
||||||
|
|
||||||
Draw.rect(re(bottomRegion), entity.x(), entity.y(), rotation);
|
|
||||||
|
|
||||||
if(entity.liquids().total() > 0.001f){
|
|
||||||
Draw.color(outputLiquid.liquid.color);
|
|
||||||
Draw.alpha(entity.liquids().get(outputLiquid.liquid) / liquidCapacity);
|
|
||||||
Draw.rect(re(liquidRegion), entity.x(), entity.y(), rotation);
|
|
||||||
Draw.color();
|
|
||||||
}
|
|
||||||
|
|
||||||
Draw.rect(re(topRegion), entity.x(), entity.y(), rotation);
|
|
||||||
};
|
|
||||||
}};
|
}};
|
||||||
|
|
||||||
blastMixer = new GenericCrafter("blast-mixer"){{
|
blastMixer = new GenericCrafter("blast-mixer"){{
|
||||||
@@ -704,27 +657,10 @@ public class Blocks implements ContentList{
|
|||||||
hasLiquids = true;
|
hasLiquids = true;
|
||||||
hasPower = true;
|
hasPower = true;
|
||||||
craftEffect = Fx.none;
|
craftEffect = Fx.none;
|
||||||
|
drawer = new DrawAnimation();
|
||||||
|
|
||||||
consumes.item(Items.sporePod, 1);
|
consumes.item(Items.sporePod, 1);
|
||||||
consumes.power(0.60f);
|
consumes.power(0.60f);
|
||||||
|
|
||||||
int[] frameRegions = new int[3];
|
|
||||||
for(int i = 0; i < 3; i++){
|
|
||||||
frameRegions[i] = re("-frame" + i);
|
|
||||||
}
|
|
||||||
|
|
||||||
int liquidRegion = re("-liquid");
|
|
||||||
int topRegion = re("-top");
|
|
||||||
|
|
||||||
drawIcons = () -> new TextureRegion[]{Core.atlas.find(name), Core.atlas.find(name + "-top")};
|
|
||||||
drawer = entity -> {
|
|
||||||
Draw.rect(region, entity.x(), entity.y());
|
|
||||||
Draw.rect(re(frameRegions[(int)Mathf.absin(entity.totalProgress, 5f, 2.999f)]), entity.x(), entity.y());
|
|
||||||
Draw.color(Color.clear, entity.liquids().current().color, entity.liquids().total() / liquidCapacity);
|
|
||||||
Draw.rect(re(liquidRegion), entity.x(), entity.y());
|
|
||||||
Draw.color();
|
|
||||||
Draw.rect(re(topRegion), entity.x(), entity.y());
|
|
||||||
};
|
|
||||||
}};
|
}};
|
||||||
|
|
||||||
pulverizer = new GenericCrafter("pulverizer"){{
|
pulverizer = new GenericCrafter("pulverizer"){{
|
||||||
@@ -734,18 +670,10 @@ public class Blocks implements ContentList{
|
|||||||
craftTime = 40f;
|
craftTime = 40f;
|
||||||
updateEffect = Fx.pulverizeSmall;
|
updateEffect = Fx.pulverizeSmall;
|
||||||
hasItems = hasPower = true;
|
hasItems = hasPower = true;
|
||||||
|
drawer = new DrawRotator();
|
||||||
|
|
||||||
consumes.item(Items.scrap, 1);
|
consumes.item(Items.scrap, 1);
|
||||||
consumes.power(0.50f);
|
consumes.power(0.50f);
|
||||||
|
|
||||||
int rotatorRegion = re("-rotator");
|
|
||||||
|
|
||||||
drawIcons = () -> new TextureRegion[]{Core.atlas.find(name), Core.atlas.find(name + "-rotator")};
|
|
||||||
|
|
||||||
drawer = entity -> {
|
|
||||||
Draw.rect(region, entity.x(), entity.y());
|
|
||||||
Draw.rect(re(rotatorRegion), entity.x(), entity.y(), entity.totalProgress * 2f);
|
|
||||||
};
|
|
||||||
}};
|
}};
|
||||||
|
|
||||||
coalCentrifuge = new GenericCrafter("coal-centrifuge"){{
|
coalCentrifuge = new GenericCrafter("coal-centrifuge"){{
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ public class MapRenderer implements Disposable{
|
|||||||
region = !Core.atlas.isFound(wall.editorIcon()) ? Core.atlas.find("clear-editor") : wall.editorIcon();
|
region = !Core.atlas.isFound(wall.editorIcon()) ? Core.atlas.find("clear-editor") : wall.editorIcon();
|
||||||
offsetX = tilesize / 2f - region.getWidth() / 2f * Draw.scl;
|
offsetX = tilesize / 2f - region.getWidth() / 2f * Draw.scl;
|
||||||
offsetY = tilesize / 2f - region.getHeight() / 2f * Draw.scl;
|
offsetY = tilesize / 2f - region.getHeight() / 2f * Draw.scl;
|
||||||
}else if(wall == Blocks.air){
|
}else if(wall == Blocks.air && !tile.overlay().isAir()){
|
||||||
region = tile.overlay().editorVariantRegions()[Mathf.randomSeed(idxWall, 0, tile.overlay().editorVariantRegions().length - 1)];
|
region = tile.overlay().editorVariantRegions()[Mathf.randomSeed(idxWall, 0, tile.overlay().editorVariantRegions().length - 1)];
|
||||||
}else{
|
}else{
|
||||||
region = Core.atlas.find("clear-editor");
|
region = Core.atlas.find("clear-editor");
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import mindustry.type.*;
|
|||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.*;
|
||||||
import mindustry.world.consumers.*;
|
import mindustry.world.consumers.*;
|
||||||
|
import mindustry.world.draw.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
@@ -143,6 +144,11 @@ public class ContentParser{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//try to load DrawBlock by instantiating it
|
||||||
|
if(type == DrawBlock.class && jsonData.isString()){
|
||||||
|
return Reflect.make("mindustry.world.draw." + Strings.capitalize(jsonData.asString()));
|
||||||
|
}
|
||||||
|
|
||||||
if(Content.class.isAssignableFrom(type)){
|
if(Content.class.isAssignableFrom(type)){
|
||||||
ContentType ctype = contentTypes.getThrow(type, () -> new IllegalArgumentException("No content type for class: " + type.getSimpleName()));
|
ContentType ctype = contentTypes.getThrow(type, () -> new IllegalArgumentException("No content type for class: " + type.getSimpleName()));
|
||||||
String prefix = currentMod != null ? currentMod.name + "-" : "";
|
String prefix = currentMod != null ? currentMod.name + "-" : "";
|
||||||
|
|||||||
@@ -173,7 +173,6 @@ public class Block extends UnlockableContent{
|
|||||||
public boolean instantTransfer = false;
|
public boolean instantTransfer = false;
|
||||||
|
|
||||||
protected Prov<Tilec> entityType = null; //initialized later
|
protected Prov<Tilec> entityType = null; //initialized later
|
||||||
//TODO move
|
|
||||||
public ObjectMap<Class<?>, Cons2> configurations = new ObjectMap<>();
|
public ObjectMap<Class<?>, Cons2> configurations = new ObjectMap<>();
|
||||||
|
|
||||||
//TODO move
|
//TODO move
|
||||||
@@ -181,10 +180,6 @@ public class Block extends UnlockableContent{
|
|||||||
protected TextureRegion[] variantRegions, editorVariantRegions;
|
protected TextureRegion[] variantRegions, editorVariantRegions;
|
||||||
public TextureRegion region, editorIcon;
|
public TextureRegion region, editorIcon;
|
||||||
|
|
||||||
//TODO remove completely
|
|
||||||
protected TextureRegion[] cacheRegions = {};
|
|
||||||
protected Seq<String> cacheRegionStrings = new Seq<>();
|
|
||||||
|
|
||||||
//TODO move
|
//TODO move
|
||||||
public static TextureRegion[][] cracks;
|
public static TextureRegion[][] cracks;
|
||||||
protected static final Seq<Tile> tempTiles = new Seq<>();
|
protected static final Seq<Tile> tempTiles = new Seq<>();
|
||||||
@@ -200,7 +195,6 @@ public class Block extends UnlockableContent{
|
|||||||
initEntity();
|
initEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO rename to draw() once class refactoring is done.
|
|
||||||
public void drawBase(Tile tile){
|
public void drawBase(Tile tile){
|
||||||
//delegates to entity unless it is null
|
//delegates to entity unless it is null
|
||||||
if(tile.entity != null){
|
if(tile.entity != null){
|
||||||
@@ -574,19 +568,6 @@ public class Block extends UnlockableContent{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Adds a region by name to be loaded, with the final name "{name}-suffix". Returns an ID to looks this region up by in {@link #re(int)}.
|
|
||||||
* DO NOT USE. This will eventually be removed. */
|
|
||||||
protected int re(String suffix){
|
|
||||||
cacheRegionStrings.add(name + suffix);
|
|
||||||
return cacheRegionStrings.size - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns an internally cached region by ID.
|
|
||||||
* DO NOT USE. This will eventually be removed*/
|
|
||||||
protected TextureRegion re(int id){
|
|
||||||
return cacheRegions[id];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void displayInfo(Table table){
|
public void displayInfo(Table table){
|
||||||
ContentDisplay.displayBlock(table, this);
|
ContentDisplay.displayBlock(table, this);
|
||||||
@@ -631,11 +612,6 @@ public class Block extends UnlockableContent{
|
|||||||
public void load(){
|
public void load(){
|
||||||
region = Core.atlas.find(name);
|
region = Core.atlas.find(name);
|
||||||
|
|
||||||
cacheRegions = new TextureRegion[cacheRegionStrings.size];
|
|
||||||
for(int i = 0; i < cacheRegions.length; i++){
|
|
||||||
cacheRegions[i] = Core.atlas.find(cacheRegionStrings.get(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(cracks == null || (cracks[0][0].getTexture() != null && cracks[0][0].getTexture().isDisposed())){
|
if(cracks == null || (cracks[0][0].getTexture() != null && cracks[0][0].getTexture().isDisposed())){
|
||||||
cracks = new TextureRegion[maxCrackSize][crackRegions];
|
cracks = new TextureRegion[maxCrackSize][crackRegions];
|
||||||
for(int size = 1; size <= maxCrackSize; size++){
|
for(int size = 1; size <= maxCrackSize; size++){
|
||||||
|
|||||||
@@ -160,6 +160,11 @@ public class Floor extends Block{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextureRegion[] icons(){
|
||||||
|
return new TextureRegion[]{Core.atlas.find(Core.atlas.has(name) ? name : name + "1")};
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isDeep(){
|
public boolean isDeep(){
|
||||||
return drownTime > 0;
|
return drownTime > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package mindustry.world.blocks.production;
|
package mindustry.world.blocks.production;
|
||||||
|
|
||||||
import arc.func.*;
|
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.util.io.*;
|
import arc.util.io.*;
|
||||||
@@ -10,6 +9,7 @@ import mindustry.gen.*;
|
|||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.consumers.*;
|
import mindustry.world.consumers.*;
|
||||||
|
import mindustry.world.draw.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
public class GenericCrafter extends Block{
|
public class GenericCrafter extends Block{
|
||||||
@@ -21,8 +21,10 @@ public class GenericCrafter extends Block{
|
|||||||
public Effect updateEffect = Fx.none;
|
public Effect updateEffect = Fx.none;
|
||||||
public float updateEffectChance = 0.04f;
|
public float updateEffectChance = 0.04f;
|
||||||
|
|
||||||
public Cons<GenericCrafterEntity> drawer = null;
|
public DrawBlock drawer = new DrawBlock();
|
||||||
public Prov<TextureRegion[]> drawIcons = null;
|
|
||||||
|
//public Cons<GenericCrafterEntity> drawer = null;
|
||||||
|
//public Prov<TextureRegion[]> drawIcons = null;
|
||||||
|
|
||||||
public GenericCrafter(String name){
|
public GenericCrafter(String name){
|
||||||
super(name);
|
super(name);
|
||||||
@@ -54,6 +56,13 @@ public class GenericCrafter extends Block{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(){
|
||||||
|
super.load();
|
||||||
|
|
||||||
|
drawer.load(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(){
|
public void init(){
|
||||||
outputsLiquid = outputLiquid != null;
|
outputsLiquid = outputLiquid != null;
|
||||||
@@ -62,7 +71,7 @@ public class GenericCrafter extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TextureRegion[] icons(){
|
public TextureRegion[] icons(){
|
||||||
return drawIcons == null ? super.icons() : drawIcons.get();
|
return drawer.icons(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -77,11 +86,7 @@ public class GenericCrafter extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
if(drawer == null){
|
drawer.draw(this);
|
||||||
super.draw();
|
|
||||||
}else{
|
|
||||||
drawer.get(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
46
core/src/mindustry/world/draw/DrawAnimation.java
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package mindustry.world.draw;
|
||||||
|
|
||||||
|
import arc.*;
|
||||||
|
import arc.graphics.*;
|
||||||
|
import arc.graphics.g2d.*;
|
||||||
|
import arc.math.*;
|
||||||
|
import mindustry.world.*;
|
||||||
|
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||||
|
|
||||||
|
public class DrawAnimation extends DrawBlock{
|
||||||
|
public int frameCount = 3;
|
||||||
|
public float frameSpeed = 5f;
|
||||||
|
public boolean sine = true;
|
||||||
|
public TextureRegion[] frames;
|
||||||
|
public TextureRegion liquid, top;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(GenericCrafterEntity entity){
|
||||||
|
Draw.rect(entity.block.region, entity.x, entity.y);
|
||||||
|
Draw.rect(
|
||||||
|
sine ?
|
||||||
|
frames[(int)Mathf.absin(entity.totalProgress, frameSpeed, frameCount - 0.001f)] :
|
||||||
|
frames[(int)((entity.totalProgress / frameSpeed) % frameCount)],
|
||||||
|
entity.x, entity.y);
|
||||||
|
Draw.color(Color.clear, entity.liquids.current().color, entity.liquids.total() / entity.block.liquidCapacity);
|
||||||
|
Draw.rect(liquid, entity.x, entity.y);
|
||||||
|
Draw.color();
|
||||||
|
Draw.rect(top, entity.x, entity.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(Block block){
|
||||||
|
frames = new TextureRegion[frameCount];
|
||||||
|
for(int i = 0; i < frameCount; i++){
|
||||||
|
frames[i] = Core.atlas.find(block.name + "-frame" + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
liquid = Core.atlas.find(block.name + "-liquid");
|
||||||
|
top = Core.atlas.find(block.name + "-top");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextureRegion[] icons(Block block){
|
||||||
|
return new TextureRegion[]{block.region, top};
|
||||||
|
}
|
||||||
|
}
|
||||||
25
core/src/mindustry/world/draw/DrawBlock.java
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package mindustry.world.draw;
|
||||||
|
|
||||||
|
import arc.graphics.g2d.*;
|
||||||
|
import mindustry.world.*;
|
||||||
|
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||||
|
|
||||||
|
/** An implementation of custom rendering behavior for a block.
|
||||||
|
* This is used mostly for mods. */
|
||||||
|
public class DrawBlock{
|
||||||
|
|
||||||
|
/** Draws the block. */
|
||||||
|
public void draw(GenericCrafterEntity entity){
|
||||||
|
Draw.rect(entity.block.region, entity.x, entity.y, entity.block.rotate ? entity.rotdeg() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Load any relevant texture regions. */
|
||||||
|
public void load(Block block){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return the generated icons to be used for this block. */
|
||||||
|
public TextureRegion[] icons(Block block){
|
||||||
|
return new TextureRegion[]{block.region};
|
||||||
|
}
|
||||||
|
}
|
||||||
25
core/src/mindustry/world/draw/DrawGlow.java
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package mindustry.world.draw;
|
||||||
|
|
||||||
|
import arc.*;
|
||||||
|
import arc.graphics.g2d.*;
|
||||||
|
import arc.math.*;
|
||||||
|
import mindustry.world.*;
|
||||||
|
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||||
|
|
||||||
|
public class DrawGlow extends DrawBlock{
|
||||||
|
public float glowAmount = 0.9f, glowScale = 3f;
|
||||||
|
public TextureRegion top;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(GenericCrafterEntity entity){
|
||||||
|
Draw.rect(entity.block.region, entity.x, entity.y);
|
||||||
|
Draw.alpha(Mathf.absin(entity.totalProgress, glowScale, glowAmount) * entity.warmup);
|
||||||
|
Draw.rect(top, entity.x, entity.y);
|
||||||
|
Draw.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(Block block){
|
||||||
|
top = Core.atlas.find(block.name + "-top");
|
||||||
|
}
|
||||||
|
}
|
||||||
39
core/src/mindustry/world/draw/DrawMixer.java
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
package mindustry.world.draw;
|
||||||
|
|
||||||
|
import arc.*;
|
||||||
|
import arc.graphics.g2d.*;
|
||||||
|
import mindustry.world.*;
|
||||||
|
import mindustry.world.blocks.production.*;
|
||||||
|
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||||
|
|
||||||
|
public class DrawMixer extends DrawBlock{
|
||||||
|
public TextureRegion liquid, top, bottom;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(GenericCrafterEntity entity){
|
||||||
|
float rotation = entity.block.rotate ? entity.rotdeg() : 0;
|
||||||
|
|
||||||
|
Draw.rect(bottom, entity.x, entity.y, rotation);
|
||||||
|
|
||||||
|
if(entity.liquids.total() > 0.001f){
|
||||||
|
Draw.color(((GenericCrafter)entity.block).outputLiquid.liquid.color);
|
||||||
|
Draw.alpha(entity.liquids.get(((GenericCrafter)entity.block).outputLiquid.liquid) / entity.block.liquidCapacity);
|
||||||
|
Draw.rect(liquid, entity.x, entity.y, rotation);
|
||||||
|
Draw.color();
|
||||||
|
}
|
||||||
|
|
||||||
|
Draw.rect(top, entity.x, entity.y, rotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(Block block){
|
||||||
|
liquid = Core.atlas.find(block.name + "-liquid");
|
||||||
|
top = Core.atlas.find(block.name + "-top");
|
||||||
|
bottom = Core.atlas.find(block.name + "-bottom");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextureRegion[] icons(Block block){
|
||||||
|
return new TextureRegion[]{bottom, top};
|
||||||
|
}
|
||||||
|
}
|
||||||
26
core/src/mindustry/world/draw/DrawRotator.java
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package mindustry.world.draw;
|
||||||
|
|
||||||
|
import arc.*;
|
||||||
|
import arc.graphics.g2d.*;
|
||||||
|
import mindustry.world.*;
|
||||||
|
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||||
|
|
||||||
|
public class DrawRotator extends DrawBlock{
|
||||||
|
public TextureRegion rotator;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(GenericCrafterEntity entity){
|
||||||
|
Draw.rect(entity.block.region, entity.x, entity.y);
|
||||||
|
Draw.rect(rotator, entity.x, entity.y, entity.totalProgress * 2f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(Block block){
|
||||||
|
rotator = Core.atlas.find(block.name + "-rotator");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextureRegion[] icons(Block block){
|
||||||
|
return new TextureRegion[]{block.region, rotator};
|
||||||
|
}
|
||||||
|
}
|
||||||
43
core/src/mindustry/world/draw/DrawWeave.java
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package mindustry.world.draw;
|
||||||
|
|
||||||
|
import arc.*;
|
||||||
|
import arc.graphics.g2d.*;
|
||||||
|
import arc.math.*;
|
||||||
|
import mindustry.*;
|
||||||
|
import mindustry.graphics.*;
|
||||||
|
import mindustry.world.*;
|
||||||
|
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||||
|
|
||||||
|
public class DrawWeave extends DrawBlock{
|
||||||
|
public TextureRegion weave, bottom;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(GenericCrafterEntity entity){
|
||||||
|
Draw.rect(bottom, entity.x(), entity.y());
|
||||||
|
Draw.rect(weave, entity.x(), entity.y(), entity.totalProgress);
|
||||||
|
|
||||||
|
Draw.color(Pal.accent);
|
||||||
|
Draw.alpha(entity.warmup);
|
||||||
|
|
||||||
|
Lines.lineAngleCenter(
|
||||||
|
entity.x() + Mathf.sin(entity.totalProgress, 6f, Vars.tilesize / 3f * entity.block.size),
|
||||||
|
entity.y(),
|
||||||
|
90,
|
||||||
|
entity.block.size * Vars.tilesize / 2f);
|
||||||
|
|
||||||
|
Draw.reset();
|
||||||
|
|
||||||
|
Draw.rect(entity.block.region, entity.x, entity.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(Block block){
|
||||||
|
weave = Core.atlas.find(block.name + "-weave");
|
||||||
|
bottom = Core.atlas.find(block.name + "-bottom");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextureRegion[] icons(Block block){
|
||||||
|
return new TextureRegion[]{bottom, block.region, weave};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,9 @@ import mindustry.tools.ImagePacker.*;
|
|||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
import mindustry.world.blocks.*;
|
||||||
import mindustry.world.blocks.environment.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
|
import mindustry.world.blocks.legacy.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
@@ -99,6 +101,8 @@ public class Generators{
|
|||||||
Image colors = new Image(content.blocks().size, 1);
|
Image colors = new Image(content.blocks().size, 1);
|
||||||
|
|
||||||
for(Block block : content.blocks()){
|
for(Block block : content.blocks()){
|
||||||
|
if(block.isAir() || block instanceof BuildBlock || block instanceof OreBlock || block instanceof LegacyBlock) continue;
|
||||||
|
|
||||||
block.load();
|
block.load();
|
||||||
|
|
||||||
TextureRegion[] regions = block.getGeneratedIcons();
|
TextureRegion[] regions = block.getGeneratedIcons();
|
||||||
|
|||||||