Consistent output timer
This commit is contained in:
@@ -5,6 +5,7 @@ import io.anuke.arc.math.Mathf;
|
|||||||
import io.anuke.arc.util.Pack;
|
import io.anuke.arc.util.Pack;
|
||||||
import io.anuke.arc.util.noise.RidgedPerlin;
|
import io.anuke.arc.util.noise.RidgedPerlin;
|
||||||
import io.anuke.arc.util.noise.Simplex;
|
import io.anuke.arc.util.noise.Simplex;
|
||||||
|
import io.anuke.mindustry.content.Blocks;
|
||||||
import io.anuke.mindustry.editor.MapEditor;
|
import io.anuke.mindustry.editor.MapEditor;
|
||||||
import io.anuke.mindustry.editor.MapGenerateDialog.DummyTile;
|
import io.anuke.mindustry.editor.MapGenerateDialog.DummyTile;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
@@ -50,6 +51,10 @@ public abstract class GenerateFilter{
|
|||||||
public final void apply(GenerateInput in){
|
public final void apply(GenerateInput in){
|
||||||
this.in = in;
|
this.in = in;
|
||||||
apply();
|
apply();
|
||||||
|
//remove extra ores on liquids
|
||||||
|
if(((Floor)in.floor).isLiquid){
|
||||||
|
in.ore = Blocks.air;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class GenerateInput{
|
public static class GenerateInput{
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ public class OreFilter extends GenerateFilter{
|
|||||||
|
|
||||||
{
|
{
|
||||||
options(
|
options(
|
||||||
new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f),
|
new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f),
|
||||||
new SliderOption("threshold", () -> threshold, f -> threshold = f, 0f, 1f),
|
new SliderOption("threshold", () -> threshold, f -> threshold = f, 0f, 1f),
|
||||||
new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f),
|
new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f),
|
||||||
new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f),
|
new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f),
|
||||||
new BlockOption("ore", () -> ore, b -> ore = b, oresOnly)
|
new BlockOption("ore", () -> ore, b -> ore = b, oresOnly)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ public class OreFilter extends GenerateFilter{
|
|||||||
public void apply(){
|
public void apply(){
|
||||||
float noise = noise(in.x, in.y, scl, 1f, octaves, falloff);
|
float noise = noise(in.x, in.y, scl, 1f, octaves, falloff);
|
||||||
|
|
||||||
if(noise > threshold && !in.srcfloor.isLiquid){
|
if(noise > threshold){
|
||||||
in.ore = ore;
|
in.ore = ore;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,6 +113,11 @@ public class Block extends BlockStorage{
|
|||||||
protected TextureRegion[] variantRegions, editorVariantRegions;
|
protected TextureRegion[] variantRegions, editorVariantRegions;
|
||||||
protected TextureRegion region, editorIcon;
|
protected TextureRegion region, editorIcon;
|
||||||
|
|
||||||
|
/** Dump timer ID.*/
|
||||||
|
protected final int timerDump = timers++;
|
||||||
|
/** How often to try dumping items in ticks, e.g. 5 = 12 times/sec*/
|
||||||
|
protected final int dumpTime = 5;
|
||||||
|
|
||||||
public Block(String name){
|
public Block(String name){
|
||||||
super(name);
|
super(name);
|
||||||
this.description = Core.bundle.getOrNull("block." + name + ".description");
|
this.description = Core.bundle.getOrNull("block." + name + ".description");
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import static io.anuke.mindustry.Vars.content;
|
|||||||
|
|
||||||
public class Drill extends Block{
|
public class Drill extends Block{
|
||||||
protected final static float hardnessDrillMultiplier = 50f;
|
protected final static float hardnessDrillMultiplier = 50f;
|
||||||
protected final int timerDump = timers++;
|
|
||||||
|
|
||||||
protected final ObjectIntMap<Item> oreCount = new ObjectIntMap<>();
|
protected final ObjectIntMap<Item> oreCount = new ObjectIntMap<>();
|
||||||
protected final Array<Item> itemArray = new Array<>();
|
protected final Array<Item> itemArray = new Array<>();
|
||||||
@@ -192,7 +191,7 @@ public class Drill extends Block{
|
|||||||
|
|
||||||
float totalHardness = entity.dominantItems * entity.dominantItem.hardness;
|
float totalHardness = entity.dominantItems * entity.dominantItem.hardness;
|
||||||
|
|
||||||
if(entity.timer.get(timerDump, 5)){
|
if(entity.timer.get(timerDump, dumpTime)){
|
||||||
tryDump(tile, entity.dominantItem);
|
tryDump(tile, entity.dominantItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ import io.anuke.mindustry.world.meta.StatUnit;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
public class GenericCrafter extends Block{
|
public class GenericCrafter extends Block{
|
||||||
protected final int timerDump = timers++;
|
|
||||||
|
|
||||||
protected ItemStack outputItem;
|
protected ItemStack outputItem;
|
||||||
protected LiquidStack outputLiquid;
|
protected LiquidStack outputLiquid;
|
||||||
|
|
||||||
@@ -110,7 +108,7 @@ public class GenericCrafter extends Block{
|
|||||||
entity.progress = 0f;
|
entity.progress = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(outputItem != null && tile.entity.timer.get(timerDump, 5)){
|
if(outputItem != null && tile.entity.timer.get(timerDump, dumpTime)){
|
||||||
tryDump(tile, outputItem.item);
|
tryDump(tile, outputItem.item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ import io.anuke.mindustry.world.meta.values.ItemFilterValue;
|
|||||||
* Extracts a random list of items from an input item and an input liquid.
|
* Extracts a random list of items from an input item and an input liquid.
|
||||||
*/
|
*/
|
||||||
public class Separator extends Block{
|
public class Separator extends Block{
|
||||||
protected final int timerDump = timers++;
|
|
||||||
|
|
||||||
protected ItemStack[] results;
|
protected ItemStack[] results;
|
||||||
protected float craftTime;
|
protected float craftTime;
|
||||||
protected float spinnerRadius = 2.5f;
|
protected float spinnerRadius = 2.5f;
|
||||||
@@ -116,7 +114,7 @@ public class Separator extends Block{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(entity.timer.get(timerDump, 5)){
|
if(entity.timer.get(timerDump, dumpTime)){
|
||||||
tryDump(tile);
|
tryDump(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user