mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-03 13:30:25 +07:00
Changed generator style
This commit is contained in:
parent
c461c80122
commit
d9ed5bfd98
BIN
core/assets-raw/sprites/blocks/coalgenerator-top.png
Normal file
BIN
core/assets-raw/sprites/blocks/coalgenerator-top.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 304 B |
BIN
core/assets-raw/sprites/blocks/rtgenerator-top.png
Normal file
BIN
core/assets-raw/sprites/blocks/rtgenerator-top.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 307 B |
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB |
@ -143,6 +143,26 @@ public class Fx{
|
||||
});
|
||||
}),
|
||||
|
||||
redgeneratespark = new Effect(18, e -> {
|
||||
Angles.randLenVectors(e.id, 5, e.ifract()*8f, (x, y)->{
|
||||
float len = e.fract()*4f;
|
||||
Draw.color(Color.valueOf("fbb97f"), Color.GRAY, e.ifract());
|
||||
//Draw.alpha(e.fract());
|
||||
Draw.rect("circle", e.x + x, e.y + y, len, len);
|
||||
Draw.reset();
|
||||
});
|
||||
}),
|
||||
|
||||
generatespark = new Effect(18, e -> {
|
||||
Angles.randLenVectors(e.id, 5, e.ifract()*8f, (x, y)->{
|
||||
float len = e.fract()*4f;
|
||||
Draw.color(Color.valueOf("d2b29c"), Color.GRAY, e.ifract());
|
||||
//Draw.alpha(e.fract());
|
||||
Draw.rect("circle", e.x + x, e.y + y, len, len);
|
||||
Draw.reset();
|
||||
});
|
||||
}),
|
||||
|
||||
laserspark = new Effect(14, e -> {
|
||||
Angles.randLenVectors(e.id, 8, 1f + e.ifract()*11f, (x, y)->{
|
||||
float len = 1f+e.fract()*5f;
|
||||
|
@ -216,7 +216,7 @@ public class ProductionBlocks{
|
||||
//TODO
|
||||
formalName = "coal generator";
|
||||
generateItem = Item.coal;
|
||||
generateAmount = 4f;
|
||||
powerOutput = 0.05f;
|
||||
powerCapacity = 40f;
|
||||
description = "Generates power from coal.";
|
||||
fullDescription = "The essential generator. Generates power from coal. Outputs power as lasers to its 4 sides.";
|
||||
@ -227,11 +227,12 @@ public class ProductionBlocks{
|
||||
formalName = "thermal generator";
|
||||
//TODO
|
||||
generateLiquid = Liquid.lava;
|
||||
inputLiquid = 25f;
|
||||
generatePower = 0.5f;
|
||||
maxLiquidGenerate = 0.5f;
|
||||
powerPerLiquid = 0.09f;
|
||||
powerCapacity = 40f;
|
||||
description = "Generates power from lava.";
|
||||
fullDescription = "Generates power from lava. Outputs power as lasers to its 4 sides.";
|
||||
generateEffect = Fx.redgeneratespark;
|
||||
}
|
||||
},
|
||||
combustiongenerator = new LiquidPowerGenerator("combustiongenerator"){
|
||||
@ -239,8 +240,8 @@ public class ProductionBlocks{
|
||||
formalName = "combustion generator";
|
||||
//TODO
|
||||
generateLiquid = Liquid.oil;
|
||||
inputLiquid = 14f;
|
||||
generatePower = 1f;
|
||||
maxLiquidGenerate = 0.4f;
|
||||
powerPerLiquid = 0.13f;
|
||||
powerCapacity = 40f;
|
||||
description = "Generates power from oil.";
|
||||
fullDescription = "Generates power from oil. Outputs power as lasers to its 4 sides.";
|
||||
@ -251,9 +252,9 @@ public class ProductionBlocks{
|
||||
//TODO make this generate slowly
|
||||
formalName = "RTG generator";
|
||||
generateItem = Item.uranium;
|
||||
generateAmount = 10f;
|
||||
powerCapacity = 40f;
|
||||
generateTime = 50f;
|
||||
powerOutput = 0.055f;
|
||||
itemDuration = 250f;
|
||||
description = "Generates power from uranium.";
|
||||
fullDescription = "Generates small amounts of power from the radioactive decay of uranium. Outputs power as lasers to its 4 sides.";
|
||||
}
|
||||
|
@ -90,6 +90,7 @@ public abstract class PowerBlock extends Block implements PowerAcceptor{
|
||||
|
||||
public static class PowerEntity extends TileEntity{
|
||||
public float power;
|
||||
public float time; //generator time. this is a bit of a hack
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream stream) throws IOException{
|
||||
|
@ -31,8 +31,8 @@ public class ShieldBlock extends PowerBlock{
|
||||
@Override
|
||||
public void getStats(Array<String> list){
|
||||
super.getStats(list);
|
||||
list.add("[powerinfo]Power Drain/second: " + Strings.toFixed(powerDrain*60, 2));
|
||||
list.add("[powerinfo]Power Drain/damage taken: " + Strings.toFixed(powerPerDamage, 2));
|
||||
list.add("[powerinfo]Power used: " + Strings.toFixed(powerDrain*60, 2) + "power/s");
|
||||
list.add("[powerinfo]Power Drain: " + Strings.toFixed(powerPerDamage, 2) + "power/damage");
|
||||
list.add("[powerinfo]Shield Radius: " + (int)shieldRadius + " units");
|
||||
}
|
||||
|
||||
|
@ -1,26 +1,58 @@
|
||||
package io.anuke.mindustry.world.blocks.types.production;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.effect.Fx;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Effects.Effect;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
public class ItemPowerGenerator extends Generator{
|
||||
public int itemCapacity = 20;
|
||||
public Item generateItem;
|
||||
public float generateAmount;
|
||||
public float generateTime = 2f;
|
||||
public float powerOutput;
|
||||
public float itemDuration = 70f;
|
||||
public Effect generateEffect = Fx.generatespark;
|
||||
public Color heatColor = Color.valueOf("ff9b59");
|
||||
|
||||
public ItemPowerGenerator(String name) {
|
||||
super(name);
|
||||
outputOnly = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getStats(Array<String> list){
|
||||
super.getStats(list);
|
||||
list.add("[powerinfo]Item Capacity: " + itemCapacity);
|
||||
list.add("[powerinfo]Generation: " + Strings.toFixed(powerOutput*60f, 2) + " power/s");
|
||||
list.add("[powerinfo]Generation Time: " + Strings.toFixed(itemDuration/60f, 2) + " s/item");
|
||||
list.add("[powerinfo]Input: " + generateItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
super.draw(tile);
|
||||
|
||||
PowerEntity entity = tile.entity();
|
||||
|
||||
if(entity.time > 0){
|
||||
Draw.color(heatColor);
|
||||
float alpha = (entity.hasItem(generateItem) ? 1f : Mathf.clamp(entity.time));
|
||||
alpha = alpha * 0.7f + Mathf.absin(Timers.time(), 12f, 0.3f) * alpha;
|
||||
Draw.alpha(alpha);
|
||||
Draw.rect(name + "-top", tile.worldx(), tile.worldy());
|
||||
Draw.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPixelOverlay(Tile tile){
|
||||
super.drawPixelOverlay(tile);
|
||||
@ -40,9 +72,19 @@ public class ItemPowerGenerator extends Generator{
|
||||
public void update(Tile tile){
|
||||
PowerEntity entity = tile.entity();
|
||||
|
||||
if(Timers.get(tile, "generate", generateTime) && entity.hasItem(generateItem) && tryAddPower(tile, generateAmount)){
|
||||
Effects.effect(Fx.generate, tile.entity);
|
||||
float maxPower = Math.min(powerCapacity - entity.power, powerOutput);
|
||||
float mfract = maxPower/powerOutput;
|
||||
|
||||
if(entity.time > 0f){
|
||||
entity.time -= 1f/itemDuration*mfract;
|
||||
entity.power += maxPower;
|
||||
entity.time = Mathf.clamp(entity.time);
|
||||
}
|
||||
|
||||
if(entity.time <= 0f && entity.hasItem(generateItem)){
|
||||
Effects.effect(generateEffect, tile.worldx() + Mathf.range(3f), tile.worldy() + Mathf.range(3f));
|
||||
entity.removeItem(generateItem, 1);
|
||||
entity.time = 1f;
|
||||
}
|
||||
|
||||
distributeLaserPower(tile);
|
||||
|
@ -8,8 +8,6 @@ import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
|
||||
public class LiquidItemPowerGenerator extends LiquidPowerGenerator{
|
||||
public Item generateItem;
|
||||
@ -33,6 +31,8 @@ public class LiquidItemPowerGenerator extends LiquidPowerGenerator{
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
//TODO implement?
|
||||
/*
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
LiquidPowerEntity entity = tile.entity();
|
||||
@ -50,7 +50,7 @@ public class LiquidItemPowerGenerator extends LiquidPowerGenerator{
|
||||
|
||||
distributeLaserPower(tile);
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
|
@ -16,17 +16,17 @@ import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Effects.Effect;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
public class LiquidPowerGenerator extends Generator implements LiquidAcceptor{
|
||||
public int generateTime = 15;
|
||||
public Liquid generateLiquid;
|
||||
/**Power to generate per generateInput.*/
|
||||
public float generatePower = 1f;
|
||||
/**How much liquid to consume to get one generatePower.*/
|
||||
public float inputLiquid = 5f;
|
||||
public float powerPerLiquid = 0.13f;
|
||||
/**Maximum liquid used per frame.*/
|
||||
public float maxLiquidGenerate = 0.4f;
|
||||
public float liquidCapacity = 30f;
|
||||
public Effect generateEffect = Fx.generate;
|
||||
public Effect generateEffect = Fx.generatespark;
|
||||
|
||||
public LiquidPowerGenerator(String name) {
|
||||
super(name);
|
||||
@ -37,7 +37,8 @@ public class LiquidPowerGenerator extends Generator implements LiquidAcceptor{
|
||||
public void getStats(Array<String> list){
|
||||
super.getStats(list);
|
||||
list.add("[liquidinfo]Liquid Capacity: " + (int)liquidCapacity);
|
||||
list.add("[liquidinfo]Generation: " + Strings.toFixed(generatePower / inputLiquid, 2) + " power/liquid");
|
||||
list.add("[liquidinfo]Generation: " + Strings.toFixed(powerPerLiquid, 2) + " power/liquid");
|
||||
list.add("[liquidinfo]Max liquid: " + Strings.toFixed(maxLiquidGenerate*60f, 2) + " liquid/s");
|
||||
list.add("[liquidinfo]Input: " + generateLiquid);
|
||||
}
|
||||
|
||||
@ -65,13 +66,17 @@ public class LiquidPowerGenerator extends Generator implements LiquidAcceptor{
|
||||
LiquidPowerEntity entity = tile.entity();
|
||||
|
||||
//TODO don't generate when full of energy
|
||||
if(entity.liquidAmount >= inputLiquid && entity.power + generatePower < powerCapacity
|
||||
&& Timers.get(tile, "consume", generateTime)){
|
||||
entity.liquidAmount -= inputLiquid;
|
||||
entity.power += generatePower;
|
||||
if(entity.liquidAmount > 0){
|
||||
float used = Math.min(entity.liquidAmount, maxLiquidGenerate);
|
||||
used = Math.min(used, (powerCapacity - entity.power)/powerPerLiquid);
|
||||
|
||||
Vector2 offset = getPlaceOffset();
|
||||
Effects.effect(generateEffect, tile.worldx() + offset.x, tile.worldy() + offset.y);
|
||||
entity.liquidAmount -= used;
|
||||
entity.power += used * powerPerLiquid;
|
||||
|
||||
if(used > 0.001f && Mathf.chance(0.05 * Timers.delta())){
|
||||
Vector2 offset = getPlaceOffset();
|
||||
Effects.effect(generateEffect, tile.worldx() + offset.x + Mathf.range(3f), tile.worldy() + offset.y + Mathf.range(3f));
|
||||
}
|
||||
}
|
||||
|
||||
distributeLaserPower(tile);
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user