Skip to content

Commit

Permalink
1.4
Browse files Browse the repository at this point in the history
- Fixed blending issues
- Most buildings draw limitations removed
- Phase fabric item now glows
  • Loading branch information
EyeOfDarkness committed Dec 3, 2023
1 parent 79b385d commit c0f422b
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 32 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Advance lighting",
"author": "EoD",
"description": "Not recommended for weak devices. Only supports Vanilla/Supported-Json content. This mod replaces/add some effects, and may cause issues with mods that actively check on those effects. May conflict with vanilla bloom.",
"version": "v1.3.1.1",
"version": "v1.4.0.0",
"minGameVersion": 145,
"main": "lights.AdvanceLighting",
"hidden": true,
Expand Down
45 changes: 21 additions & 24 deletions src/lights/AdvanceLighting.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import mindustry.type.weapons.*;
import mindustry.world.*;
import mindustry.world.blocks.defense.turrets.*;
import mindustry.world.blocks.distribution.*;
import mindustry.world.blocks.environment.*;
import mindustry.world.blocks.liquid.*;
import mindustry.world.blocks.power.*;
Expand All @@ -42,7 +43,7 @@ public class AdvanceLighting extends Mod{
public static ObjectSet<TextureRegion> autoGlowRegions = new ObjectSet<>(), liquidRegions = new ObjectSet<>();
public static IntMap<TextureRegion> uvGlowRegions = new IntMap<>();
public static IntMap<EnviroGlow> glowingEnvTiles = new IntMap<>();
public static IntSet uvAutoGlowRegions = new IntSet(), validBlocks = new IntSet();
public static IntSet uvAutoGlowRegions = new IntSet();
public static Shader screenShader, smoothAlphaCutShader;
public static AdditiveBloom bloom;
public static boolean bloomActive;
Expand Down Expand Up @@ -399,9 +400,11 @@ boolean drawBlockLiquid(DrawBlock draw){

void load(){
TextureRegion itemCircle = Core.atlas.find("ring-item");
TextureRegion phase = Items.phaseFabric.fullIcon;
if(itemCircle.found()){
autoGlowRegions.add(itemCircle);
}
autoGlowRegions.add(phase);

EnviroGlow env = new EnviroGlow();
TextureRegion[] tmpVariants = new TextureRegion[16];
Expand All @@ -415,7 +418,6 @@ void load(){
}

for(Block block : Vars.content.blocks()){
boolean found = false;

if(renderEnvironment){
tmpVariantsSize = -1;
Expand Down Expand Up @@ -494,10 +496,6 @@ void load(){
}
}
}

if(block instanceof TreeBlock || block instanceof TallBlock){
validBlocks.add(block.id);
}

if(!block.hasBuilding()){
continue;
Expand All @@ -518,6 +516,15 @@ void load(){
}
}
}
if(block instanceof Duct duc){
for(TextureRegion top : duc.topRegions){
if(top instanceof AtlasRegion ar){
if((rep = getReplace(ar.name)).found()){
replace.put(ar, rep);
}
}
}
}

if(block instanceof LiquidBlock || block instanceof LiquidSource || block instanceof NuclearReactor){
liquidBlocks.add(block.id);
Expand All @@ -531,11 +538,9 @@ void load(){
if(block instanceof Turret tr && tr.drawer instanceof DrawTurret dtr){
TextureRegion r;
Seq<TextureRegion> sr;
//Assume all turret parts go outside the block
//found = true;

if(block.region.found() && (r = get(block.name)).found()){
glowEquiv.put(block.region, r);
//found = true;
}
if(dtr.liquid.found()){
liquidRegions.add(dtr.liquid);
Expand All @@ -557,34 +562,30 @@ void load(){
}
}
if(block instanceof GenericCrafter gc){
found = loadDraws(gc.drawer);
loadDraws(gc.drawer);

if(drawOverride(gc.drawer)){
gc.drawer = new DrawGlowWrapper(gc.drawer);
found = true;
}
}
if(block instanceof Separator sr){
found = loadDraws(sr.drawer);
loadDraws(sr.drawer);

if(drawOverride(sr.drawer)){
sr.drawer = new DrawGlowWrapper(sr.drawer);
found = true;
}
}
if(block instanceof PowerGenerator pg){
found = loadDraws(pg.drawer);
loadDraws(pg.drawer);

if(drawOverride(pg.drawer)){
pg.drawer = new DrawGlowWrapper(pg.drawer);
found = true;
}
}
if(block instanceof PowerNode pn){
autoGlowRegions.add(pn.laserEnd);
uvAutoGlowRegions.add(ALStructs.uv(pn.laser.texture, pn.laser.u, pn.laser.v));
}
if(block instanceof LightBlock) found = true;

/*
if(block instanceof HeatConductor || block instanceof HeatProducer || block instanceof PowerBlock){
Expand All @@ -594,10 +595,6 @@ void load(){
found = true;
}
*/

if(found){
validBlocks.add(block.id);
}
}

autoGlowRegions.add(Core.atlas.find("minelaser-end"));
Expand Down Expand Up @@ -686,7 +683,7 @@ void drawTiles(){
float bridge = Renderer.bridgeOpacity;
Renderer.bridgeOpacity = 0.7f + (bridge * (1f - 0.7f));

batch.cacheMode = true;
//batch.cacheMode = true;
for(Tile tile : tileView){
Block block = tile.block();
Building build = tile.build;
Expand All @@ -699,9 +696,9 @@ void drawTiles(){
Liquid lc;
boolean setLiquid = (build != null && liquidBlocks.contains(block.id) && ((lc = build.liquids.current()) != null && build.liquids.currentAmount() > 0.001f && glowingLiquids.contains(lc.id)));
//boolean valid = validBlocks.contains(block.id) || onGlowingTile.contains(tile.pos()) || setLiquid;
boolean valid = validBlocks.contains(block.id) || setLiquid;
//boolean valid = validBlocks.contains(block.id) || setLiquid;

batch.setExcludeLayer(-100f, valid ? -100f : Layer.blockAfterCracks);
//batch.setExcludeLayer(-100f, valid ? -100f : Layer.blockAfterCracks);

if(setLiquid) batch.setLiquidMode(true);
block.drawBase(tile);
Expand All @@ -719,7 +716,7 @@ void drawTiles(){
}
}
}
batch.cacheMode = false;
//batch.cacheMode = false;
batch.setExcludeLayer();
Renderer.bridgeOpacity = bridge;
}
Expand Down
16 changes: 9 additions & 7 deletions src/lights/graphics/AltLightBatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ protected void draw(TextureRegion region, float x, float y, float originX, float
return;
}

if(cacheMode && color.a >= 0.999f && !glow && z >= excludeMinZ && z <= excludeMaxZ){
if(cacheMode && color.a >= 0.9f && !glow && z >= excludeMinZ && z <= excludeMaxZ){
//boolean autoGlow = AdvanceLighting.autoGlowRegions.contains(region);
CacheRequest cr = obtainCache();
cr.set(region, x, y, originX, originY, width, height, rotation);
Expand Down Expand Up @@ -176,7 +176,7 @@ protected void draw(TextureRegion region, float x, float y, float originX, float
rq.color = colorPacked;
rq.mixColor = mixColorPacked;
rq.z = z;
rq.blend = blending;
//rq.blend = blending;

if(!Mathf.zero(rotation)){
float worldOriginX = x + originX;
Expand Down Expand Up @@ -318,7 +318,7 @@ protected void draw(Texture texture, float[] spriteVertices, int offset, int cou
rq.color = colorPacked;
rq.mixColor = mixColorPacked;
rq.z = z;
rq.blend = blending;
//rq.blend = blending;
float[] vertices = rq.vertices;

//System.arraycopy(spriteVertices, 0, rq.vertices, 0, 24);
Expand Down Expand Up @@ -401,10 +401,12 @@ protected void flush(){
//requests2
for(int i = 0; i < calls; i++){
LightRequest r = requests[i];
if(blending != r.blend && r.action == 0) setBlending(r.blend);

if(r.texture != null){
if(auto) r.convertAutoColor();
if(layerGlow) r.convertGlow();
if(blending != r.blend) setBlending(r.blend);
//if(blending != r.blend) setBlending(r.blend);
superDraw(r.texture, r.vertices, 24);
}else if(r.run != null){
r.run.run();
Expand Down Expand Up @@ -465,7 +467,7 @@ protected void setPackedColor(float packedColor){
@Override
protected void setBlending(Blending blending){
if(flushing){
super.flush();
if(blending != this.blending) super.flush();
}else{
glow = blending == Blending.additive;
}
Expand All @@ -482,8 +484,8 @@ LightRequest obtain(){
r.texture = null;
r.run = null;
r.action = 0;
r.z = 0f;
r.blend = Blending.normal;
r.z = z;
r.blend = blending;
calls++;
return r;
}
Expand Down

0 comments on commit c0f422b

Please sign in to comment.