Moved some static regions
This commit is contained in:
@@ -766,9 +766,9 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void drawCracks(){
|
public void drawCracks(){
|
||||||
if(!damaged() || block.size > Block.maxCrackSize) return;
|
if(!damaged() || block.size > BlockRenderer.maxCrackSize) return;
|
||||||
int id = pos();
|
int id = pos();
|
||||||
TextureRegion region = Block.cracks[block.size - 1][Mathf.clamp((int)((1f - healthf()) * Block.crackRegions), 0, Block.crackRegions-1)];
|
TextureRegion region = renderer.blocks.cracks[block.size - 1][Mathf.clamp((int)((1f - healthf()) * BlockRenderer.crackRegions), 0, BlockRenderer.crackRegions-1)];
|
||||||
Draw.colorl(0.2f, 0.1f + (1f - healthf())* 0.6f);
|
Draw.colorl(0.2f, 0.1f + (1f - healthf())* 0.6f);
|
||||||
Draw.rect(region, x, y, (id%4)*90);
|
Draw.rect(region, x, y, (id%4)*90);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
|
|||||||
@@ -20,11 +20,14 @@ import static arc.Core.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class BlockRenderer implements Disposable{
|
public class BlockRenderer implements Disposable{
|
||||||
|
public static final int crackRegions = 8, maxCrackSize = 9;
|
||||||
|
|
||||||
private static final int initialRequests = 32 * 32;
|
private static final int initialRequests = 32 * 32;
|
||||||
private static final int expandr = 9;
|
private static final int expandr = 9;
|
||||||
private static final Color shadowColor = new Color(0, 0, 0, 0.71f);
|
private static final Color shadowColor = new Color(0, 0, 0, 0.71f);
|
||||||
|
|
||||||
public final FloorRenderer floor = new FloorRenderer();
|
public final FloorRenderer floor = new FloorRenderer();
|
||||||
|
public TextureRegion[][] cracks;
|
||||||
|
|
||||||
private Seq<Tile> tileview = new Seq<>(false, initialRequests, Tile.class);
|
private Seq<Tile> tileview = new Seq<>(false, initialRequests, Tile.class);
|
||||||
private Seq<Tile> lightview = new Seq<>(false, initialRequests, Tile.class);
|
private Seq<Tile> lightview = new Seq<>(false, initialRequests, Tile.class);
|
||||||
@@ -40,6 +43,15 @@ public class BlockRenderer implements Disposable{
|
|||||||
|
|
||||||
public BlockRenderer(){
|
public BlockRenderer(){
|
||||||
|
|
||||||
|
Events.on(ClientLoadEvent.class, e -> {
|
||||||
|
cracks = new TextureRegion[maxCrackSize][crackRegions];
|
||||||
|
for(int size = 1; size <= maxCrackSize; size++){
|
||||||
|
for(int i = 0; i < crackRegions; i++){
|
||||||
|
cracks[size - 1][i] = Core.atlas.find("cracks-" + size + "-" + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Events.on(WorldLoadEvent.class, event -> {
|
Events.on(WorldLoadEvent.class, event -> {
|
||||||
shadowEvents.clear();
|
shadowEvents.clear();
|
||||||
lastCamY = lastCamX = -99; //invalidate camera position so blocks get updated
|
lastCamY = lastCamX = -99; //invalidate camera position so blocks get updated
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ public class LExecutor{
|
|||||||
public void setnum(int index, double value){
|
public void setnum(int index, double value){
|
||||||
Var v = vars[index];
|
Var v = vars[index];
|
||||||
if(v.constant) return;
|
if(v.constant) return;
|
||||||
v.numval = Double.isNaN(value) || Double.isInfinite(value) ? 0 : 0;
|
v.numval = Double.isNaN(value) || Double.isInfinite(value) ? 0 : value;
|
||||||
v.objval = null;
|
v.objval = null;
|
||||||
v.isobj = false;
|
v.isobj = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -304,10 +304,12 @@ public class Sector{
|
|||||||
return Core.settings.getInt(key("secondsi-passed"));
|
return Core.settings.getInt(key("secondsi-passed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO this is terrible
|
||||||
private String key(String key){
|
private String key(String key){
|
||||||
return planet.name + "-s-" + id + "-" + key;
|
return planet.name + "-s-" + id + "-" + key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO this is terrible
|
||||||
private void put(String key, Object value){
|
private void put(String key, Object value){
|
||||||
Core.settings.put(key(key), value);
|
Core.settings.put(key(key), value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ import java.util.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class Block extends UnlockableContent{
|
public class Block extends UnlockableContent{
|
||||||
public static final int crackRegions = 8, maxCrackSize = 9;
|
|
||||||
|
|
||||||
public boolean hasItems;
|
public boolean hasItems;
|
||||||
public boolean hasLiquids;
|
public boolean hasLiquids;
|
||||||
public boolean hasPower;
|
public boolean hasPower;
|
||||||
@@ -212,8 +210,6 @@ public class Block extends UnlockableContent{
|
|||||||
public @Load("@-team") TextureRegion teamRegion;
|
public @Load("@-team") TextureRegion teamRegion;
|
||||||
public TextureRegion[] teamRegions;
|
public TextureRegion[] teamRegions;
|
||||||
|
|
||||||
//TODO make this not static
|
|
||||||
public static TextureRegion[][] cracks;
|
|
||||||
protected static final Seq<Tile> tempTiles = new Seq<>();
|
protected static final Seq<Tile> tempTiles = new Seq<>();
|
||||||
protected static final Seq<Building> tempTileEnts = new Seq<>();
|
protected static final Seq<Building> tempTileEnts = new Seq<>();
|
||||||
|
|
||||||
@@ -687,15 +683,6 @@ public class Block extends UnlockableContent{
|
|||||||
public void load(){
|
public void load(){
|
||||||
region = Core.atlas.find(name);
|
region = Core.atlas.find(name);
|
||||||
|
|
||||||
if(cracks == null || (cracks[0][0].texture != null && cracks[0][0].texture.isDisposed())){
|
|
||||||
cracks = new TextureRegion[maxCrackSize][crackRegions];
|
|
||||||
for(int size = 1; size <= maxCrackSize; size++){
|
|
||||||
for(int i = 0; i < crackRegions; i++){
|
|
||||||
cracks[size - 1][i] = Core.atlas.find("cracks-" + size + "-" + i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ContentRegions.loadRegions(this);
|
ContentRegions.loadRegions(this);
|
||||||
|
|
||||||
//load specific team regions
|
//load specific team regions
|
||||||
|
|||||||
Reference in New Issue
Block a user