mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-13 11:29:48 +07:00
Improved cultivator sprite, changed save format of some crafters
This commit is contained in:
parent
1d0063ed39
commit
29051d4281
BIN
core/assets-raw/sprites/blocks/production/cultivator-middle.png
Normal file
BIN
core/assets-raw/sprites/blocks/production/cultivator-middle.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 233 B |
BIN
core/assets-raw/sprites/blocks/production/cultivator-top.png
Normal file
BIN
core/assets-raw/sprites/blocks/production/cultivator-top.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 404 B |
Binary file not shown.
Before Width: | Height: | Size: 410 B After Width: | Height: | Size: 234 B |
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 95 KiB |
@ -1,7 +1,7 @@
|
||||
#Autogenerated file. Do not modify.
|
||||
#Tue Mar 27 21:26:54 EDT 2018
|
||||
#Tue Mar 27 23:14:38 EDT 2018
|
||||
version=release
|
||||
androidBuildCode=681
|
||||
androidBuildCode=686
|
||||
name=Mindustry
|
||||
code=3.4
|
||||
build=custom build
|
||||
|
@ -34,7 +34,6 @@ public class CraftingBlocks {
|
||||
inputs = new ItemStack[]{new ItemStack(Items.titanium, 4), new ItemStack(Items.thorium, 4)};
|
||||
result = Items.densealloy;
|
||||
powerUse = 0.3f;
|
||||
burnDuration = 45f;
|
||||
craftTime = 25f;
|
||||
size = 2;
|
||||
}},
|
||||
@ -44,7 +43,6 @@ public class CraftingBlocks {
|
||||
craftEffect = Fx.smeltsmoke;
|
||||
inputs = new ItemStack[]{new ItemStack(Items.coal, 1), new ItemStack(Items.iron, 1)};
|
||||
result = Items.steel;
|
||||
burnDuration = 45f;
|
||||
powerUse = 0.1f;
|
||||
craftTime = 25f;
|
||||
size = 2;
|
||||
|
@ -3,6 +3,7 @@ package io.anuke.mindustry.content.blocks;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.content.Liquids;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.blocks.types.production.Cultivator;
|
||||
import io.anuke.mindustry.world.blocks.types.production.Drill;
|
||||
import io.anuke.mindustry.world.blocks.types.production.GenericDrill;
|
||||
import io.anuke.mindustry.world.blocks.types.production.SolidPump;
|
||||
@ -93,7 +94,7 @@ public class ProductionBlocks {
|
||||
liquidCapacity = 80f;
|
||||
}},
|
||||
|
||||
cultivator = new GenericDrill("cultivator") {{
|
||||
cultivator = new Cultivator("cultivator") {{
|
||||
resource = Blocks.grass;
|
||||
result = Items.biomatter;
|
||||
inputLiquid = Liquids.water;
|
||||
|
@ -22,6 +22,8 @@ public class Fx{
|
||||
public static Color beamLight = Color.valueOf("ddffe9");
|
||||
|
||||
public static final Effect
|
||||
|
||||
none = new Effect(0, 0f, e->{}),
|
||||
|
||||
generatorexplosion = new Effect(28, 40f, e -> {
|
||||
Angles.randLenVectors(e.id, 16, 10f + e.ifract()*8f, (x, y)->{
|
||||
|
@ -0,0 +1,91 @@
|
||||
package io.anuke.mindustry.world.blocks.types.production;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.graphics.Fx;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.SeedRandom;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Cultivator extends GenericDrill {
|
||||
protected Color plantColor = Color.valueOf("648b55");
|
||||
protected Color plantColorLight = Color.valueOf("73a75f");
|
||||
protected Color bottomColor = Color.valueOf("474747");
|
||||
|
||||
protected SeedRandom random = new SeedRandom(0);
|
||||
protected float recurrence = 6f;
|
||||
|
||||
public Cultivator(String name) {
|
||||
super(name);
|
||||
drillEffect = Fx.none;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tile tile) {
|
||||
super.update(tile);
|
||||
|
||||
CultivatorEntity entity = tile.entity();
|
||||
entity.warmup = Mathf.lerpDelta(entity.warmup,
|
||||
tile.entity.liquid.amount > liquidUse ? 1f : 0f, 0.015f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile) {
|
||||
CultivatorEntity entity = tile.entity();
|
||||
|
||||
Draw.rect(name, tile.drawx(), tile.drawy());
|
||||
|
||||
Draw.color(plantColor);
|
||||
Draw.alpha(entity.warmup);
|
||||
Draw.rect(name + "-middle", tile.drawx(), tile.drawy());
|
||||
|
||||
Draw.color(bottomColor, plantColorLight, entity.warmup);
|
||||
|
||||
random.setSeed(tile.packedPosition());
|
||||
for(int i = 0; i < 12; i ++){
|
||||
float offset = random.nextFloat() * 999999f;
|
||||
float x = random.range(4f), y = random.range(4f);
|
||||
float life = 1f - (((Timers.time() + offset) / 50f) % recurrence);
|
||||
|
||||
if(life > 0){
|
||||
Lines.stroke(entity.warmup * (life*1f + 0.2f));
|
||||
Lines.poly(tile.drawx() + x, tile.drawy() + y, 8, (1f-life) * 3f);
|
||||
}
|
||||
}
|
||||
|
||||
Draw.color();
|
||||
Draw.rect(name + "-top", tile.drawx(), tile.drawy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] getIcon() {
|
||||
return new TextureRegion[]{Draw.region(name), Draw.region(name + "-top"), };
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity() {
|
||||
return new CultivatorEntity();
|
||||
}
|
||||
|
||||
public static class CultivatorEntity extends DrillEntity{
|
||||
public float warmup;
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream stream) throws IOException {
|
||||
stream.writeFloat(warmup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInputStream stream) throws IOException {
|
||||
warmup = stream.readFloat();
|
||||
}
|
||||
}
|
||||
}
|
@ -29,6 +29,15 @@ public class GenericDrill extends Drill{
|
||||
|
||||
DrillEntity entity = tile.entity();
|
||||
|
||||
float multiplier = 0f;
|
||||
|
||||
for(Tile other : tile.getLinkedTiles(tempTiles)){
|
||||
if(isValid(other)){
|
||||
toAdd.add(result == null ? other.floor().drops.item : result);
|
||||
multiplier += 1f;
|
||||
}
|
||||
}
|
||||
|
||||
float powerUsed = Math.min(powerCapacity, powerUse * Timers.delta());
|
||||
float liquidUsed = Math.min(liquidCapacity, liquidUse * Timers.delta());
|
||||
|
||||
@ -36,25 +45,24 @@ public class GenericDrill extends Drill{
|
||||
&& (!hasLiquids || entity.liquid.amount >= liquidUsed)){
|
||||
if(hasPower) entity.power.amount -= powerUsed;
|
||||
if(hasLiquids) entity.liquid.amount -= liquidUsed;
|
||||
entity.time += Timers.delta();
|
||||
entity.time += Timers.delta() * multiplier;
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
|
||||
for(Tile other : tile.getLinkedTiles(tempTiles)){
|
||||
if(isValid(other)){
|
||||
toAdd.add(result == null ? other.floor().drops.item : result);
|
||||
}
|
||||
}
|
||||
|
||||
if(toAdd.size > 0 && entity.time >= drillTime
|
||||
&& tile.entity.inventory.totalItems() < itemCapacity){
|
||||
for(Item item : toAdd) offloadNear(tile, item);
|
||||
Effects.effect(drillEffect, tile.drawx(), tile.drawy());
|
||||
|
||||
int index = entity.index % toAdd.size;
|
||||
offloadNear(tile, toAdd.get(index));
|
||||
|
||||
entity.index ++;
|
||||
entity.time = 0f;
|
||||
|
||||
Effects.effect(drillEffect, tile.drawx(), tile.drawy());
|
||||
}
|
||||
|
||||
if(entity.timer.get(timerDump, 30)){
|
||||
if(entity.timer.get(timerDump, 15)){
|
||||
tryDump(tile);
|
||||
}
|
||||
}
|
||||
@ -78,7 +86,8 @@ public class GenericDrill extends Drill{
|
||||
return new DrillEntity();
|
||||
}
|
||||
|
||||
static class DrillEntity extends TileEntity{
|
||||
public static class DrillEntity extends TileEntity{
|
||||
public float time;
|
||||
public int index;
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,10 @@ import io.anuke.ucore.graphics.Fill;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PowerSmelter extends PowerBlock {
|
||||
protected final int timerDump = timers++;
|
||||
protected final int timerCraft = timers++;
|
||||
@ -32,10 +36,10 @@ public class PowerSmelter extends PowerBlock {
|
||||
protected float minHeat = 0.5f;
|
||||
|
||||
protected float craftTime = 20f; //time to craft one item, so max 3 items per second by default
|
||||
protected float burnDuration = 50f; //by default, the fuel will burn 45 frames, so that's 2.5 items/fuel at most
|
||||
protected float burnEffectChance = 0.01f;
|
||||
protected Effect craftEffect = Fx.smelt,
|
||||
burnEffect = Fx.fuelburn;
|
||||
protected Color flameColor = Color.valueOf("ffc999");
|
||||
|
||||
protected int capacity = 20;
|
||||
|
||||
@ -62,7 +66,6 @@ public class PowerSmelter extends PowerBlock {
|
||||
// stats.add("input", Arrays.toString(inputs));
|
||||
stats.add("powersecond", Strings.toFixed(powerUse *60f, 2));
|
||||
//stats.add("output", result);
|
||||
stats.add("fuelduration", Strings.toFixed(burnDuration/60f, 1));
|
||||
stats.add("maxoutputsecond", Strings.toFixed(60f/craftTime, 1));
|
||||
stats.add("inputcapacity", capacity);
|
||||
stats.add("outputcapacity", capacity);
|
||||
@ -138,7 +141,7 @@ public class PowerSmelter extends PowerBlock {
|
||||
|
||||
Draw.alpha(((1f-g) + Mathf.absin(Timers.time(), 8f, g) + Mathf.random(r) - r) * entity.heat);
|
||||
|
||||
Draw.tint(Color.valueOf("ffc999"));
|
||||
Draw.tint(flameColor);
|
||||
Fill.circle(tile.drawx(), tile.drawy(), 3f + Mathf.absin(Timers.time(), 5f, 2f) + cr);
|
||||
Draw.color(1f, 1f, 1f, entity.heat);
|
||||
Draw.rect(name + "-top", tile.drawx(), tile.drawy());
|
||||
@ -155,5 +158,15 @@ public class PowerSmelter extends PowerBlock {
|
||||
|
||||
class PowerSmelterEntity extends TileEntity{
|
||||
public float heat;
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream stream) throws IOException {
|
||||
stream.writeFloat(heat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInputStream stream) throws IOException {
|
||||
heat = stream.readFloat();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user