Changed generator style
This commit is contained in:
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 -> {
|
laserspark = new Effect(14, e -> {
|
||||||
Angles.randLenVectors(e.id, 8, 1f + e.ifract()*11f, (x, y)->{
|
Angles.randLenVectors(e.id, 8, 1f + e.ifract()*11f, (x, y)->{
|
||||||
float len = 1f+e.fract()*5f;
|
float len = 1f+e.fract()*5f;
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ public class ProductionBlocks{
|
|||||||
//TODO
|
//TODO
|
||||||
formalName = "coal generator";
|
formalName = "coal generator";
|
||||||
generateItem = Item.coal;
|
generateItem = Item.coal;
|
||||||
generateAmount = 4f;
|
powerOutput = 0.05f;
|
||||||
powerCapacity = 40f;
|
powerCapacity = 40f;
|
||||||
description = "Generates power from coal.";
|
description = "Generates power from coal.";
|
||||||
fullDescription = "The essential generator. Generates power from coal. Outputs power as lasers to its 4 sides.";
|
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";
|
formalName = "thermal generator";
|
||||||
//TODO
|
//TODO
|
||||||
generateLiquid = Liquid.lava;
|
generateLiquid = Liquid.lava;
|
||||||
inputLiquid = 25f;
|
maxLiquidGenerate = 0.5f;
|
||||||
generatePower = 0.5f;
|
powerPerLiquid = 0.09f;
|
||||||
powerCapacity = 40f;
|
powerCapacity = 40f;
|
||||||
description = "Generates power from lava.";
|
description = "Generates power from lava.";
|
||||||
fullDescription = "Generates power from lava. Outputs power as lasers to its 4 sides.";
|
fullDescription = "Generates power from lava. Outputs power as lasers to its 4 sides.";
|
||||||
|
generateEffect = Fx.redgeneratespark;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
combustiongenerator = new LiquidPowerGenerator("combustiongenerator"){
|
combustiongenerator = new LiquidPowerGenerator("combustiongenerator"){
|
||||||
@@ -239,8 +240,8 @@ public class ProductionBlocks{
|
|||||||
formalName = "combustion generator";
|
formalName = "combustion generator";
|
||||||
//TODO
|
//TODO
|
||||||
generateLiquid = Liquid.oil;
|
generateLiquid = Liquid.oil;
|
||||||
inputLiquid = 14f;
|
maxLiquidGenerate = 0.4f;
|
||||||
generatePower = 1f;
|
powerPerLiquid = 0.13f;
|
||||||
powerCapacity = 40f;
|
powerCapacity = 40f;
|
||||||
description = "Generates power from oil.";
|
description = "Generates power from oil.";
|
||||||
fullDescription = "Generates power from oil. Outputs power as lasers to its 4 sides.";
|
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
|
//TODO make this generate slowly
|
||||||
formalName = "RTG generator";
|
formalName = "RTG generator";
|
||||||
generateItem = Item.uranium;
|
generateItem = Item.uranium;
|
||||||
generateAmount = 10f;
|
|
||||||
powerCapacity = 40f;
|
powerCapacity = 40f;
|
||||||
generateTime = 50f;
|
powerOutput = 0.055f;
|
||||||
|
itemDuration = 250f;
|
||||||
description = "Generates power from uranium.";
|
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.";
|
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 static class PowerEntity extends TileEntity{
|
||||||
public float power;
|
public float power;
|
||||||
|
public float time; //generator time. this is a bit of a hack
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutputStream stream) throws IOException{
|
public void write(DataOutputStream stream) throws IOException{
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ public class ShieldBlock extends PowerBlock{
|
|||||||
@Override
|
@Override
|
||||||
public void getStats(Array<String> list){
|
public void getStats(Array<String> list){
|
||||||
super.getStats(list);
|
super.getStats(list);
|
||||||
list.add("[powerinfo]Power Drain/second: " + Strings.toFixed(powerDrain*60, 2));
|
list.add("[powerinfo]Power used: " + Strings.toFixed(powerDrain*60, 2) + "power/s");
|
||||||
list.add("[powerinfo]Power Drain/damage taken: " + Strings.toFixed(powerPerDamage, 2));
|
list.add("[powerinfo]Power Drain: " + Strings.toFixed(powerPerDamage, 2) + "power/damage");
|
||||||
list.add("[powerinfo]Shield Radius: " + (int)shieldRadius + " units");
|
list.add("[powerinfo]Shield Radius: " + (int)shieldRadius + " units");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +1,58 @@
|
|||||||
package io.anuke.mindustry.world.blocks.types.production;
|
package io.anuke.mindustry.world.blocks.types.production;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.entities.effect.Fx;
|
import io.anuke.mindustry.entities.effect.Fx;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.ucore.core.Draw;
|
||||||
import io.anuke.ucore.core.Effects;
|
import io.anuke.ucore.core.Effects;
|
||||||
|
import io.anuke.ucore.core.Effects.Effect;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
import io.anuke.ucore.util.Strings;
|
||||||
|
|
||||||
public class ItemPowerGenerator extends Generator{
|
public class ItemPowerGenerator extends Generator{
|
||||||
public int itemCapacity = 20;
|
public int itemCapacity = 20;
|
||||||
public Item generateItem;
|
public Item generateItem;
|
||||||
public float generateAmount;
|
public float powerOutput;
|
||||||
public float generateTime = 2f;
|
public float itemDuration = 70f;
|
||||||
|
public Effect generateEffect = Fx.generatespark;
|
||||||
|
public Color heatColor = Color.valueOf("ff9b59");
|
||||||
|
|
||||||
public ItemPowerGenerator(String name) {
|
public ItemPowerGenerator(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
outputOnly = true;
|
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
|
@Override
|
||||||
public void drawPixelOverlay(Tile tile){
|
public void drawPixelOverlay(Tile tile){
|
||||||
super.drawPixelOverlay(tile);
|
super.drawPixelOverlay(tile);
|
||||||
@@ -40,9 +72,19 @@ public class ItemPowerGenerator extends Generator{
|
|||||||
public void update(Tile tile){
|
public void update(Tile tile){
|
||||||
PowerEntity entity = tile.entity();
|
PowerEntity entity = tile.entity();
|
||||||
|
|
||||||
if(Timers.get(tile, "generate", generateTime) && entity.hasItem(generateItem) && tryAddPower(tile, generateAmount)){
|
float maxPower = Math.min(powerCapacity - entity.power, powerOutput);
|
||||||
Effects.effect(Fx.generate, tile.entity);
|
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.removeItem(generateItem, 1);
|
||||||
|
entity.time = 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
distributeLaserPower(tile);
|
distributeLaserPower(tile);
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ import io.anuke.mindustry.entities.TileEntity;
|
|||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.core.Draw;
|
import io.anuke.ucore.core.Draw;
|
||||||
import io.anuke.ucore.core.Effects;
|
|
||||||
import io.anuke.ucore.core.Timers;
|
|
||||||
|
|
||||||
public class LiquidItemPowerGenerator extends LiquidPowerGenerator{
|
public class LiquidItemPowerGenerator extends LiquidPowerGenerator{
|
||||||
public Item generateItem;
|
public Item generateItem;
|
||||||
@@ -33,6 +31,8 @@ public class LiquidItemPowerGenerator extends LiquidPowerGenerator{
|
|||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO implement?
|
||||||
|
/*
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void update(Tile tile){
|
||||||
LiquidPowerEntity entity = tile.entity();
|
LiquidPowerEntity entity = tile.entity();
|
||||||
@@ -50,7 +50,7 @@ public class LiquidItemPowerGenerator extends LiquidPowerGenerator{
|
|||||||
|
|
||||||
distributeLaserPower(tile);
|
distributeLaserPower(tile);
|
||||||
|
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
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;
|
||||||
import io.anuke.ucore.core.Effects.Effect;
|
import io.anuke.ucore.core.Effects.Effect;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
import io.anuke.ucore.util.Strings;
|
import io.anuke.ucore.util.Strings;
|
||||||
|
|
||||||
public class LiquidPowerGenerator extends Generator implements LiquidAcceptor{
|
public class LiquidPowerGenerator extends Generator implements LiquidAcceptor{
|
||||||
public int generateTime = 15;
|
public int generateTime = 15;
|
||||||
public Liquid generateLiquid;
|
public Liquid generateLiquid;
|
||||||
/**Power to generate per generateInput.*/
|
public float powerPerLiquid = 0.13f;
|
||||||
public float generatePower = 1f;
|
/**Maximum liquid used per frame.*/
|
||||||
/**How much liquid to consume to get one generatePower.*/
|
public float maxLiquidGenerate = 0.4f;
|
||||||
public float inputLiquid = 5f;
|
|
||||||
public float liquidCapacity = 30f;
|
public float liquidCapacity = 30f;
|
||||||
public Effect generateEffect = Fx.generate;
|
public Effect generateEffect = Fx.generatespark;
|
||||||
|
|
||||||
public LiquidPowerGenerator(String name) {
|
public LiquidPowerGenerator(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
@@ -37,7 +37,8 @@ public class LiquidPowerGenerator extends Generator implements LiquidAcceptor{
|
|||||||
public void getStats(Array<String> list){
|
public void getStats(Array<String> list){
|
||||||
super.getStats(list);
|
super.getStats(list);
|
||||||
list.add("[liquidinfo]Liquid Capacity: " + (int)liquidCapacity);
|
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);
|
list.add("[liquidinfo]Input: " + generateLiquid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,13 +66,17 @@ public class LiquidPowerGenerator extends Generator implements LiquidAcceptor{
|
|||||||
LiquidPowerEntity entity = tile.entity();
|
LiquidPowerEntity entity = tile.entity();
|
||||||
|
|
||||||
//TODO don't generate when full of energy
|
//TODO don't generate when full of energy
|
||||||
if(entity.liquidAmount >= inputLiquid && entity.power + generatePower < powerCapacity
|
if(entity.liquidAmount > 0){
|
||||||
&& Timers.get(tile, "consume", generateTime)){
|
float used = Math.min(entity.liquidAmount, maxLiquidGenerate);
|
||||||
entity.liquidAmount -= inputLiquid;
|
used = Math.min(used, (powerCapacity - entity.power)/powerPerLiquid);
|
||||||
entity.power += generatePower;
|
|
||||||
|
|
||||||
Vector2 offset = getPlaceOffset();
|
entity.liquidAmount -= used;
|
||||||
Effects.effect(generateEffect, tile.worldx() + offset.x, tile.worldy() + offset.y);
|
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);
|
distributeLaserPower(tile);
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user