Added sorted unloader and new block group system
This commit is contained in:
BIN
core/assets-raw/sprites/blocks/tech/sortedunloader.png
Normal file
BIN
core/assets-raw/sprites/blocks/tech/sortedunloader.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 276 B |
@@ -426,42 +426,42 @@ snowedge
|
|||||||
index: -1
|
index: -1
|
||||||
stone1
|
stone1
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 721, 252
|
xy: 701, 248
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
stone2
|
stone2
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 701, 248
|
xy: 711, 242
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
stone3
|
stone3
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 711, 242
|
xy: 721, 242
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
stoneblock1
|
stoneblock1
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 721, 242
|
xy: 867, 437
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
stoneblock2
|
stoneblock2
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 867, 437
|
xy: 877, 437
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
stoneblock3
|
stoneblock3
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 877, 437
|
xy: 887, 437
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -475,49 +475,49 @@ stoneedge
|
|||||||
index: -1
|
index: -1
|
||||||
titanium1
|
titanium1
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 887, 427
|
xy: 897, 427
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
titanium2
|
titanium2
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 897, 427
|
xy: 907, 427
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
titanium3
|
titanium3
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 907, 427
|
xy: 917, 427
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
uranium1
|
uranium1
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 733, 284
|
xy: 733, 274
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
uranium2
|
uranium2
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 733, 274
|
xy: 733, 264
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
uranium3
|
uranium3
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 733, 264
|
xy: 261, 33
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
water
|
water
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 313, 37
|
xy: 323, 37
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -762,49 +762,49 @@ solarpanel
|
|||||||
index: -1
|
index: -1
|
||||||
stonedrill
|
stonedrill
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 887, 437
|
xy: 897, 437
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
stoneformer
|
stoneformer
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 897, 437
|
xy: 907, 437
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
thermalgenerator
|
thermalgenerator
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 877, 427
|
xy: 887, 427
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
titaniumdrill
|
titaniumdrill
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 917, 427
|
xy: 927, 434
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
titaniumextractor
|
titaniumextractor
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 927, 434
|
xy: 937, 434
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
uraniumdrill
|
uraniumdrill
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 261, 33
|
xy: 273, 37
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
uraniumextractor
|
uraniumextractor
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 273, 37
|
xy: 283, 37
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -984,51 +984,58 @@ shieldprojector
|
|||||||
orig: 16, 16
|
orig: 16, 16
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
sorter
|
sortedunloader
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 835, 380
|
xy: 835, 380
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
splitter
|
sorter
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 815, 370
|
xy: 815, 370
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
steelconveyor
|
splitter
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 825, 370
|
xy: 825, 370
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
steelconveyormove
|
steelconveyor
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 835, 370
|
xy: 835, 370
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
teleporter
|
steelconveyormove
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 917, 437
|
xy: 711, 252
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
teleporter-top
|
teleporter
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 867, 427
|
xy: 867, 427
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
|
teleporter-top
|
||||||
|
rotate: false
|
||||||
|
xy: 877, 427
|
||||||
|
size: 8, 8
|
||||||
|
orig: 8, 8
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
unloader
|
unloader
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 545, 57
|
xy: 733, 284
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -1042,7 +1049,7 @@ vault
|
|||||||
index: -1
|
index: -1
|
||||||
vault-icon
|
vault-icon
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 283, 37
|
xy: 293, 37
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -1266,7 +1273,7 @@ ironwall
|
|||||||
index: -1
|
index: -1
|
||||||
steelwall
|
steelwall
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 711, 252
|
xy: 721, 252
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -1280,21 +1287,21 @@ steelwall-large
|
|||||||
index: -1
|
index: -1
|
||||||
stonewall
|
stonewall
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 907, 437
|
xy: 917, 437
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
titaniumshieldwall
|
titaniumshieldwall
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 937, 434
|
xy: 947, 434
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
titaniumwall
|
titaniumwall
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 947, 434
|
xy: 927, 424
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -1378,7 +1385,7 @@ shot-long
|
|||||||
index: -1
|
index: -1
|
||||||
titanshell
|
titanshell
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 927, 424
|
xy: 937, 424
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
@@ -2658,28 +2665,28 @@ shockgun-equip
|
|||||||
index: -1
|
index: -1
|
||||||
triblaster
|
triblaster
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 937, 424
|
xy: 947, 424
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
triblaster-equip
|
triblaster-equip
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 947, 424
|
xy: 545, 57
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
vulcan
|
vulcan
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 293, 37
|
xy: 303, 37
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
vulcan-equip
|
vulcan-equip
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 303, 37
|
xy: 313, 37
|
||||||
size: 8, 8
|
size: 8, 8
|
||||||
orig: 8, 8
|
orig: 8, 8
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 89 KiB |
@@ -1,7 +1,7 @@
|
|||||||
#Autogenerated file. Do not modify.
|
#Autogenerated file. Do not modify.
|
||||||
#Sat Mar 10 13:27:15 EST 2018
|
#Sat Mar 10 15:19:13 EST 2018
|
||||||
version=release
|
version=release
|
||||||
androidBuildCode=426
|
androidBuildCode=431
|
||||||
name=Mindustry
|
name=Mindustry
|
||||||
code=3.4
|
code=3.4
|
||||||
build=custom build
|
build=custom build
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ public class Recipes {
|
|||||||
new Recipe(distribution, DistributionBlocks.splitter, stack(Item.steel, 1)),
|
new Recipe(distribution, DistributionBlocks.splitter, stack(Item.steel, 1)),
|
||||||
new Recipe(distribution, DistributionBlocks.vault, stack(Item.steel, 50)),
|
new Recipe(distribution, DistributionBlocks.vault, stack(Item.steel, 50)),
|
||||||
new Recipe(distribution, DistributionBlocks.unloader, stack(Item.steel, 5)),
|
new Recipe(distribution, DistributionBlocks.unloader, stack(Item.steel, 5)),
|
||||||
|
new Recipe(distribution, DistributionBlocks.sortedunloader, stack(Item.steel, 5)),
|
||||||
|
|
||||||
new Recipe(weapon, WeaponBlocks.doubleturret, stack(Item.stone, 7)),
|
new Recipe(weapon, WeaponBlocks.doubleturret, stack(Item.stone, 7)),
|
||||||
new Recipe(weapon, WeaponBlocks.gatlingturret, stack(Item.iron, 8), stack(Item.stone, 10)),
|
new Recipe(weapon, WeaponBlocks.gatlingturret, stack(Item.iron, 8), stack(Item.stone, 10)),
|
||||||
|
|||||||
@@ -73,8 +73,6 @@ public class Block extends BaseBlock {
|
|||||||
public Liquid liquidDrop = null;
|
public Liquid liquidDrop = null;
|
||||||
/**multiblock size*/
|
/**multiblock size*/
|
||||||
public int size = 1;
|
public int size = 1;
|
||||||
/**Brief block description. Should be short enough fit in the place menu.*/
|
|
||||||
public final String description;
|
|
||||||
/**Detailed description of the block. Can be as long as necesary.*/
|
/**Detailed description of the block. Can be as long as necesary.*/
|
||||||
public final String fullDescription;
|
public final String fullDescription;
|
||||||
/**Whether to draw this block in the expanded draw range.*/
|
/**Whether to draw this block in the expanded draw range.*/
|
||||||
@@ -89,6 +87,8 @@ public class Block extends BaseBlock {
|
|||||||
public boolean alwaysReplace = false;
|
public boolean alwaysReplace = false;
|
||||||
/**whether this block has instant transfer checking. used for calculations to prevent infinite loops.*/
|
/**whether this block has instant transfer checking. used for calculations to prevent infinite loops.*/
|
||||||
public boolean instantTransfer = false;
|
public boolean instantTransfer = false;
|
||||||
|
/**The block group. Unless {@link #canReplace} is overriden, blocks in the same group can replace each other.*/
|
||||||
|
public BlockGroup group = BlockGroup.none;
|
||||||
/**list of displayed block status bars. Defaults to health bar.*/
|
/**list of displayed block status bars. Defaults to health bar.*/
|
||||||
public BlockBars bars = new BlockBars();
|
public BlockBars bars = new BlockBars();
|
||||||
/**List of block stats.*/
|
/**List of block stats.*/
|
||||||
@@ -97,7 +97,6 @@ public class Block extends BaseBlock {
|
|||||||
public Block(String name) {
|
public Block(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.formalName = Bundles.get("block." + name + ".name", name);
|
this.formalName = Bundles.get("block." + name + ".name", name);
|
||||||
this.description = Bundles.getOrNull("block." + name + ".description");
|
|
||||||
this.fullDescription = Bundles.getOrNull("block." + name + ".fulldescription");
|
this.fullDescription = Bundles.getOrNull("block." + name + ".fulldescription");
|
||||||
this.solid = false;
|
this.solid = false;
|
||||||
this.id = lastid++;
|
this.id = lastid++;
|
||||||
@@ -129,6 +128,7 @@ public class Block extends BaseBlock {
|
|||||||
|
|
||||||
public void setConfigure(Tile tile, byte data){
|
public void setConfigure(Tile tile, byte data){
|
||||||
if(Net.active()) NetEvents.handleBlockConfig(tile, data);
|
if(Net.active()) NetEvents.handleBlockConfig(tile, data);
|
||||||
|
configure(tile, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isConfigurable(Tile tile){
|
public boolean isConfigurable(Tile tile){
|
||||||
@@ -160,7 +160,7 @@ public class Block extends BaseBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canReplace(Block other){
|
public boolean canReplace(Block other){
|
||||||
return false;
|
return other != this && this.group != BlockGroup.none && other.group == this.group;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int handleDamage(Tile tile, int amount){
|
public int handleDamage(Tile tile, int amount){
|
||||||
|
|||||||
5
core/src/io/anuke/mindustry/world/BlockGroup.java
Normal file
5
core/src/io/anuke/mindustry/world/BlockGroup.java
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package io.anuke.mindustry.world;
|
||||||
|
|
||||||
|
public enum BlockGroup {
|
||||||
|
none, walls, turrets, transportation, power, liquids, drills;
|
||||||
|
}
|
||||||
@@ -14,9 +14,9 @@ public abstract class BaseBlock {
|
|||||||
public boolean hasPower;
|
public boolean hasPower;
|
||||||
|
|
||||||
public int itemCapacity;
|
public int itemCapacity;
|
||||||
public float liquidCapacity;
|
public float liquidCapacity = 10f;
|
||||||
public float liquidFlowFactor = 4.9f;
|
public float liquidFlowFactor = 4.9f;
|
||||||
public float powerCapacity;
|
public float powerCapacity = 10f;
|
||||||
|
|
||||||
public void handleItem(Item item, Tile tile, Tile source){
|
public void handleItem(Item item, Tile tile, Tile source){
|
||||||
tile.entity.inventory.addItem(item, 1);
|
tile.entity.inventory.addItem(item, 1);
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package io.anuke.mindustry.world.blocks;
|
package io.anuke.mindustry.world.blocks;
|
||||||
|
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.blocks.types.LiquidBlock;
|
||||||
import io.anuke.mindustry.world.blocks.types.distribution.*;
|
import io.anuke.mindustry.world.blocks.types.distribution.*;
|
||||||
|
import io.anuke.mindustry.world.blocks.types.storage.SortedUnloader;
|
||||||
import io.anuke.mindustry.world.blocks.types.storage.Unloader;
|
import io.anuke.mindustry.world.blocks.types.storage.Unloader;
|
||||||
import io.anuke.mindustry.world.blocks.types.storage.Vault;
|
import io.anuke.mindustry.world.blocks.types.storage.Vault;
|
||||||
|
|
||||||
@@ -9,11 +11,11 @@ public class DistributionBlocks{
|
|||||||
|
|
||||||
public static final Block
|
public static final Block
|
||||||
|
|
||||||
conduit = new Conduit("conduit"){{
|
conduit = new LiquidBlock("conduit"){{
|
||||||
health = 45;
|
health = 45;
|
||||||
}},
|
}},
|
||||||
|
|
||||||
pulseconduit = new Conduit("pulseconduit"){{
|
pulseconduit = new LiquidBlock("pulseconduit"){{
|
||||||
liquidCapacity = 16f;
|
liquidCapacity = 16f;
|
||||||
liquidFlowFactor = 4.9f;
|
liquidFlowFactor = 4.9f;
|
||||||
health = 65;
|
health = 65;
|
||||||
@@ -53,6 +55,10 @@ public class DistributionBlocks{
|
|||||||
|
|
||||||
}},
|
}},
|
||||||
|
|
||||||
|
sortedunloader = new SortedUnloader("sortedunloader"){{
|
||||||
|
|
||||||
|
}},
|
||||||
|
|
||||||
junction = new Junction("junction"){{
|
junction = new Junction("junction"){{
|
||||||
|
|
||||||
}},
|
}},
|
||||||
|
|||||||
@@ -188,6 +188,7 @@ public class ProductionBlocks{
|
|||||||
drillTime = 240;
|
drillTime = 240;
|
||||||
size = 2;
|
size = 2;
|
||||||
powerUse = 0.08f;
|
powerUse = 0.08f;
|
||||||
|
hasPower = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -196,6 +197,7 @@ public class ProductionBlocks{
|
|||||||
drillTime = 240;
|
drillTime = 240;
|
||||||
size = 3;
|
size = 3;
|
||||||
powerUse = 0.32f;
|
powerUse = 0.32f;
|
||||||
|
hasPower = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -205,6 +207,8 @@ public class ProductionBlocks{
|
|||||||
drillTime = 240;
|
drillTime = 240;
|
||||||
size = 4;
|
size = 4;
|
||||||
powerUse = 0.16f;
|
powerUse = 0.16f;
|
||||||
|
hasLiquids = true;
|
||||||
|
hasPower = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -223,8 +227,10 @@ public class ProductionBlocks{
|
|||||||
result = Item.biomatter;
|
result = Item.biomatter;
|
||||||
inputLiquid = Liquid.water;
|
inputLiquid = Liquid.water;
|
||||||
liquidUse = 0.1f;
|
liquidUse = 0.1f;
|
||||||
drillTime = 50;
|
drillTime = 300;
|
||||||
size = 2;
|
size = 2;
|
||||||
|
hasLiquids = true;
|
||||||
|
hasPower = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.anuke.mindustry.world.blocks.types;
|
package io.anuke.mindustry.world.blocks.types;
|
||||||
|
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.BlockGroup;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.types.modules.LiquidModule;
|
import io.anuke.mindustry.world.blocks.types.modules.LiquidModule;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
@@ -12,6 +13,8 @@ public class LiquidBlock extends Block{
|
|||||||
super(name);
|
super(name);
|
||||||
rotate = true;
|
rotate = true;
|
||||||
update = true;
|
update = true;
|
||||||
|
hasLiquids = true;
|
||||||
|
group = BlockGroup.liquids;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.world.blocks.types;
|
|||||||
|
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.BlockGroup;
|
||||||
|
|
||||||
public abstract class PowerBlock extends Block{
|
public abstract class PowerBlock extends Block{
|
||||||
public float powerCapacity = 10f;
|
public float powerCapacity = 10f;
|
||||||
@@ -12,6 +13,7 @@ public abstract class PowerBlock extends Block{
|
|||||||
update = true;
|
update = true;
|
||||||
solid = true;
|
solid = true;
|
||||||
hasPower = true;
|
hasPower = true;
|
||||||
|
group = BlockGroup.power;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.anuke.mindustry.world.blocks.types;
|
package io.anuke.mindustry.world.blocks.types;
|
||||||
|
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.BlockGroup;
|
||||||
|
|
||||||
public class Wall extends Block{
|
public class Wall extends Block{
|
||||||
|
|
||||||
@@ -8,10 +9,12 @@ public class Wall extends Block{
|
|||||||
super(name);
|
super(name);
|
||||||
solid = true;
|
solid = true;
|
||||||
destructible = true;
|
destructible = true;
|
||||||
|
group = BlockGroup.walls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean canReplace(Block other){
|
public boolean canReplace(Block other){
|
||||||
return other instanceof Wall && health > other.health;
|
return super.canReplace(other) && health > other.health;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public class Turret extends Block{
|
|||||||
update = true;
|
update = true;
|
||||||
solid = true;
|
solid = true;
|
||||||
layer = Layer.turret;
|
layer = Layer.turret;
|
||||||
|
group = BlockGroup.turrets;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -76,11 +77,6 @@ public class Turret extends Block{
|
|||||||
stats.add("shots", shots);
|
stats.add("shots", shots);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canReplace(Block other){
|
|
||||||
return other instanceof Turret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(Tile tile){
|
||||||
if(base == null) {
|
if(base == null) {
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
package io.anuke.mindustry.world.blocks.types.distribution;
|
|
||||||
|
|
||||||
import io.anuke.mindustry.world.Block;
|
|
||||||
import io.anuke.mindustry.world.blocks.types.LiquidBlock;
|
|
||||||
|
|
||||||
public class Conduit extends LiquidBlock {
|
|
||||||
|
|
||||||
public Conduit(String name) {
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canReplace(Block other) {
|
|
||||||
return other instanceof Conduit && other != this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,6 +4,7 @@ import com.badlogic.gdx.utils.LongArray;
|
|||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.BlockGroup;
|
||||||
import io.anuke.mindustry.world.Layer;
|
import io.anuke.mindustry.world.Layer;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
@@ -38,6 +39,7 @@ public class Conveyor extends Block{
|
|||||||
rotate = true;
|
rotate = true;
|
||||||
update = true;
|
update = true;
|
||||||
layer = Layer.overlay;
|
layer = Layer.overlay;
|
||||||
|
group = BlockGroup.transportation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -46,11 +48,6 @@ public class Conveyor extends Block{
|
|||||||
stats.add("itemspeedsecond", Strings.toFixed(speed * 60, 1));
|
stats.add("itemspeedsecond", Strings.toFixed(speed * 60, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canReplace(Block other){
|
|
||||||
return other instanceof Conveyor || other instanceof Router || other instanceof Junction;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(Tile tile){
|
||||||
byte rotation = tile.getRotation();
|
byte rotation = tile.getRotation();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.badlogic.gdx.utils.NumberUtils;
|
|||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.BlockGroup;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.function.Consumer;
|
import io.anuke.ucore.function.Consumer;
|
||||||
@@ -19,11 +20,7 @@ public class Junction extends Block{
|
|||||||
update = true;
|
update = true;
|
||||||
solid = true;
|
solid = true;
|
||||||
instantTransfer = true;
|
instantTransfer = true;
|
||||||
}
|
group = BlockGroup.transportation;
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canReplace(Block other){
|
|
||||||
return other instanceof Conveyor || other instanceof Router;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import io.anuke.mindustry.world.blocks.types.LiquidBlock;
|
|||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
|
|
||||||
public class LiquidJunction extends Conduit{
|
public class LiquidJunction extends LiquidBlock{
|
||||||
|
|
||||||
public LiquidJunction(String name) {
|
public LiquidJunction(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ package io.anuke.mindustry.world.blocks.types.distribution;
|
|||||||
|
|
||||||
import io.anuke.mindustry.resource.Liquid;
|
import io.anuke.mindustry.resource.Liquid;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.mindustry.world.blocks.types.LiquidBlock;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
|
|
||||||
public class LiquidRouter extends Conduit{
|
public class LiquidRouter extends LiquidBlock{
|
||||||
|
|
||||||
public LiquidRouter(String name) {
|
public LiquidRouter(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package io.anuke.mindustry.world.blocks.types.distribution;
|
package io.anuke.mindustry.world.blocks.types.distribution;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import io.anuke.mindustry.world.Block;
|
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.types.generation.Generator;
|
import io.anuke.mindustry.world.blocks.types.generation.Generator;
|
||||||
|
|
||||||
@@ -17,11 +16,6 @@ public class PowerLaser extends Generator{
|
|||||||
health = 50;
|
health = 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canReplace(Block other) {
|
|
||||||
return other instanceof PowerLaser && other != this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void update(Tile tile){
|
||||||
distributeLaserPower(tile);
|
distributeLaserPower(tile);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.world.blocks.types.distribution;
|
|||||||
|
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.BlockGroup;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
|
|
||||||
@@ -12,11 +13,7 @@ public class Router extends Block{
|
|||||||
update = true;
|
update = true;
|
||||||
solid = true;
|
solid = true;
|
||||||
itemCapacity = 20;
|
itemCapacity = 20;
|
||||||
}
|
group = BlockGroup.transportation;
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canReplace(Block other){
|
|
||||||
return other instanceof Junction || other instanceof Conveyor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.badlogic.gdx.utils.Array;
|
|||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.BlockGroup;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.scene.style.TextureRegionDrawable;
|
import io.anuke.ucore.scene.style.TextureRegionDrawable;
|
||||||
@@ -25,6 +26,7 @@ public class Sorter extends Block{
|
|||||||
update = true;
|
update = true;
|
||||||
solid = true;
|
solid = true;
|
||||||
instantTransfer = true;
|
instantTransfer = true;
|
||||||
|
group = BlockGroup.transportation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -39,11 +41,6 @@ public class Sorter extends Block{
|
|||||||
Draw.rect(Tmp.tr1, tile.worldx(), tile.worldy(), 4f, 4f);
|
Draw.rect(Tmp.tr1, tile.worldx(), tile.worldy(), 4f, 4f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canReplace(Block other){
|
|
||||||
return other instanceof Conveyor || other instanceof Router;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||||
Tile to = getTileTarget(item, tile, source, false);
|
Tile to = getTileTarget(item, tile, source, false);
|
||||||
@@ -121,13 +118,12 @@ public class Sorter extends Block{
|
|||||||
cont.margin(4);
|
cont.margin(4);
|
||||||
cont.marginBottom(5);
|
cont.marginBottom(5);
|
||||||
|
|
||||||
cont.add().colspan(4).height(105f);
|
cont.add().colspan(4).height(50f * (int)(items.size/4f + 1f));
|
||||||
cont.row();
|
cont.row();
|
||||||
|
|
||||||
for(int i = 0; i < items.size; i ++){
|
for(int i = 0; i < items.size; i ++){
|
||||||
final int f = i;
|
final int f = i;
|
||||||
ImageButton button = cont.addImageButton("white", "toggle", 24, () -> {
|
ImageButton button = cont.addImageButton("white", "toggle", 24, () -> {
|
||||||
entity.sortItem = items.get(f);
|
|
||||||
setConfigure(tile, (byte)f);
|
setConfigure(tile, (byte)f);
|
||||||
}).size(38, 42).padBottom(-5.1f).group(group).get();
|
}).size(38, 42).padBottom(-5.1f).group(group).get();
|
||||||
button.getStyle().imageUp = new TextureRegionDrawable(new TextureRegion(items.get(i).region));
|
button.getStyle().imageUp = new TextureRegionDrawable(new TextureRegion(items.get(i).region));
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import io.anuke.ucore.util.Strings;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.syncBlockState;
|
import static io.anuke.mindustry.Vars.syncBlockState;
|
||||||
|
|
||||||
@@ -56,7 +55,7 @@ public class Teleporter extends PowerBlock{
|
|||||||
TeleporterEntity entity = tile.entity();
|
TeleporterEntity entity = tile.entity();
|
||||||
if(entity != null){
|
if(entity != null){
|
||||||
entity.color = data;
|
entity.color = data;
|
||||||
Arrays.fill(entity.inventory.items, 0);
|
entity.inventory.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +116,6 @@ public class Teleporter extends PowerBlock{
|
|||||||
for(int i = 0; i < colors; i ++){
|
for(int i = 0; i < colors; i ++){
|
||||||
final int f = i;
|
final int f = i;
|
||||||
ImageButton button = cont.addImageButton("white", "toggle", 24, () -> {
|
ImageButton button = cont.addImageButton("white", "toggle", 24, () -> {
|
||||||
entity.color = (byte)f;
|
|
||||||
lastColor = (byte)f;
|
lastColor = (byte)f;
|
||||||
setConfigure(tile, (byte)f);
|
setConfigure(tile, (byte)f);
|
||||||
}).size(34, 38).padBottom(-5.1f).group(group).get();
|
}).size(34, 38).padBottom(-5.1f).group(group).get();
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ package io.anuke.mindustry.world.blocks.types.distribution;
|
|||||||
|
|
||||||
import io.anuke.mindustry.resource.Liquid;
|
import io.anuke.mindustry.resource.Liquid;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.mindustry.world.blocks.types.LiquidBlock;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
|
|
||||||
public class TunnelConduit extends Conduit {
|
public class TunnelConduit extends LiquidBlock {
|
||||||
protected int maxdist = 3;
|
protected int maxdist = 3;
|
||||||
protected float speed = 53;
|
protected float speed = 53;
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.badlogic.gdx.utils.NumberUtils;
|
|||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.BlockGroup;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.util.Bits;
|
import io.anuke.ucore.util.Bits;
|
||||||
@@ -21,11 +22,7 @@ public class TunnelConveyor extends Block{
|
|||||||
solid = true;
|
solid = true;
|
||||||
health = 70;
|
health = 70;
|
||||||
instantTransfer = true;
|
instantTransfer = true;
|
||||||
}
|
group = BlockGroup.transportation;
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canReplace(Block other){
|
|
||||||
return other instanceof Conveyor || other instanceof Router || other instanceof Junction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import io.anuke.mindustry.world.blocks.types.BlockModule;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class InventoryModule extends BlockModule{
|
public class InventoryModule extends BlockModule{
|
||||||
public int[] items = new int[Item.getAllItems().size];
|
public int[] items = new int[Item.getAllItems().size];
|
||||||
@@ -38,6 +39,10 @@ public class InventoryModule extends BlockModule{
|
|||||||
items[item.id] -= amount;
|
items[item.id] -= amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clear(){
|
||||||
|
Arrays.fill(items, 0);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutputStream stream) throws IOException {
|
public void write(DataOutputStream stream) throws IOException {
|
||||||
byte amount = 0;
|
byte amount = 0;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import io.anuke.mindustry.entities.TileEntity;
|
|||||||
import io.anuke.mindustry.graphics.Fx;
|
import io.anuke.mindustry.graphics.Fx;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.BlockGroup;
|
||||||
import io.anuke.mindustry.world.Layer;
|
import io.anuke.mindustry.world.Layer;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.core.Effects;
|
import io.anuke.ucore.core.Effects;
|
||||||
@@ -31,6 +32,7 @@ public class Drill extends Block{
|
|||||||
solid = true;
|
solid = true;
|
||||||
layer = Layer.overlay;
|
layer = Layer.overlay;
|
||||||
itemCapacity = 5;
|
itemCapacity = 5;
|
||||||
|
group = BlockGroup.drills;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package io.anuke.mindustry.world.blocks.types.production;
|
package io.anuke.mindustry.world.blocks.types.production;
|
||||||
|
|
||||||
import io.anuke.mindustry.resource.Liquid;
|
import io.anuke.mindustry.resource.Liquid;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.BlockGroup;
|
||||||
import io.anuke.mindustry.world.Layer;
|
import io.anuke.mindustry.world.Layer;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.types.LiquidBlock;
|
import io.anuke.mindustry.world.blocks.types.LiquidBlock;
|
||||||
@@ -22,11 +22,7 @@ public class Pump extends LiquidBlock{
|
|||||||
solid = true;
|
solid = true;
|
||||||
layer = Layer.overlay;
|
layer = Layer.overlay;
|
||||||
liquidFlowFactor = 3f;
|
liquidFlowFactor = 3f;
|
||||||
}
|
group = BlockGroup.liquids;
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canReplace(Block other) {
|
|
||||||
return other instanceof Pump && other != this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -58,7 +54,7 @@ public class Pump extends LiquidBlock{
|
|||||||
@Override
|
@Override
|
||||||
public void drawLayer(Tile tile){
|
public void drawLayer(Tile tile){
|
||||||
Draw.colorl(0.85f + Mathf.absin(Timers.time(), 6f, 0.15f));
|
Draw.colorl(0.85f + Mathf.absin(Timers.time(), 6f, 0.15f));
|
||||||
Draw.rect("cross", tile.worldx(), tile.worldy());
|
Draw.rect("cross-"+size, tile.worldx(), tile.worldy());
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package io.anuke.mindustry.world.blocks.types.storage;
|
package io.anuke.mindustry.world.blocks.types.storage;
|
||||||
|
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
@@ -37,9 +36,9 @@ public class CoreBlock extends StorageBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Item removeItem(Tile tile){
|
public Item removeItem(Tile tile, Item item){
|
||||||
for(int i = 0; i < state.inventory.getItems().length; i ++){
|
for(int i = 0; i < state.inventory.getItems().length; i ++){
|
||||||
if(state.inventory.getItems()[i] > 0){
|
if(state.inventory.getItems()[i] > 0 && (item == null || item.id == i)){
|
||||||
if(Net.server() || !Net.active()) state.inventory.getItems()[i] --;
|
if(Net.server() || !Net.active()) state.inventory.getItems()[i] --;
|
||||||
return Item.getByID(i);
|
return Item.getByID(i);
|
||||||
}
|
}
|
||||||
@@ -48,10 +47,9 @@ public class CoreBlock extends StorageBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasItem(Tile tile){
|
public boolean hasItem(Tile tile, Item item){
|
||||||
TileEntity entity = tile.entity;
|
|
||||||
for(int i = 0; i < state.inventory.getItems().length; i ++){
|
for(int i = 0; i < state.inventory.getItems().length; i ++){
|
||||||
if(state.inventory.getItems()[i] > 0){
|
if(state.inventory.getItems()[i] > 0 && (item == null || item.id == i)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,118 @@
|
|||||||
|
package io.anuke.mindustry.world.blocks.types.storage;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
|
import io.anuke.mindustry.resource.Item;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.ucore.graphics.Draw;
|
||||||
|
import io.anuke.ucore.scene.style.TextureRegionDrawable;
|
||||||
|
import io.anuke.ucore.scene.ui.ButtonGroup;
|
||||||
|
import io.anuke.ucore.scene.ui.ImageButton;
|
||||||
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
|
import io.anuke.ucore.util.Tmp;
|
||||||
|
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class SortedUnloader extends Unloader {
|
||||||
|
|
||||||
|
public SortedUnloader(String name){
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Tile tile){
|
||||||
|
SortedUnloaderEntity entity = tile.entity();
|
||||||
|
|
||||||
|
if(entity.inventory.totalItems() == 0 && entity.timer.get(timerUnload, 5)){
|
||||||
|
tile.allNearby(other -> {
|
||||||
|
if(other.block() instanceof StorageBlock && entity.inventory.totalItems() == 0 &&
|
||||||
|
((StorageBlock)other.block()).hasItem(other, entity.sortItem)){
|
||||||
|
offloadNear(tile, ((StorageBlock)other.block()).removeItem(other, entity.sortItem));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if(entity.inventory.totalItems() > 0){
|
||||||
|
tryDump(tile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Tile tile){
|
||||||
|
super.draw(tile);
|
||||||
|
|
||||||
|
SortedUnloaderEntity entity = tile.entity();
|
||||||
|
|
||||||
|
TextureRegion region = entity.sortItem.region;
|
||||||
|
Tmp.tr1.setRegion(region, 4, 4, 1, 1);
|
||||||
|
|
||||||
|
Draw.rect(Tmp.tr1, tile.worldx(), tile.worldy(), 2f, 2f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isConfigurable(Tile tile){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configure(Tile tile, byte data) {
|
||||||
|
SortedUnloaderEntity entity = tile.entity();
|
||||||
|
if(entity != null){
|
||||||
|
entity.sortItem = Item.getByID(data);
|
||||||
|
entity.inventory.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildTable(Tile tile, Table table){
|
||||||
|
SortedUnloaderEntity entity = tile.entity();
|
||||||
|
|
||||||
|
Array<Item> items = Item.getAllItems();
|
||||||
|
|
||||||
|
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||||
|
Table cont = new Table();
|
||||||
|
cont.margin(4);
|
||||||
|
cont.marginBottom(5);
|
||||||
|
|
||||||
|
cont.add().colspan(4).height(50f * (int)(items.size/4f + 1f));
|
||||||
|
cont.row();
|
||||||
|
|
||||||
|
for(int i = 0; i < items.size; i ++){
|
||||||
|
|
||||||
|
final int f = i;
|
||||||
|
ImageButton button = cont.addImageButton("white", "toggle", 24, () -> {
|
||||||
|
setConfigure(tile, (byte)f);
|
||||||
|
}).size(38, 42).padBottom(-5.1f).group(group).get();
|
||||||
|
button.getStyle().imageUp = new TextureRegionDrawable(new TextureRegion(items.get(i).region));
|
||||||
|
button.setChecked(entity.sortItem.id == f);
|
||||||
|
|
||||||
|
if(i%4 == 3){
|
||||||
|
cont.row();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
table.add(cont);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity getEntity(){
|
||||||
|
return new SortedUnloaderEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SortedUnloaderEntity extends TileEntity{
|
||||||
|
public Item sortItem = Item.iron;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(DataOutputStream stream) throws IOException {
|
||||||
|
stream.writeByte(sortItem.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(DataInputStream stream) throws IOException{
|
||||||
|
sortItem = Item.getAllItems().get(stream.readByte());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,11 +11,12 @@ public abstract class StorageBlock extends Block {
|
|||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Removes any one item and returns it. Returns null if no items are there.*/
|
/**Removes an item and returns it. If item is not null, it should return the item.
|
||||||
public Item removeItem(Tile tile){
|
* Returns null if no items are there.*/
|
||||||
|
public Item removeItem(Tile tile, Item item){
|
||||||
TileEntity entity = tile.entity;
|
TileEntity entity = tile.entity;
|
||||||
for(int i = 0; i < entity.inventory.items.length; i ++){
|
for(int i = 0; i < entity.inventory.items.length; i ++){
|
||||||
if(entity.inventory.items[i] > 0){
|
if(entity.inventory.items[i] > 0 && (item == null || i == item.id)){
|
||||||
entity.inventory.items[i] --;
|
entity.inventory.items[i] --;
|
||||||
return Item.getByID(i);
|
return Item.getByID(i);
|
||||||
}
|
}
|
||||||
@@ -23,10 +24,12 @@ public abstract class StorageBlock extends Block {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasItem(Tile tile){
|
/**Returns whether this storage block has the specified item.
|
||||||
|
* If the item is null, it should return whether it has ANY items.*/
|
||||||
|
public boolean hasItem(Tile tile, Item item){
|
||||||
TileEntity entity = tile.entity;
|
TileEntity entity = tile.entity;
|
||||||
for(int i = 0; i < entity.inventory.items.length; i ++){
|
for(int i = 0; i < entity.inventory.items.length; i ++){
|
||||||
if(entity.inventory.items[i] > 0){
|
if(entity.inventory.items[i] > 0 && (item == null || i == item.id)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.world.blocks.types.storage;
|
|||||||
|
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.BlockGroup;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
public class Unloader extends Block {
|
public class Unloader extends Block {
|
||||||
@@ -12,6 +13,7 @@ public class Unloader extends Block {
|
|||||||
update = true;
|
update = true;
|
||||||
solid = true;
|
solid = true;
|
||||||
health = 70;
|
health = 70;
|
||||||
|
group = BlockGroup.transportation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -19,8 +21,8 @@ public class Unloader extends Block {
|
|||||||
if(tile.entity.inventory.totalItems() == 0 && tile.entity.timer.get(timerUnload, 5)){
|
if(tile.entity.inventory.totalItems() == 0 && tile.entity.timer.get(timerUnload, 5)){
|
||||||
tile.allNearby(other -> {
|
tile.allNearby(other -> {
|
||||||
if(other.block() instanceof StorageBlock && tile.entity.inventory.totalItems() == 0 &&
|
if(other.block() instanceof StorageBlock && tile.entity.inventory.totalItems() == 0 &&
|
||||||
((StorageBlock)other.block()).hasItem(other)){
|
((StorageBlock)other.block()).hasItem(other, null)){
|
||||||
offloadNear(tile, ((StorageBlock)other.block()).removeItem(other));
|
offloadNear(tile, ((StorageBlock)other.block()).removeItem(other, null));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user