Autogenerated render layer groups

This commit is contained in:
Anuken
2020-02-06 13:20:03 -05:00
parent 6a99a3922e
commit 6fe5663f79
11 changed files with 91 additions and 56 deletions

View File

@@ -187,7 +187,7 @@ public class Renderer implements ApplicationListener{
blocks.floor.drawFloor();
render(RenderLayer.floor);
Groups.drawFloor();
blocks.processBlocks();
blocks.drawShadows();
@@ -208,25 +208,25 @@ public class Renderer implements ApplicationListener{
blocks.drawBlocks(Layer.overlay);
render(RenderLayer.groundShadows);
render(RenderLayer.ground);
Groups.drawGroundShadows();
Groups.drawGround();
blocks.drawBlocks(Layer.turret);
render(RenderLayer.flyingShadows);
Groups.drawFlyingShadows();
blocks.drawBlocks(Layer.power);
blocks.drawBlocks(Layer.lights);
render(RenderLayer.flying);
Groups.drawFlying();
Draw.flush();
if(bloom != null && !pixelator.enabled()){
bloom.capture();
}
render(RenderLayer.bullets);
render(RenderLayer.effects);
Groups.drawBullets();
Groups.drawEffects();
Draw.flush();
if(bloom != null && !pixelator.enabled()){
@@ -240,9 +240,9 @@ public class Renderer implements ApplicationListener{
overlays.drawTop();
render(RenderLayer.names);
//TODO should use (draw)
Groups.player.each(p -> !p.dead(), Playerc::drawName);
if(!pixelator.enabled()){
Groups.drawNames();
}
if(state.rules.lighting){
lights.draw();
@@ -254,10 +254,6 @@ public class Renderer implements ApplicationListener{
Draw.flush();
}
private void render(RenderLayer layer){
}
private void drawLanding(){
if(landTime > 0 && player.closestCore() != null){
float fract = landTime / Fx.coreLand.lifetime;

View File

@@ -22,9 +22,6 @@ class AllEntities{
@EntityDef({UnitComp.class})
class GenericUnitDef{}
@EntityDef({BuilderComp.class})
class GenericBuilderDef{}
@GroupDef(EntityComp.class)
void all(){
@@ -45,11 +42,6 @@ class AllEntities{
}
@GroupDef(DrawComp.class)
void drawer(){
}
@GroupDef(SyncComp.class)
void sync(){

View File

@@ -6,13 +6,27 @@ import mindustry.annotations.Annotations.*;
import mindustry.gen.*;
@Component
abstract class DrawShadowComp implements Drawc, Rotc, Flyingc{
abstract class DrawShadowComp implements Drawc, Rotc, Flyingc, DrawLayerFlyingShadowsc, DrawLayerGroundShadowsc{
static final float shadowTX = -12, shadowTY = -13, shadowColor = Color.toFloatBits(0, 0, 0, 0.22f);
transient float x, y, rotation;
abstract TextureRegion getShadowRegion();
@Override
public void drawFlyingShadows(){
if(isFlying()){
drawShadow();
}
}
@Override
public void drawGroundShadows(){
if(isGrounded()){
drawShadow();
}
}
void drawShadow(){
if(!isGrounded()){
Draw.color(shadowColor);

View File

@@ -21,6 +21,10 @@ abstract class FlyingComp implements Posc, Velc, Healthc{
return elevation < 0.001f;
}
boolean isFlying(){
return elevation >= 0.001f;
}
@Override
public void update(){
Floor floor = floorOn();

View File

@@ -19,10 +19,20 @@ import mindustry.world.blocks.*;
import static mindustry.Vars.*;
@Component
abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitboxc, Rotc, Massc, Unitc, Weaponsc{
abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitboxc, Rotc, Massc, Unitc, Weaponsc, DrawShadowc{
private UnitController controller;
private UnitDef type;
@Override
public TextureRegion getShadowRegion(){
return type.region;
}
@Override
public float clipSize(){
return type.region.getWidth() * 2f;
}
@Override
public int itemCapacity(){
return type.itemCapacity;

View File

@@ -6,6 +6,7 @@ import arc.graphics.Texture.*;
import arc.graphics.g2d.*;
import arc.graphics.gl.*;
import arc.util.*;
import mindustry.gen.*;
import static arc.Core.*;
import static mindustry.Vars.renderer;
@@ -52,8 +53,7 @@ public class Pixelator implements Disposable{
Draw.rect(Draw.wrap(buffer.getTexture()), Core.camera.position.x, Core.camera.position.y, Core.camera.width, -Core.camera.height);
Draw.blend();
//TODO implement drawing functions, maybe
//Groups.player.draw(p -> !p.isDead(), Playerc::drawName);
Groups.drawNames();
Core.camera.position.set(px, py);
Core.settings.put("animatedwater", hadWater);

View File

@@ -1,12 +0,0 @@
package mindustry.graphics;
public enum RenderLayer{
floor,
groundShadows,
ground,
flyingShadows,
flying,
bullets,
effects,
names,
}