Fortress builtin map / Attributes / Efficiency stat / Bugfixes

This commit is contained in:
Anuken
2019-03-12 23:39:39 -04:00
parent 4d4869842e
commit ecb77b0283
52 changed files with 1247 additions and 1146 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 977 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 995 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -300,7 +300,8 @@ no = No
info.title = Info
error.title = [crimson]An error has occured
error.crashtitle = An error has occured
blocks.outputspeed = Drill Speed: {0}/s
blocks.outputspeed = Drill Speed: {0}/
blocks.efficiency = Efficiency: {0}%
blocks.unknown = [LIGHT_GRAY]???
blocks.blockinfo = Block Info
blocks.powerbalance = Power: {0}
@ -525,6 +526,16 @@ mech.ability = [LIGHT_GRAY]Ability: {0}
liquid.heatcapacity = [LIGHT_GRAY]Heat Capacity: {0}
liquid.viscosity = [LIGHT_GRAY]Viscosity: {0}
liquid.temperature = [LIGHT_GRAY]Temperature: {0}
block.grass.name = Grass
block.salt.name = Salt
block.sandrocks.name = Sand Rocks
block.spore-pine.name = Spore Pine
block.shale.name = Shale
block.shale-boulder.name = Shale Boulder
block.moss.name = Moss
block.spore-moss.name = Spore Moss
block.shalerocks.name = Shale Rocks
block.scrap-wall.name = Scrap Wall
block.scrap-wall-large.name = Large Scrap Wall
block.scrap-wall-huge.name = Huge Scrap Wall
@ -559,12 +570,6 @@ block.pine.name = Pine
block.white-tree-dead.name = White Tree Dead
block.white-tree.name = White Tree
block.spore-cluster.name = Spore Cluster
block.stained-rocks.name = Stained Rocks
block.stained-rocks-red.name = Stained Rocks Red
block.stained-stone-red.name = Stained Stone Red
block.stained-rocks-yellow.name = Stained Rocks Yellow
block.stained-stone-yellow.name = Stained Stone Yellow
block.stained-boulder.name = Stained Boulder
block.metal-floor.name = Metal Floor
block.metal-floor-2.name = Metal Floor 2
block.metal-floor-3.name = Metal Floor 3

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 497 B

After

Width:  |  Height:  |  Size: 500 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 KiB

After

Width:  |  Height:  |  Size: 237 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 165 KiB

After

Width:  |  Height:  |  Size: 192 KiB

View File

@ -23,7 +23,7 @@ import java.io.IOException;
import static io.anuke.mindustry.Vars.*;
public class WaveSpawner{
private static final float shockwaveBase = 380f, shockwaveRand = 50f, maxShockwaveDst = shockwaveBase + shockwaveRand;
private static final float shockwaveBase = 380f, shockwaveRand = 0f, maxShockwaveDst = shockwaveBase + shockwaveRand;
private Array<SpawnGroup> groups;
private Array<FlyerSpawn> flySpawns = new Array<>();
private Array<GroundSpawn> groundSpawns = new Array<>();

View File

@ -26,6 +26,7 @@ import io.anuke.mindustry.world.blocks.units.RepairPoint;
import io.anuke.mindustry.world.blocks.units.UnitFactory;
import io.anuke.mindustry.world.consumers.ConsumeItemFilter;
import io.anuke.mindustry.world.consumers.ConsumeLiquidFilter;
import io.anuke.mindustry.world.meta.Attribute;
import static io.anuke.mindustry.Vars.state;
import static io.anuke.mindustry.Vars.world;
@ -36,7 +37,7 @@ public class Blocks implements ContentList{
//environment
air, part, spawn, deepwater, water, tar, stone, craters, charr, sand, ice, snow,
holostone, rocks, icerocks, cliffs, sporePine, pine, whiteTree, whiteTreeDead, sporeCluster,
iceSnow, sandWater, duneRocks, sandRocks, stainedRocks, moss, stainedRocksRed, stainedStoneRed, stainedRocksYellow, stainedStoneYellow, stainedBoulder, grass, salt,
iceSnow, sandWater, duneRocks, sandRocks, moss, sporeMoss, shale, shaleRocks, shaleBoulder, grass, salt,
metalFloor, metalFloorDamaged, metalFloor2, metalFloor3, metalFloor5, ignarock, magmarock, hotrock, snowrocks,
//ores
@ -190,15 +191,18 @@ public class Blocks implements ContentList{
iceSnow = new Floor("ice-snow"){{
variants = 3;
attributes.set(Attribute.water, 0.3f);
}};
snow = new Floor("snow"){{
attributes.set(Attribute.water, 0.2f);
}};
ice = new Floor("ice"){{
//TODO fix
//TODO fix drag/speed
dragMultiplier = 1f;
speedMultiplier = 1f;
attributes.set(Attribute.water, 0.4f);
}};
cliffs = new StaticWall("cliffs"){{
@ -244,32 +248,27 @@ public class Blocks implements ContentList{
variants = 3;
}};
stainedRocks = new StaticWall("stained-rocks"){{
shale = new Floor("shale"){{
variants = 3;
attributes.set(Attribute.oil, 0.3f);
}};
shaleRocks = new StaticWall("shalerocks"){{
variants = 2;
}};
shaleBoulder = new Rock("shale-boulder"){{
variants = 2;
}};
moss = new Floor("moss"){{
variants = 3;
attributes.set(Attribute.spores, 0.15f);
}};
stainedRocksRed = new StaticWall("stained-rocks-red"){{
variants = 2;
}};
stainedStoneRed = new Floor("stained-stone-red"){{
variants = 1;
}};
stainedRocksYellow = new StaticWall("stained-rocks-yellow"){{
variants = 2;
}};
stainedStoneYellow = new Floor("stained-stone-yellow"){{
variants = 1;
}};
stainedBoulder = new Rock("stained-boulder"){{
variants = 2;
sporeMoss = new Floor("spore-moss"){{
variants = 3;
attributes.set(Attribute.spores, 0.3f);
}};
metalFloor = new Floor("metal-floor"){{
@ -278,22 +277,18 @@ public class Blocks implements ContentList{
metalFloorDamaged = new Floor("metal-floor-damaged"){{
variants = 6;
blendGroup = metalFloor;
}};
metalFloor2 = new Floor("metal-floor-2"){{
variants = 0;
blendGroup = metalFloor;
}};
metalFloor3 = new Floor("metal-floor-3"){{
variants = 0;
blendGroup = metalFloor;
}};
metalFloor5 = new Floor("metal-floor-5"){{
variants = 0;
blendGroup = metalFloor;
}};
ignarock = new Floor("ignarock"){{
@ -301,12 +296,12 @@ public class Blocks implements ContentList{
}};
hotrock = new Floor("hotrock"){{
heat = 0.5f;
attributes.set(Attribute.heat, 0.5f);
blendGroup = ignarock;
}};
magmarock = new Floor("magmarock"){{
heat = 0.75f;
attributes.set(Attribute.heat, 0.75f);
updateEffect = Fx.magmasmoke;
blendGroup = ignarock;
}};
@ -975,6 +970,7 @@ public class Blocks implements ContentList{
size = 2;
liquidCapacity = 30f;
rotateSpeed = 1.4f;
attribute = Attribute.water;
consumes.power(0.90f);
}};
@ -988,6 +984,7 @@ public class Blocks implements ContentList{
pumpAmount = 0.25f;
size = 3;
liquidCapacity = 30f;
attribute = Attribute.oil;
consumes.item(Items.sand);
consumes.power(3f);

View File

@ -279,7 +279,7 @@ public class Zones implements ContentList{
stainedMountains = new Zone("stainedMountains", new MapGenerator("stainedMountains", 2)
.dist(2.5f, true)
.decor(new Decoration(Blocks.moss, Blocks.stainedBoulder, 0.01))){{
.decor(new Decoration(Blocks.moss, Blocks.shaleBoulder, 0.02))){{
loadout = Loadouts.basicFoundation;
baseLaunchCost = ItemStack.with(Items.copper, 100, Items.lead, 200, Items.silicon, 100);
startingItems = ItemStack.list(Items.copper, 400, Items.lead, 100);

View File

@ -110,6 +110,13 @@ public class Control implements ApplicationListener{
//todo high scores for custom maps, as well as other statistics
Events.on(WaveEvent.class, event -> {
if(world.getMap().getHightScore() < state.wave){
hiscore = true;
world.getMap().setHighScore(state.wave);
}
});
Events.on(GameOverEvent.class, event -> {
state.stats.wavesLasted = state.wave;
Effects.shake(5, 6, Core.camera.position.x, Core.camera.position.y);

View File

@ -44,8 +44,15 @@ public class MapIO{
private static void initBlocks(){
if(missingBlocks != null) return;
//stainedRocks, stainedRocksRed, stainedRocksYellow, stainedStoneYellow, stainedBoulder,
missingBlocks = ObjectMap.of(
"stained-stone", Blocks.moss
"stained-stone", Blocks.shale,
"stained-stone-red", Blocks.shale,
"stained-stone-yellow", Blocks.shale,
"stained-rocks", Blocks.shaleRocks,
"stained-boulder", Blocks.shaleBoulder,
"stained-rocks-red", Blocks.shaleRocks,
"stained-rocks-yellow", Blocks.shaleRocks
);
}
@ -74,8 +81,7 @@ public class MapIO{
@Override
public void setOreByte(byte b){
if(b != 0)
floor.drawPixel(x, floor.getHeight() - 1 - y, colorFor(floor(), Blocks.air, content.block(b), getTeam()));
if(b != 0) floor.drawPixel(x, floor.getHeight() - 1 - y, colorFor(floor(), Blocks.air, content.block(b), getTeam()));
}
@Override
@ -165,7 +171,7 @@ public class MapIO{
stream.writeByte(tile.link);
}else if(tile.entity != null){
stream.writeByte(Pack.byteByte(tile.getTeamID(), tile.getRotation())); //team + rotation
stream.writeShort((short)tile.entity.health); //health
stream.writeShort(/*(short)tile.entity.health*/tile.block().health); //health
tile.entity.writeConfig(stream);
}else{
//write consecutive non-entity blocks
@ -267,13 +273,13 @@ public class MapIO{
Tile tile = tiles.get(x, y);
tile.setFloor((Floor)content.block(floorid));
tile.setOreByte(oreid);
tile.setOre(content.block(oreid));
for(int j = i + 1; j < i + 1 + consecutives; j++){
int newx = j % width, newy = j / width;
Tile newTile = tiles.get(newx, newy);
newTile.setFloor((Floor)content.block(floorid));
newTile.setOreByte(oreid);
newTile.setOre(content.block(oreid));
}
i += consecutives;
@ -297,7 +303,7 @@ public class MapIO{
byte rotation = Pack.rightByte(tr);
tile.setTeam(Team.all[team]);
tile.entity.health = health;
tile.entity.health = /*health*/tile.block().health;
tile.setRotation(rotation);
tile.entity.readConfig(stream);
@ -432,7 +438,7 @@ public class MapIO{
}
if(oreMap.containsKey(floorb)){
tile.setOreByte((byte)oreMap.get(floorb, 0));
tile.setOre(content.block(oreMap.get(floorb, 0)));
}
}
}

View File

@ -4,6 +4,7 @@ import io.anuke.arc.Core;
import io.anuke.arc.collection.ObjectMap;
import io.anuke.arc.files.FileHandle;
import io.anuke.arc.graphics.Texture;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.io.MapIO;
public class Map{
@ -44,6 +45,15 @@ public class Map{
return file.nameWithoutExtension();
}
public int getHightScore(){
return Core.settings.getInt("hiscore" + fileName(), 0);
}
public void setHighScore(int score){
Core.settings.put("hiscore" + fileName(), score);
Vars.data.modified();
}
public String getDisplayName(){
return tags.get("name", fileName());
}

View File

@ -17,7 +17,7 @@ import static io.anuke.mindustry.Vars.*;
public class Maps implements Disposable{
/** List of all built-in maps. */
private static final String[] defaultMapNames = {"impact0079"};
private static final String[] defaultMapNames = {"Fortress"};
/** All maps stored in an ordered array. */
private Array<Map> maps = new Array<>();
@ -107,7 +107,7 @@ public class Maps implements Disposable{
/** Import a map, then save it. This updates all values and stored data necessary. */
public void importMap(FileHandle file, Map map) throws IOException{
file.copyTo(customMapDirectory.child(file.name()));
file.copyTo(customMapDirectory.child(map.name() + ".mmap"));
if(!headless){
map.texture = new Texture(MapIO.generatePreview(map));
}

View File

@ -106,7 +106,7 @@ public class CustomGameDialog extends FloatingDialog{
image.row();
image.add("[accent]" + map.getDisplayName()).pad(3f).growX().wrap().get().setAlignment(Align.center, Align.center);
image.row();
image.label((() -> Core.bundle.format("level.highscore", Core.settings.getInt("hiscore" + map.fileName(), 0)))).pad(3f);
image.label((() -> Core.bundle.format("level.highscore", map.getHightScore()))).pad(3f);
BorderImage border = new BorderImage(map.texture, 3f);
border.setScaling(Scaling.fit);

View File

@ -137,8 +137,6 @@ public class MapsDialog extends FloatingDialog{
t.add("$editor.description").padRight(10).color(Color.GRAY).top();
t.row();
t.add(map.description()).growX().wrap().padTop(2);
t.row();
t.add("$editor.oregen.info").padRight(10).color(Color.GRAY);
}).height(mapsize).width(mapsize);
table.row();

View File

@ -8,13 +8,13 @@ import io.anuke.arc.collection.EnumSet;
import io.anuke.arc.function.BooleanProvider;
import io.anuke.arc.function.Function;
import io.anuke.arc.graphics.Color;
import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.arc.graphics.g2d.Lines;
import io.anuke.arc.graphics.g2d.*;
import io.anuke.arc.graphics.g2d.TextureAtlas.AtlasRegion;
import io.anuke.arc.graphics.g2d.TextureRegion;
import io.anuke.arc.math.Mathf;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.arc.util.Align;
import io.anuke.arc.util.Time;
import io.anuke.arc.util.pooling.Pools;
import io.anuke.mindustry.entities.Damage;
import io.anuke.mindustry.entities.bullet.Bullet;
import io.anuke.mindustry.entities.effect.Puddle;
@ -32,10 +32,7 @@ import io.anuke.mindustry.ui.ContentDisplay;
import io.anuke.mindustry.world.consumers.Consume;
import io.anuke.mindustry.world.consumers.ConsumeLiquid;
import io.anuke.mindustry.world.consumers.ConsumePower;
import io.anuke.mindustry.world.meta.BlockFlag;
import io.anuke.mindustry.world.meta.BlockGroup;
import io.anuke.mindustry.world.meta.BlockStat;
import io.anuke.mindustry.world.meta.StatUnit;
import io.anuke.mindustry.world.meta.*;
import java.util.Arrays;
@ -202,6 +199,28 @@ public class Block extends BlockStorage{
public void drawPlace(int x, int y, int rotation, boolean valid){
}
protected void drawPlaceText(String text, int x, int y, boolean valid){
Color color = valid ? Pal.accent : Pal.remove;
BitmapFont font = Core.scene.skin.getFont("default-font");
GlyphLayout layout = Pools.obtain(GlyphLayout.class, GlyphLayout::new);
boolean ints = font.usesIntegerPositions();
font.setUseIntegerPositions(false);
font.getData().setScale(1f / 4f);
layout.setText(font, text);
font.setColor(color);
float dx = x*tilesize + offset(), dy = y*tilesize + offset() + size*tilesize/2f + 2;
font.draw(text, dx, dy + layout.height + 1, Align.center);
Lines.stroke(1f, color);
Lines.line(dx - layout.width/2f - 2f, dy, dx + layout.width/2f + 2f, dy);
font.setUseIntegerPositions(ints);
font.setColor(Color.WHITE);
font.getData().setScale(1f);
Draw.reset();
Pools.free(layout);
}
public void draw(Tile tile){
Draw.rect(region, tile.drawx(), tile.drawy(), rotate ? tile.getRotation() * 90 : 0);
}
@ -248,6 +267,15 @@ public class Block extends BlockStorage{
}
}
public float sumAttribute(Attribute attr, int x, int y){
Tile tile = world.tile(x, y);
float sum = 0;
for(Tile other : tile.getLinkedTilesAs(this, tempTiles)){
sum += other.floor().attributes.get(attr);
}
return sum;
}
@Override
public String localizedName(){
return localizedName;

View File

@ -23,7 +23,7 @@ public class LegacyColorMapper implements ContentList{
map("323232", Blocks.stone);
map("646464", Blocks.stone, Blocks.rocks);
map("50965a", Blocks.grass);
map("5ab464", Blocks.grass, Blocks.stainedRocks);
map("5ab464", Blocks.grass, Blocks.pine);
map("506eb4", Blocks.water);
map("465a96", Blocks.deepwater);
map("252525", Blocks.ignarock);
@ -33,8 +33,8 @@ public class LegacyColorMapper implements ContentList{
map("c2d1d2", Blocks.snow);
map("c4e3e7", Blocks.ice);
map("f7feff", Blocks.snow, Blocks.snowrocks);
map("6e501e", Blocks.stainedStoneRed);
map("ed5334", Blocks.stainedStoneRed);
map("6e501e", Blocks.holostone);
map("ed5334", Blocks.magmarock);
map("292929", Blocks.tar);
map("c3a490", Blocks.stone, Blocks.air, Blocks.oreCopper);
map("161616", Blocks.stone, Blocks.air, Blocks.oreCoal);

View File

@ -0,0 +1,15 @@
package io.anuke.mindustry.world.blocks;
import io.anuke.mindustry.world.meta.Attribute;
public class Attributes{
private float[] array = new float[Attribute.values().length];
public float get(Attribute attr){
return array[attr.ordinal()];
}
public void set(Attribute attr, float value){
array[attr.ordinal()] = value;
}
}

View File

@ -48,8 +48,6 @@ public class Floor extends Block{
public Item itemDrop = null;
/** whether this block can be drowned in */
public boolean isLiquid;
/** Heat of this block, 0 at baseline. Used for calculating output of thermal generators.*/
public float heat = 0f;
/** if true, this block cannot be mined by players. useful for annoying things like sand. */
public boolean playerUnmineable = false;
/**Style of the edge stencil. Loaded by looking up "edge-stencil-{name}".*/
@ -58,6 +56,8 @@ public class Floor extends Block{
public Block blendGroup = this;
/**Effect displayed when randomly updated.*/
public Effect updateEffect = Fx.none;
/**Array of affinities to certain things.*/
public Attributes attributes = new Attributes();
protected TextureRegion[][] edges;
protected byte eq = 0;

View File

@ -1,10 +1,12 @@
package io.anuke.mindustry.world.blocks.power;
import io.anuke.mindustry.entities.Effects;
import io.anuke.mindustry.entities.Effects.Effect;
import io.anuke.arc.Core;
import io.anuke.arc.math.Mathf;
import io.anuke.mindustry.content.Fx;
import io.anuke.mindustry.entities.Effects;
import io.anuke.mindustry.entities.Effects.Effect;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.Attribute;
public class ThermalGenerator extends PowerGenerator{
protected Effect generateEffect = Fx.none;
@ -24,6 +26,11 @@ public class ThermalGenerator extends PowerGenerator{
super.update(tile);
}
@Override
public void drawPlace(int x, int y, int rotation, boolean valid){
drawPlaceText(Core.bundle.format("blocks.efficiency", sumAttribute(Attribute.heat, x, y)*100, 1), x, y, valid);
}
@Override
public void placed(Tile tile){
super.placed(tile);
@ -34,10 +41,7 @@ public class ThermalGenerator extends PowerGenerator{
super.onProximityAdded(tile);
GeneratorEntity entity = tile.entity();
entity.productionEfficiency = 0f;
for(Tile other : tile.getLinkedTiles(tempTiles)){
entity.productionEfficiency += other.floor().heat;
}
entity.productionEfficiency = sumAttribute(Attribute.heat, tile.x, tile.y);
}
@Override
@ -50,6 +54,6 @@ public class ThermalGenerator extends PowerGenerator{
@Override
public boolean canPlaceOn(Tile tile){
//make sure there's heat at this location
return tile.getLinkedTilesAs(this, tempTiles).sum(other -> other.floor().heat) > 0.01f;
return tile.getLinkedTilesAs(this, tempTiles).sum(other -> other.floor().attributes.get(Attribute.heat)) > 0.01f;
}
}

View File

@ -10,7 +10,10 @@ import io.anuke.arc.math.RandomXS128;
import io.anuke.arc.util.Time;
import io.anuke.mindustry.content.Fx;
import io.anuke.mindustry.entities.type.TileEntity;
import io.anuke.mindustry.graphics.Pal;
import io.anuke.mindustry.ui.Bar;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.Attribute;
import java.io.DataInput;
import java.io.DataOutput;
@ -46,6 +49,21 @@ public class Cultivator extends GenericCrafter{
entity.warmup = Mathf.lerpDelta(entity.warmup, entity.cons.valid() ? 1f : 0f, 0.015f);
}
@Override
public void setBars(){
super.setBars();
bars.add("multiplier", entity -> new Bar(() ->
Core.bundle.format("blocks.efficiency",
((((CultivatorEntity)entity).boost + 1f) * ((CultivatorEntity)entity).warmup)*100f,1),
() -> Pal.ammo,
() -> ((CultivatorEntity)entity).warmup));
}
@Override
public void drawPlace(int x, int y, int rotation, boolean valid){
drawPlaceText(Core.bundle.format("blocks.efficiency", (1+sumAttribute(Attribute.spores, x, y))*100, 1), x, y, valid);
}
@Override
public void draw(Tile tile){
CultivatorEntity entity = tile.entity();
@ -84,8 +102,23 @@ public class Cultivator extends GenericCrafter{
return new CultivatorEntity();
}
@Override
public void onProximityAdded(Tile tile){
super.onProximityAdded(tile);
CultivatorEntity entity = tile.entity();
entity.boost = sumAttribute(Attribute.spores, tile.x, tile.y);
}
@Override
protected float getProgressIncrease(TileEntity entity, float baseTime){
CultivatorEntity c = (CultivatorEntity)entity;
return super.getProgressIncrease(entity, baseTime) * (1f + c.boost);
}
public static class CultivatorEntity extends GenericCrafterEntity{
public float warmup;
public float boost;
@Override
public void write(DataOutput stream) throws IOException{

View File

@ -1,17 +1,20 @@
package io.anuke.mindustry.world.blocks.production;
import io.anuke.arc.Core;
import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.arc.graphics.g2d.TextureRegion;
import io.anuke.mindustry.content.Liquids;
import io.anuke.arc.math.Mathf;
import io.anuke.mindustry.content.Fx;
import io.anuke.mindustry.entities.type.TileEntity;
import io.anuke.mindustry.type.Liquid;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.BlockStat;
import io.anuke.mindustry.content.Liquids;
import io.anuke.mindustry.entities.Effects;
import io.anuke.mindustry.entities.Effects.Effect;
import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.arc.math.Mathf;
import io.anuke.mindustry.entities.type.TileEntity;
import io.anuke.mindustry.graphics.Pal;
import io.anuke.mindustry.type.Liquid;
import io.anuke.mindustry.ui.Bar;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.Attribute;
import io.anuke.mindustry.world.meta.BlockStat;
/**
* Pump that makes liquid from solids and takes in power. Only works on solid floor blocks.
@ -21,6 +24,8 @@ public class SolidPump extends Pump{
protected Effect updateEffect = Fx.none;
protected float updateEffectChance = 0.02f;
protected float rotateSpeed = 1f;
/**Attribute that is checked when calculating output.*/
protected Attribute attribute;
public SolidPump(String name){
super(name);
@ -34,11 +39,27 @@ public class SolidPump extends Pump{
liquidRegion = Core.atlas.find(name + "-liquid");
}
@Override
public void drawPlace(int x, int y, int rotation, boolean valid){
if(attribute != null){
drawPlaceText(Core.bundle.format("blocks.efficiency", (sumAttribute(attribute, x, y) + 1f)*100, 1), x, y, valid);
}
}
@Override
public void setBars(){
super.setBars();
bars.add("efficiency", entity -> new Bar(() ->
Core.bundle.format("blocks.efficiency",
((((SolidPumpEntity)entity).boost + 1f) * ((SolidPumpEntity)entity).warmup) * 100, 1),
() -> Pal.ammo,
() -> ((SolidPumpEntity)entity).warmup));
}
@Override
public void setStats(){
super.setStats();
// stats.remove(BlockStat.liquidOutput);
stats.add(BlockStat.liquidOutput, result);
}
@ -76,6 +97,8 @@ public class SolidPump extends Pump{
if(isValid(tile)) fraction = 1f;
}
fraction += entity.boost;
if(tile.entity.cons.valid() && typeLiquid(tile) < liquidCapacity - 0.001f){
float maxPump = Math.min(liquidCapacity - typeLiquid(tile), pumpAmount * entity.delta() * fraction * entity.power.satisfaction);
tile.entity.liquids.add(result, maxPump);
@ -115,6 +138,16 @@ public class SolidPump extends Pump{
return new SolidPumpEntity();
}
@Override
public void onProximityAdded(Tile tile){
super.onProximityAdded(tile);
if(attribute != null){
SolidPumpEntity entity = tile.entity();
entity.boost = sumAttribute(attribute, tile.x, tile.y);
}
}
public float typeLiquid(Tile tile){
return tile.entity.liquids.total();
}
@ -122,5 +155,6 @@ public class SolidPump extends Pump{
public static class SolidPumpEntity extends TileEntity{
public float warmup;
public float pumpTime;
public float boost;
}
}

View File

@ -0,0 +1,12 @@
package io.anuke.mindustry.world.meta;
public enum Attribute{
/** Heat of this block. Used for calculating output of thermal generators.*/
heat,
/** Spore content of this block. Used for increasing cultivator yield.*/
spores,
/** Water content of this block. Used for increasing water extractor yield.*/
water,
/** Oil content of this block. Used for increasing oil extractor yield.*/
oil
}

View File

@ -18,9 +18,10 @@ public class ConsumeModule extends BlockModule{
public void update(){
boolean prevValid = valid();
valid = true;
boolean docons = entity.tile.block().shouldConsume(entity.tile);
for(Consume cons : entity.tile.block().consumes.all()){
if(cons.isUpdate() && prevValid && entity.tile.block().shouldConsume(entity.tile) && cons.valid(entity.getTile().block(), entity)){
if(docons && cons.isUpdate() && prevValid && cons.valid(entity.getTile().block(), entity)){
cons.update(entity.getTile().block(), entity);
}