Various crash fixes

This commit is contained in:
Anuken
2018-06-26 16:19:05 -04:00
parent 20b3bb8f13
commit 03277c69af
6 changed files with 36 additions and 17 deletions

View File

@@ -86,11 +86,10 @@ public class Renderer extends RendererModule{
entity.data = data;
entity.id ++;
entity.set(x, y);
effectGroup.add(entity);
if(data instanceof BaseEntity){
entity.setParent((BaseEntity)data);
}
threads.runGraphics(() -> effectGroup.add(entity));
}else{
GroundEffectEntity entity = Pools.obtain(GroundEffectEntity.class);
entity.effect = effect;
@@ -99,7 +98,7 @@ public class Renderer extends RendererModule{
entity.id ++;
entity.data = data;
entity.set(x, y);
groundEffectGroup.add(entity);
threads.runGraphics(() -> groundEffectGroup.add(entity));
}
}
}

View File

@@ -71,7 +71,9 @@ public class BlockRenderer{
Block block = tile.block();
if(!expanded && block != Blocks.air && world.isAccessible(worldx, worldy)){
block.drawShadow(tile);
synchronized (Tile.tileSetLock) {
block.drawShadow(tile);
}
}
if(!(block instanceof StaticBlock)){
@@ -130,12 +132,14 @@ public class BlockRenderer{
layerBegins(req.layer);
}
if(req.layer == Layer.block){
block.draw(req.tile);
}else if(req.layer == block.layer){
block.drawLayer(req.tile);
}else if(req.layer == block.layer2){
block.drawLayer2(req.tile);
synchronized (Tile.tileSetLock) {
if (req.layer == Layer.block) {
block.draw(req.tile);
} else if (req.layer == block.layer) {
block.drawLayer(req.tile);
} else if (req.layer == block.layer2) {
block.drawLayer2(req.tile);
}
}
lastLayer = req.layer;

View File

@@ -94,6 +94,8 @@ public class MinimapRenderer implements Disposable{
}
public TextureRegion getRegion() {
if(texture == null) return null;
int sz = Mathf.clamp(baseSize * zoom, baseSize, Math.min(world.width(), world.height()));
float dx = (Core.camera.position.x / tilesize);
float dy = (Core.camera.position.y / tilesize);

View File

@@ -50,7 +50,10 @@ public class OverlayRenderer {
//draw config selected block
if(input.frag.config.isShown()){
Tile tile = input.frag.config.getSelectedTile();
tile.block().drawConfigure(tile);
synchronized (Tile.tileSetLock) {
tile.block().drawConfigure(tile);
}
}
input.drawTop();
@@ -132,7 +135,9 @@ public class OverlayRenderer {
drawbars.run();
}
target.block().drawSelect(target);
synchronized (Tile.tileSetLock) {
target.block().drawSelect(target);
}
}
}

View File

@@ -37,8 +37,6 @@ public class Minimap extends Table {
renderer.fog().getTexture().setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
//draw.getRegion().setV(draw.getRegion().getV2());
//draw.getRegion().setV2(v);
draw.getRegion().setTexture(renderer.fog().getTexture());
draw.getRegion().setV(1f - draw.getRegion().getV());
draw.getRegion().setV2(1f - draw.getRegion().getV2());

View File

@@ -55,6 +55,9 @@ public class Drill extends Block{
protected boolean drawRim = false;
protected Color heatColor = Color.valueOf("ff5512");
protected TextureRegion rimRegion;
protected TextureRegion rotatorRegion;
protected TextureRegion topRegion;
public Drill(String name) {
super(name);
@@ -68,6 +71,14 @@ public class Drill extends Block{
hasItems = true;
}
@Override
public void load() {
super.load();
rimRegion = Draw.region(name + "-rim");
rotatorRegion = Draw.region(name + "-rotator");
topRegion = Draw.region(name + "-top");
}
@Override
public void draw(Tile tile) {
float s = 0.3f;
@@ -81,14 +92,14 @@ public class Drill extends Block{
Graphics.setAdditiveBlending();
Draw.color(heatColor);
Draw.alpha(entity.warmup * ts * (1f-s + Mathf.absin(Timers.time(), 3f, s)));
Draw.rect(name + "-rim", tile.drawx(), tile.drawy());
Draw.rect(rimRegion, tile.drawx(), tile.drawy());
Draw.color();
Graphics.setNormalBlending();
}
Draw.rect(name + "-rotator", tile.drawx(), tile.drawy(), entity.drillTime * rotateSpeed);
Draw.rect(rotatorRegion, tile.drawx(), tile.drawy(), entity.drillTime * rotateSpeed);
Draw.rect(name + "-top", tile.drawx(), tile.drawy());
Draw.rect(topRegion, tile.drawx(), tile.drawy());
if(!isMultiblock() && isValid(tile)) {
Draw.color(tile.floor().drops.item.color);