Editor map fix / Crafter renderer system
This commit is contained in:
46
core/src/mindustry/world/draw/DrawAnimation.java
Normal file
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
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
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
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
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
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};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user