mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-03-15 03:11:07 -07:00
Consistent output timer
This commit is contained in:
parent
6113edf2ce
commit
f825931f92
6 changed files with 19 additions and 14 deletions
|
|
@ -5,6 +5,7 @@ import io.anuke.arc.math.Mathf;
|
|||
import io.anuke.arc.util.Pack;
|
||||
import io.anuke.arc.util.noise.RidgedPerlin;
|
||||
import io.anuke.arc.util.noise.Simplex;
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.editor.MapEditor;
|
||||
import io.anuke.mindustry.editor.MapGenerateDialog.DummyTile;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
|
|
@ -50,6 +51,10 @@ public abstract class GenerateFilter{
|
|||
public final void apply(GenerateInput in){
|
||||
this.in = in;
|
||||
apply();
|
||||
//remove extra ores on liquids
|
||||
if(((Floor)in.floor).isLiquid){
|
||||
in.ore = Blocks.air;
|
||||
}
|
||||
}
|
||||
|
||||
public static class GenerateInput{
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ public class OreFilter extends GenerateFilter{
|
|||
|
||||
{
|
||||
options(
|
||||
new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f),
|
||||
new SliderOption("threshold", () -> threshold, f -> threshold = f, 0f, 1f),
|
||||
new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f),
|
||||
new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f),
|
||||
new BlockOption("ore", () -> ore, b -> ore = b, oresOnly)
|
||||
new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f),
|
||||
new SliderOption("threshold", () -> threshold, f -> threshold = f, 0f, 1f),
|
||||
new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f),
|
||||
new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f),
|
||||
new BlockOption("ore", () -> ore, b -> ore = b, oresOnly)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ public class OreFilter extends GenerateFilter{
|
|||
public void apply(){
|
||||
float noise = noise(in.x, in.y, scl, 1f, octaves, falloff);
|
||||
|
||||
if(noise > threshold && !in.srcfloor.isLiquid){
|
||||
if(noise > threshold){
|
||||
in.ore = ore;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,6 +113,11 @@ public class Block extends BlockStorage{
|
|||
protected TextureRegion[] variantRegions, editorVariantRegions;
|
||||
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){
|
||||
super(name);
|
||||
this.description = Core.bundle.getOrNull("block." + name + ".description");
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import static io.anuke.mindustry.Vars.content;
|
|||
|
||||
public class Drill extends Block{
|
||||
protected final static float hardnessDrillMultiplier = 50f;
|
||||
protected final int timerDump = timers++;
|
||||
|
||||
protected final ObjectIntMap<Item> oreCount = new ObjectIntMap<>();
|
||||
protected final Array<Item> itemArray = new Array<>();
|
||||
|
|
@ -192,7 +191,7 @@ public class Drill extends Block{
|
|||
|
||||
float totalHardness = entity.dominantItems * entity.dominantItem.hardness;
|
||||
|
||||
if(entity.timer.get(timerDump, 5)){
|
||||
if(entity.timer.get(timerDump, dumpTime)){
|
||||
tryDump(tile, entity.dominantItem);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ import io.anuke.mindustry.world.meta.StatUnit;
|
|||
import java.io.*;
|
||||
|
||||
public class GenericCrafter extends Block{
|
||||
protected final int timerDump = timers++;
|
||||
|
||||
protected ItemStack outputItem;
|
||||
protected LiquidStack outputLiquid;
|
||||
|
||||
|
|
@ -110,7 +108,7 @@ public class GenericCrafter extends Block{
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*/
|
||||
public class Separator extends Block{
|
||||
protected final int timerDump = timers++;
|
||||
|
||||
protected ItemStack[] results;
|
||||
protected float craftTime;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue