Shader crash fix / More blocks / Kiln / Removed (unused) flux

This commit is contained in:
Anuken
2019-01-30 22:51:24 -05:00
parent 43bff5c34d
commit e6a39a8255
20 changed files with 1965 additions and 2001 deletions

View File

@@ -36,10 +36,10 @@ public class Blocks implements ContentList{
//environment
air, part, spawn, deepwater, water, tar, stone, craters, charr, sand, ice, snow,
grass, holostone, rocks, icerocks, cliffs, pine, whiteTree, whiteTreeDead, sporeCluster,
iceSnow, sandWater, duneRocks, stainedRocks,
iceSnow, sandWater, duneRocks, stainedRocks, stainedStone,
//crafting
siliconSmelter, graphitePress, plastaniumCompressor, multiPress, phaseWeaver, surgeSmelter, pyratiteMixer, blastMixer, cryofluidMixer,
siliconSmelter, kiln, graphitePress, plastaniumCompressor, multiPress, phaseWeaver, surgeSmelter, pyratiteMixer, blastMixer, cryofluidMixer,
melter, separator, centrifuge, biomatterCompressor, pulverizer, incinerator,
//sandbox
@@ -200,7 +200,6 @@ public class Blocks implements ContentList{
}};
grass = new Floor("grass"){{
hasOres = true;
minimapColor = Color.valueOf("549d5b");
}};
@@ -240,6 +239,11 @@ public class Blocks implements ContentList{
variants = 2;
}};
stainedStone = new Floor("stained-stone"){{
edgeStyle = "blocky";
hasOres = true;
}};
//endregion
//region crafting
@@ -283,6 +287,19 @@ public class Blocks implements ContentList{
consumes.power(0.50f);
}};
kiln = new PowerSmelter("kiln"){{
requirements(Category.crafting, ItemStack.with(Items.copper, 120, Items.graphite, 60, Items.lead, 60));
craftEffect = Fx.smeltsmoke;
output = Items.metaglass;
craftTime = 30f;
size = 2;
hasLiquids = false;
flameColor = Color.valueOf("ffc099");
consumes.items(new ItemStack(Items.lead, 1), new ItemStack(Items.sand, 1));
consumes.power(0.60f);
}};
plastaniumCompressor = new PlastaniumCompressor("plastanium-compressor"){{
requirements(Category.crafting, ItemStack.with(Items.silicon, 160, Items.lead, 230, Items.graphite, 120, Items.titanium, 160));
hasItems = true;
@@ -318,9 +335,6 @@ public class Blocks implements ContentList{
craftTime = 75f;
size = 2;
useFlux = true;
fluxNeeded = 3;
consumes.power(4f);
consumes.items(new ItemStack(Items.titanium, 2), new ItemStack(Items.lead, 4), new ItemStack(Items.silicon, 3), new ItemStack(Items.copper, 3));
}};

View File

@@ -78,7 +78,6 @@ public class Items implements ContentList{
phasefabric = new Item("phase-fabric", Color.valueOf("f4ba6e")){{
type = ItemType.material;
cost = 1.5f;
fluxiness = 1.8f;
radioactivity = 0.6f;
}};
@@ -88,11 +87,10 @@ public class Items implements ContentList{
biomatter = new Item("biomatter", Color.valueOf("648b55")){{
flammability = 1.05f;
fluxiness = 0.6f;
}};
sand = new Item("sand", Color.valueOf("e3d39e")){{
fluxiness = 1f;
}};
blastCompound = new Item("blast-compound", Color.valueOf("ff795e")){{

View File

@@ -428,7 +428,7 @@ public class World implements ApplicationListener{
for(int x = 0; x < tiles.length; x++){
for(int y = 0; y < tiles[0].length; y++){
Tile tile = tiles[x][y];
if(tile.block().solid && !tile.block().update && tile.block().fillsTile){
if(tile.block().solid && !tile.block().synthetic() && tile.block().fillsTile){
dark[x][y] = darkIterations;
}
}
@@ -459,7 +459,7 @@ public class World implements ApplicationListener{
for(int x = 0; x < tiles.length; x++){
for(int y = 0; y < tiles[0].length; y++){
Tile tile = tiles[x][y];
if(tile.block().solid && !tile.block().update){
if(tile.block().solid && !tile.block().synthetic()){
tiles[x][y].setRotation(dark[x][y]);
}
}

View File

@@ -185,7 +185,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
}
public boolean isOutOfBounds(){
return x < worldBounds || y < worldBounds || x > world.width() * tilesize + worldBounds || y > world.height() * tilesize + worldBounds;
return x < -worldBounds || y < -worldBounds || x > world.width() * tilesize + worldBounds || y > world.height() * tilesize + worldBounds;
}
public float calculateDamage(float amount){

View File

@@ -58,7 +58,7 @@ public class BlockRenderer{
for(int x = 0; x < world.width(); x++){
for(int y = 0; y < world.height(); y++){
Tile tile = world.rawTile(x, y);
if(tile.getRotation() > 0){
if(tile.getRotation() > 0 && tile.block().solid && tile.block().fillsTile && !tile.block().synthetic()){
Draw.color(0f, 0f, 0f, Math.min((tile.getRotation() + 0.5f)/4f, 1f));
Fill.rect(tile.x + 0.5f, tile.y + 0.5f, 1, 1);
}

View File

@@ -7,19 +7,12 @@ import io.anuke.arc.graphics.glutils.Shader;
import io.anuke.arc.scene.ui.layout.Unit;
import io.anuke.arc.util.Time;
import static io.anuke.mindustry.Vars.tilesize;
import static io.anuke.mindustry.Vars.world;
public class Shaders{
public static Outline outline;
public static Shadow shadow;
public static BlockBuild blockbuild;
public static BlockPreview blockpreview;
public static Shield shield;
public static SurfaceShader water;
public static SurfaceShader lava;
public static SurfaceShader oil;
public static Space space;
public static UnitBuild build;
public static MixShader mix;
public static Shader fullMix;
@@ -32,10 +25,6 @@ public class Shaders{
blockbuild = new BlockBuild();
blockpreview = new BlockPreview();
shield = new Shield();
water = new SurfaceShader("water");
lava = new SurfaceShader("lava");
oil = new SurfaceShader("oil");
space = new Space();
build = new UnitBuild();
mix = new MixShader();
fog = new FogShader();
@@ -82,19 +71,6 @@ public class Shaders{
}
}
public static class Space extends SurfaceShader{
public Space(){
super("space2");
}
@Override
public void apply(){
super.apply();
setUniformf("u_center", world.width() * tilesize / 2f, world.height() * tilesize / 2f);
}
}
public static class UnitBuild extends LoadShader{
public float progress, time;
public Color color = new Color();
@@ -203,23 +179,6 @@ public class Shaders{
Core.camera.height );
}
}
public static class SurfaceShader extends LoadShader{
public SurfaceShader(String frag){
super(frag, "cache");
}
@Override
public void apply(){
setUniformf("camerapos",
Core.camera.position.x - Core.camera.width / 2 ,
Core.camera.position.y - Core.camera.height / 2 );
setUniformf("screensize", Core.camera.width,
Core.camera.height );
setUniformf("u_time", Time.time());
}
}
public static class LoadShader extends Shader{
public LoadShader(String frag, String vert){

View File

@@ -92,7 +92,7 @@ public class MapGenerator extends Generator{
if((tile.block() instanceof StaticWall
&& tiles[newX][newY].block() instanceof StaticWall)
|| tile.block() == Blocks.air
|| (tile.block() == Blocks.air && !tiles[newX][newY].block().synthetic())
|| (tiles[newX][newY].block() == Blocks.air && tile.block() instanceof StaticWall)){
tile.setBlock(tiles[newX][newY].block());
}

View File

@@ -26,8 +26,6 @@ public class Item extends UnlockableContent implements Comparable<Item>{
public float flammability = 0f;
/**how radioactive this item is. 0=none, 1=chernobyl ground zero*/
public float radioactivity;
/**how effective this item is as flux for smelting. 0 = not a flux, 0.5 = normal flux, 1 = very good*/
public float fluxiness = 0f;
/**drill hardness of the item*/
public int hardness = 0;
/**the burning color of this item. TODO unused; implement*/

View File

@@ -92,8 +92,6 @@ public class ContentDisplay{
table.row();
table.add(Core.bundle.format("item.radioactivity", (int) (item.radioactivity * 100)));
table.row();
table.add(Core.bundle.format("item.fluxiness", (int) (item.fluxiness * 100)));
table.row();
}
public static void displayLiquid(Table table, Liquid liquid){

View File

@@ -173,8 +173,7 @@ public class HudFragment extends Fragment{
.update(l ->{
l.setColor(Tmp.c1.set(Color.WHITE).lerp(Color.SCARLET, Mathf.absin(Time.time(), 10f, 1f)));
l.setText(Core.bundle.format("outofbounds", (int)((boundsCountdown - players[0].destructTime) / 60f)));
}).get().setAlignment(Align.center, Align.center))
.margin(6).update(u -> {
}).get().setAlignment(Align.center, Align.center)).margin(6).update(u -> {
u.color.a = Mathf.lerpDelta(u.color.a, Mathf.num(players[0].isOutOfBounds()), 0.1f);
}).get().color.a = 0f;
});

View File

@@ -9,7 +9,6 @@ import io.anuke.arc.graphics.g2d.Fill;
import io.anuke.arc.graphics.g2d.TextureRegion;
import io.anuke.arc.math.Mathf;
import io.anuke.arc.util.Time;
import io.anuke.mindustry.content.Items;
import io.anuke.mindustry.content.Fx;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.type.Item;
@@ -23,19 +22,11 @@ import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import static io.anuke.mindustry.Vars.content;
public class PowerSmelter extends PowerBlock{
protected final int timerDump = timers++;
protected Item output;
protected float minFlux = 0.2f;
protected int fluxNeeded = 1;
protected float fluxSpeedMult = 0.75f;
protected float baseFluxChance = 0.25f;
protected boolean useFlux = false;
protected float heatUpTime = 80f;
protected float minHeat = 0.5f;
@@ -56,10 +47,6 @@ public class PowerSmelter extends PowerBlock{
@Override
public void init(){
if(useFlux){
consumes.item(Items.sand).optional(true);
}
super.init();
produces.set(output);
@@ -106,43 +93,18 @@ public class PowerSmelter extends PowerBlock{
return;
}
float baseSmeltSpeed = 1f;
for(Item item : content.items()){
if(item.fluxiness >= minFlux && tile.entity.items.get(item) > 0){
baseSmeltSpeed = fluxSpeedMult;
break;
}
}
entity.craftTime += entity.delta() * entity.power.satisfaction;
if(entity.items.get(output) >= itemCapacity //output full
|| entity.heat <= minHeat //not burning
|| entity.craftTime < craftTime*baseSmeltSpeed){ //not yet time
|| entity.craftTime < craftTime){ //not yet time
return;
}
entity.craftTime = 0f;
boolean consumeInputs = true;
if(useFlux){
//remove flux materials if present
for(Item item : content.items()){
if(item.fluxiness >= minFlux && tile.entity.items.get(item) >= fluxNeeded){
tile.entity.items.remove(item, fluxNeeded);
//chance of not consuming inputs if flux material present
consumeInputs = !Mathf.chance(item.fluxiness * baseFluxChance);
break;
}
}
}
if(consumeInputs){
for(ItemStack item : consumes.items()){
entity.items.remove(item.item, item.amount);
}
for(ItemStack item : consumes.items()){
entity.items.remove(item.item, item.amount);
}
offloadNear(tile, output);
@@ -158,8 +120,7 @@ public class PowerSmelter extends PowerBlock{
}
}
return useFlux && item.fluxiness >= minFlux && tile.entity.items.get(item) < itemCapacity;
return false;
}
@Override

View File

@@ -1,6 +1,12 @@
package io.anuke.mindustry.world.blocks.production;
import io.anuke.arc.entities.Effects;
import io.anuke.arc.entities.Effects.Effect;
import io.anuke.arc.graphics.Color;
import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.arc.graphics.g2d.Fill;
import io.anuke.arc.math.Mathf;
import io.anuke.arc.util.Time;
import io.anuke.mindustry.content.Fx;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.type.Item;
@@ -11,25 +17,12 @@ import io.anuke.mindustry.world.consumers.ConsumeItem;
import io.anuke.mindustry.world.consumers.ConsumeItems;
import io.anuke.mindustry.world.meta.BlockStat;
import io.anuke.mindustry.world.meta.StatUnit;
import io.anuke.arc.entities.Effects;
import io.anuke.arc.entities.Effects.Effect;
import io.anuke.arc.util.Time;
import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.arc.graphics.g2d.Fill;
import io.anuke.arc.math.Mathf;
import static io.anuke.mindustry.Vars.*;
public class Smelter extends Block{
protected final int timerDump = timers++;
protected Item result;
protected float minFlux = 0.2f;
protected float fluxSpeedMult = 0.75f;
protected float baseFluxChance = 0.25f;
protected boolean useFlux = false;
protected float craftTime = 20f;
protected float burnDuration = 50f;
protected Effect craftEffect = Fx.smelt, burnEffect = Fx.fuelburn;
@@ -61,13 +54,6 @@ public class Smelter extends Block{
@Override
public void init(){
super.init();
for(ItemStack item : consumes.items()){
if(item.item.fluxiness >= minFlux && useFlux){
throw new IllegalArgumentException("'" + name + "' has input item '" + item.item.name + "', which is a flux, when useFlux is enabled. To prevent ambiguous item use, either remove this flux item from the inputs, or set useFlux to false.");
}
}
produces.set(result);
}
@@ -99,43 +85,17 @@ public class Smelter extends Block{
return;
}
float baseSmeltSpeed = 1f;
for(Item item : content.items()){
if(item.fluxiness >= minFlux && tile.entity.items.get(item) > 0){
baseSmeltSpeed = fluxSpeedMult;
break;
}
}
entity.craftTime += entity.delta();
if(entity.items.get(result) >= itemCapacity //output full
|| entity.burnTime <= 0 //not burning
|| entity.craftTime < craftTime*baseSmeltSpeed){ //not yet time
|| entity.craftTime < craftTime){ //not yet time
return;
}
entity.craftTime = 0f;
boolean consumeInputs = true;
if(useFlux){
//remove flux materials if present
for(Item item : content.items()){
if(item.fluxiness >= minFlux && tile.entity.items.get(item) > 0){
tile.entity.items.remove(item, 1);
//chance of not consuming inputs if flux material present
consumeInputs = !Mathf.chance(item.fluxiness * baseFluxChance);
break;
}
}
}
if(consumeInputs){
for(ItemStack item : consumes.items()){
entity.items.remove(item.item, item.amount);
}
for(ItemStack item : consumes.items()){
entity.items.remove(item.item, item.amount);
}
offloadNear(tile, result);
@@ -153,8 +113,7 @@ public class Smelter extends Block{
}
}
return (isInput && tile.entity.items.get(item) < itemCapacity) || (item == consumes.item() && tile.entity.items.get(consumes.item()) < itemCapacity) ||
(useFlux && item.fluxiness >= minFlux && tile.entity.items.get(item) < itemCapacity);
return (isInput && tile.entity.items.get(item) < itemCapacity) || (item == consumes.item() && tile.entity.items.get(consumes.item()) < itemCapacity);
}
@Override