WIP terrible-looking regen projector
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
@@ -15,6 +16,9 @@ import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
public class DrawBlock{
|
||||
protected static final Rand rand = new Rand();
|
||||
|
||||
/** If set, the icon is overridden to be these strings, in order. Each string is a suffix. */
|
||||
public @Nullable String[] iconOverride = null;
|
||||
|
||||
/** @deprecated no longer called! not specific to generic crafters! */
|
||||
@Deprecated
|
||||
public void draw(GenericCrafterBuild build){}
|
||||
@@ -52,6 +56,17 @@ public class DrawBlock{
|
||||
return new TextureRegion[]{block.region};
|
||||
}
|
||||
|
||||
public final TextureRegion[] finalIcons(Block block){
|
||||
if(iconOverride != null){
|
||||
var out = new TextureRegion[iconOverride.length];
|
||||
for(int i = 0; i < out.length; i++){
|
||||
out[i] = Core.atlas.find(block.name + iconOverride[i]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
return icons(block);
|
||||
}
|
||||
|
||||
public GenericCrafter expectCrafter(Block block){
|
||||
if(!(block instanceof GenericCrafter crafter)) throw new ClassCastException("This drawer requires the block to be a GenericCrafter. Use a different drawer.");
|
||||
return crafter;
|
||||
|
||||
@@ -17,6 +17,7 @@ public class DrawGlowRegion extends DrawBlock{
|
||||
public float alpha = 0.9f, glowScale = 10f, glowIntensity = 0.5f;
|
||||
public float rotateSpeed = 0f;
|
||||
public float layer = Layer.blockAdditive;
|
||||
public boolean rotate = false;
|
||||
public Color color = Color.red.cpy();
|
||||
public TextureRegion region;
|
||||
|
||||
@@ -27,6 +28,10 @@ public class DrawGlowRegion extends DrawBlock{
|
||||
this.layer = layer;
|
||||
}
|
||||
|
||||
public DrawGlowRegion(boolean rotate){
|
||||
this.rotate = rotate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBase(Building build){
|
||||
if(build.warmup() <= 0.001f) return;
|
||||
@@ -36,7 +41,7 @@ public class DrawGlowRegion extends DrawBlock{
|
||||
Draw.blend(blending);
|
||||
Draw.color(color);
|
||||
Draw.alpha((Mathf.absin(build.totalProgress(), glowScale, alpha) * glowIntensity + 1f - glowIntensity) * build.warmup() * alpha);
|
||||
Draw.rect(region, build.x, build.y, build.totalProgress() * rotateSpeed);
|
||||
Draw.rect(region, build.x, build.y, build.totalProgress() * rotateSpeed + (rotate ? build.rotdeg() : 0f));
|
||||
Draw.reset();
|
||||
Draw.blend();
|
||||
Draw.z(z);
|
||||
|
||||
45
core/src/mindustry/world/draw/DrawSideRegion.java
Normal file
45
core/src/mindustry/world/draw/DrawSideRegion.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class DrawSideRegion extends DrawBlock{
|
||||
public boolean drawRegion = false;
|
||||
public TextureRegion top1, top2;
|
||||
|
||||
public DrawSideRegion(){
|
||||
}
|
||||
|
||||
public DrawSideRegion(boolean drawRegion){
|
||||
this.drawRegion = drawRegion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBase(Building build){
|
||||
if(drawRegion) Draw.rect(build.block.region, build.x, build.y);
|
||||
|
||||
Draw.rect(build.rotation > 1 ? top2 : top1, build.x, build.y, build.rotdeg());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlan(Block block, BuildPlan plan, Eachable<BuildPlan> list){
|
||||
if(drawRegion) Draw.rect(block.region, plan.drawx(), plan.drawy());
|
||||
Draw.rect(plan.rotation > 1 ? top2 : top1, plan.drawx(), plan.drawy(), plan.rotation * 90);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
top1 = Core.atlas.find(block.name + "-top1");
|
||||
top2 = Core.atlas.find(block.name + "-top2");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(Block block){
|
||||
return new TextureRegion[]{block.region, top1};
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user