1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-11-11 14:56:10 +03:00

Added extended stats and descriptions for all blocks

This commit is contained in:
Anuken 2017-11-21 13:48:14 -05:00
parent 5594c3b704
commit 4788bbf65c
20 changed files with 192 additions and 38 deletions

View File

@ -46,6 +46,7 @@ public class UI extends SceneModule{
MenuDialog menu;
Tooltip tooltip;
Tile configTile;
Array<String> statlist = new Array<>();
boolean wasPaused = false;
VisibilityProvider play = () -> !GameState.is(State.menu);
@ -92,6 +93,10 @@ public class UI extends SceneModule{
Colors.put("description", Color.WHITE);
Colors.put("turretinfo", Color.ORANGE);
Colors.put("iteminfo", Color.LIGHT_GRAY);
Colors.put("powerinfo", Color.YELLOW);
Colors.put("liquidinfo", Color.ROYAL);
Colors.put("craftinfo", Color.LIGHT_GRAY);
Colors.put("missingitems", Color.SCARLET);
Colors.put("health", Color.YELLOW);
Colors.put("interact", Color.ORANGE);
@ -670,6 +675,9 @@ public class UI extends SceneModule{
//extra info
if(recipe.result.fullDescription != null){
header.addButton("?", ()->{
statlist.clear();
recipe.result.getStats(statlist);
Label desclabel = new Label(recipe.result.fullDescription);
desclabel.setWrap(true);
@ -684,10 +692,23 @@ public class UI extends SceneModule{
d.content().add(top).fill().left();
d.content().row();
d.content().add(desclabel).width(600).units(Unit.dp);
d.content().row();
if(statlist.size > 0){
d.content().add("[coral][[extra block info]:").padTop(6).padBottom(5).left();
d.content().row();
}
for(String s : statlist){
d.content().add(s).left();
d.content().row();
}
d.buttons().addButton("OK", ()->{
if(!wasPaused) GameState.set(State.playing);
d.hide();
}).size(110, 50).pad(10f).units(Unit.dp);
d.show();
}).expandX().padLeft(4).top().right().size(36f, 40f).units(Unit.dp);
}

View File

@ -19,6 +19,7 @@ import io.anuke.ucore.util.Tmp;
public class Block{
private static int lastid;
private static Array<Block> blocks = new Array<Block>();
protected static TextureRegion temp = new TextureRegion();
/**internal name*/
@ -76,6 +77,11 @@ public class Block{
public void drawPlace(int x, int y, boolean valid){}
public void postInit(){}
public void getStats(Array<String> list){
list.add("[gray]size: " + width + "x" + height);
list.add("[health]health: " + health);
}
public String name(){
return name;
}

View File

@ -37,6 +37,7 @@ public class DistributionBlocks{
steelconveyor = new Conveyor("steelconveyor"){{
health = 55;
speed = 0.04f;
description = "Moves items faster.";
formalName = "steel conveyor";
fullDescription = "Advanced item transport block. Moves items faster than standard conveyors.";
}},
@ -45,6 +46,7 @@ public class DistributionBlocks{
pulseconveyor = new Conveyor("poweredconveyor"){{
health = 90;
speed = 0.09f;
description = "Moves items even faster.";
formalName = "pulse conveyor";
fullDescription = "The ultimate item transport block. Moves items faster than steel conveyors.";
}},
@ -75,15 +77,18 @@ public class DistributionBlocks{
powerbooster = new PowerBooster("powerbooster"){{
formalName = "power booster";
powerRange = 4;
description = "Distributes power within a radius.";
fullDescription = "Distributes power to all blocks within its radius. ";
}},
powerlaser = new PowerLaser("powerlaser"){{
formalName = "power laser";
description = "Transmits power with a laser.";
fullDescription = "Creates a laser that transmits power to the block in front of it. Does not generate any power itself. "
+ "Best used with generators or other lasers.";
}},
powerlaserrouter = new PowerLaserRouter("powerlaserrouter"){{
formalName = "laser router";
description = "Splits input power into 3 lasers.";
fullDescription = "Laser that distributes power to three directions at once. "
+ "Useful in situations where it is required to power multiple blocks from one generator.";
}},

View File

@ -44,7 +44,7 @@ public class ProductionBlocks{
}},
fluxpump = new Pump("fluxpump"){{
pumpspeed = 3f;
pumpAmount = 3f;
description = "Pumps liquids into nearby conduits.";
fullDescription = "An advanced version of the pump. Stores more liquid and pumps liquid faster.";
}},

View File

@ -14,7 +14,6 @@ import io.anuke.mindustry.world.blocks.types.defense.LaserTurret;
import io.anuke.mindustry.world.blocks.types.defense.PowerTurret;
import io.anuke.mindustry.world.blocks.types.defense.Turret;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
@ -75,20 +74,12 @@ public class WeaponBlocks{
bullet = BulletType.iron;
ammo = Item.iron;
health = 70;
shots = 7;
inaccuracy = 30f;
shotDelayScale = 0.7f;
fullDescription = "A standard turret. Uses iron for ammo. Shoots a spread of 7 bullets. "
+ "Lower range, but higher damage output than the gattling turret.";
}
@Override
protected void shoot(Tile tile){
TurretEntity entity = tile.entity();
for(int i = 0; i < 7; i ++)
Timers.run(i/1.5f, ()->{
Angles.translation(entity.rotation, 4f);
bullet(tile, entity.rotation + Mathf.range(30));
});
}
},
flameturret = new Turret("flameturret"){
@ -195,6 +186,7 @@ public class WeaponBlocks{
health = 430;
width = height = 2;
shootCone = 9f;
shots = 2;
fullDescription = "The ultimate rapid-fire turret. Uses uranium as ammo. Shoots large slugs at a high fire rate. "
+ "Medium range. Spans multiple tiles. Extremely tough.";
}

View File

@ -4,6 +4,8 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.resource.Liquid;
import io.anuke.mindustry.world.Block;
@ -22,6 +24,12 @@ public class LiquidBlock extends Block implements LiquidAcceptor{
update = true;
}
@Override
public void getStats(Array<String> list){
super.getStats(list);
list.add("[liquidinfo]Liquid Capacity: " + liquidCapacity);
}
@Override
public void draw(Tile tile){
LiquidEntity entity = tile.entity();

View File

@ -6,6 +6,7 @@ import java.io.IOException;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.entities.TileEntity;
@ -23,6 +24,12 @@ public abstract class PowerBlock extends Block implements PowerAcceptor{
solid = true;
}
@Override
public void getStats(Array<String> list){
super.getStats(list);
list.add("[powerinfo]Power Capacity: " + powerCapacity);
}
@Override
public void drawPixelOverlay(Tile tile){
PowerEntity entity = tile.entity();

View File

@ -24,11 +24,6 @@ public class LaserTurret extends PowerTurret{
super(name);
}
@Override
public void postInit(){
description = "[turretinfo]Ammo: "+(ammo==null ? "N/A" : ammo.name())+"\nRange: " + (int)range + "\nDamage: " + damage;
}
@Override
public void shoot(Tile tile){
TurretEntity entity = tile.entity();

View File

@ -6,6 +6,7 @@ import java.io.IOException;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.entities.TileEntity;
@ -14,6 +15,7 @@ import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.PowerAcceptor;
import io.anuke.ucore.core.Draw;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Strings;
public class PowerTurret extends Turret implements PowerAcceptor{
public float powerCapacity = 20f;
@ -21,7 +23,14 @@ public class PowerTurret extends Turret implements PowerAcceptor{
public PowerTurret(String name) {
super(name);
ammo = Item.stone;
ammo = null;
}
@Override
public void getStats(Array<String> list){
super.getStats(list);
list.add("[powerinfo]Power Capacity: " + (int)powerCapacity);
list.add("[powerinfo]Power/shot: " + Strings.toFixed(powerUsed, 1));
}
@Override

View File

@ -2,6 +2,7 @@ package io.anuke.mindustry.world.blocks.types.defense;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.World;
@ -10,6 +11,7 @@ import io.anuke.ucore.core.Timers;
import io.anuke.ucore.graphics.Hue;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Strings;
public class RepairTurret extends Turret{
@ -17,6 +19,13 @@ public class RepairTurret extends Turret{
super(name);
}
@Override
public void getStats(Array<String> list){
list.add("[health]health: " + health);
list.add("[turretinfo]Range: " + (int)range);
list.add("[turretinfo]Repairs/Second: " + Strings.toFixed(60f/reload, 1));
}
@Override
public void postInit(){
description = "[turretinfo]Range: " + (int)range + "\n[description]Heals nearby tiles.";

View File

@ -6,6 +6,7 @@ import java.io.IOException;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.Fx;
import io.anuke.mindustry.Vars;
@ -22,6 +23,7 @@ import io.anuke.ucore.core.Timers;
import io.anuke.ucore.entities.Entities;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Strings;
public class Turret extends Block{
static final int targetInterval = 15;
@ -30,6 +32,8 @@ public class Turret extends Block{
protected float range = 50f;
protected float reload = 10f;
protected float inaccuracy = 0f;
protected int shots = 1;
protected float shotDelayScale = 0;
protected String shootsound = "shoot";
protected BulletType bullet = BulletType.iron;
protected Item ammo;
@ -44,9 +48,23 @@ public class Turret extends Block{
solid = true;
}
@Override
public void getStats(Array<String> list){
super.getStats(list);
if(ammo != null) list.add("[turretinfo]Ammo: " + ammo);
if(ammo != null) list.add("[turretinfo]Ammo Capacity: " + maxammo);
if(ammo != null) list.add("[turretinfo]Ammo/Item: " + ammoMultiplier);
list.add("[turretinfo]Range: " + (int)range);
list.add("[turretinfo]Inaccuracy: " + (int)inaccuracy);
list.add("[turretinfo]Damage/Shot: " + bullet.damage);
list.add("[turretinfo]Shots/Second: " + Strings.toFixed(60f/reload, 1));
list.add("[turretinfo]Shots: " + shots);
}
@Override
public void postInit(){
description = "[turretinfo]Ammo: "+(ammo==null ? "N/A" : ammo.name())+"\nRange: " + (int)range + "\nDamage: " + bullet.damage;
description = "[turretinfo]" + (ammo==null ? "" : "Ammo: " + ammo +"\n")
+ "Range: " + (int)range;
}
@Override
@ -110,7 +128,7 @@ public class Turret extends Block{
public void update(Tile tile){
TurretEntity entity = tile.entity();
if(entity.hasItem(ammo)){
if(ammo != null && entity.hasItem(ammo)){
entity.ammo += ammoMultiplier;
entity.removeItem(ammo, 1);
}
@ -197,13 +215,18 @@ public class Turret extends Block{
protected void shoot(Tile tile){
TurretEntity entity = tile.entity();
float inac = Mathf.range(inaccuracy);
Angles.translation(entity.rotation, width * Vars.tilesize / 2f);
Angles.translation(entity.rotation + inac, width * Vars.tilesize / 2f);
Bullet out = new Bullet(bullet, tile.entity,
tile.worldx() + Angles.x(), tile.worldy() + Angles.y(), entity.rotation + inac).add();
out.damage = (int)(bullet.damage*Vars.multiplier);
for(int i = 0; i < shots; i ++){
if(Mathf.zero(shotDelayScale)){
bullet(tile, entity.rotation + Mathf.range(inaccuracy));
}else{
Timers.run(i * shotDelayScale, ()->{
bullet(tile, entity.rotation + Mathf.range(inaccuracy));
});
}
}
}
protected void bullet(Tile tile, float angle){

View File

@ -7,6 +7,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.IntArray;
import io.anuke.mindustry.entities.TileEntity;
@ -15,9 +16,7 @@ import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Draw;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.util.Bits;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Tmp;
import io.anuke.ucore.util.*;
public class Conveyor extends Block{
private static Item[] items = Item.values();
@ -33,6 +32,12 @@ public class Conveyor extends Block{
update = true;
}
@Override
public void getStats(Array<String> list){
super.getStats(list);
list.add("[iteminfo]Move Speed: " + Strings.toFixed(speed * 60, 1) + " units/s");
}
@Override
public boolean canReplace(Block other){
return other instanceof Conveyor || other instanceof Router || other instanceof Junction;

View File

@ -1,5 +1,7 @@
package io.anuke.mindustry.world.blocks.types.distribution;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.production.Generator;
@ -11,6 +13,12 @@ public class PowerBooster extends Generator{
explosive = false;
}
@Override
public void getStats(Array<String> list){
super.getStats(list);
list.add("[powerinfo]Power Range: " + powerRange + " tiles");
}
@Override
public void update(Tile tile){
distributePower(tile);

View File

@ -1,6 +1,7 @@
package io.anuke.mindustry.world.blocks.types.distribution;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.production.Generator;
@ -17,6 +18,12 @@ public class PowerLaser extends Generator{
laserDirections = 1;
}
@Override
public void getStats(Array<String> list){
super.getStats(list);
list.add("[powerinfo]Laser Range: " + laserRange + " tiles");
}
@Override
public void update(Tile tile){
distributeLaserPower(tile);

View File

@ -1,6 +1,7 @@
package io.anuke.mindustry.world.blocks.types.distribution;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap;
import io.anuke.mindustry.Vars;
@ -11,7 +12,7 @@ import io.anuke.ucore.core.Timers;
public class Router extends Block{
private ObjectMap<Tile, Byte> lastmap = new ObjectMap<>();
int maxitems = 20;
int capacity = 20;
public Router(String name) {
super(name);
@ -19,6 +20,12 @@ public class Router extends Block{
solid = true;
}
@Override
public void getStats(Array<String> list){
super.getStats(list);
list.add("[iteminfo]Capacity: " + capacity);
}
@Override
public boolean canReplace(Block other){
return other instanceof Junction || other instanceof Conveyor;
@ -44,13 +51,13 @@ public class Router extends Block{
@Override
public boolean acceptItem(Item item, Tile dest, Tile source){
int items = dest.entity.totalItems();
return items < maxitems;
return items < capacity;
}
@Override
public void drawPixelOverlay(Tile tile){
float fract = (float)tile.entity.totalItems()/maxitems;
float fract = (float)tile.entity.totalItems()/capacity;
Vars.renderer.drawBar(Color.GREEN, tile.worldx(), tile.worldy() + 6, fract);
}

View File

@ -1,5 +1,9 @@
package io.anuke.mindustry.world.blocks.types.production;
import java.util.Arrays;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.Fx;
import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.world.Block;
@ -17,6 +21,13 @@ public class Crafter extends Block{
solid = true;
}
@Override
public void getStats(Array<String> list){
super.getStats(list);
list.add("[craftinfo]Input: " + Arrays.toString(requirements));
list.add("[craftinfo]Output: " + result);
}
@Override
public void update(Tile tile){

View File

@ -3,6 +3,7 @@ package io.anuke.mindustry.world.blocks.types.production;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.GridPoint2;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.Fx;
import io.anuke.mindustry.Vars;
@ -30,6 +31,14 @@ public class Generator extends PowerBlock{
public Generator(String name) {
super(name);
}
@Override
public void getStats(Array<String> list){
super.getStats(list);
if(explosive){
list.add("[orange]Highly explosive!");
}
}
@Override
public void onDestroyed(Tile tile){

View File

@ -1,6 +1,7 @@
package io.anuke.mindustry.world.blocks.types.production;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.Fx;
import io.anuke.mindustry.Vars;
@ -13,13 +14,14 @@ 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.Strings;
public class LiquidCrafter extends LiquidBlock{
/**Can be null.*/
public Item input = null;
public int inputAmount = 5;
public Liquid inputLiquid = null;
public float liquidAmount = 19.99f;
public float liquidAmount = 20f;
public Item output = null;
public int itemCapacity = 90;
public int purifyTime = 80;
@ -31,7 +33,17 @@ public class LiquidCrafter extends LiquidBlock{
rotate = false;
solid = true;
health = 60;
liquidCapacity = 20f;
liquidCapacity = 21f;
}
@Override
public void getStats(Array<String> list){
super.getStats(list);
list.add("[liquidinfo]Max items/second: " + Strings.toFixed(60f/purifyTime, 1));
list.add("[liquidinfo]Input liquid: " + inputLiquid + " x " + (int)liquidAmount);
if(input != null) list.add("[iteminfo]Item Capacity: " + itemCapacity);
if(input != null) list.add("[iteminfo]Input item: " + input + " x " + inputAmount);
list.add("[iteminfo]Output: " + output);
}
@Override

View File

@ -5,6 +5,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.Fx;
import io.anuke.mindustry.entities.TileEntity;
@ -15,6 +16,7 @@ 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.Strings;
public class LiquidPowerGenerator extends Generator implements LiquidAcceptor{
public int generateTime = 5;
@ -30,6 +32,14 @@ public class LiquidPowerGenerator extends Generator implements LiquidAcceptor{
super(name);
}
@Override
public void getStats(Array<String> list){
super.getStats(list);
list.add("[liquidinfo]Liquid Capacity: " + (int)liquidCapacity);
list.add("[liquidinfo]Generation: " + Strings.toFixed(generatePower / inputLiquid, 3) + "power units/liquid unit");
list.add("[liquidinfo]Input: " + generateLiquid);
}
@Override
public void draw(Tile tile){
super.draw(tile);

View File

@ -1,14 +1,18 @@
package io.anuke.mindustry.world.blocks.types.production;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.resource.Liquid;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.LiquidBlock;
import io.anuke.ucore.core.Draw;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Strings;
public class Pump extends LiquidBlock{
protected float pumpspeed = 2f;
protected float pumpAmount = 2f;
protected float pumpTime = 8f;
public Pump(String name) {
super(name);
@ -16,6 +20,12 @@ public class Pump extends LiquidBlock{
solid = true;
}
@Override
public void getStats(Array<String> list){
super.getStats(list);
list.add("[liquidinfo]Pump Speed: " + Strings.toFixed(60f/pumpTime*pumpAmount, 1) + "/s");
}
@Override
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
return false;
@ -49,9 +59,9 @@ public class Pump extends LiquidBlock{
LiquidEntity entity = tile.entity();
if(tile.floor().liquidDrop != null &&
Timers.get(tile, "pump", 8) && entity.liquidAmount < liquidCapacity){
Timers.get(tile, "pump", pumpTime) && entity.liquidAmount < liquidCapacity){
entity.liquid = tile.floor().liquidDrop;
entity.liquidAmount += Math.min(pumpspeed, this.liquidCapacity - entity.liquidAmount);
entity.liquidAmount += Math.min(pumpAmount, this.liquidCapacity - entity.liquidAmount);
}
if(Timers.get(tile, "dump", 1)){