Merge branch '6.0' of https://github.com/Anuken/Mindustry into object-config

# Conflicts:
#	core/src/mindustry/entities/traits/BuilderTrait.java
#	core/src/mindustry/entities/type/TileEntity.java
#	core/src/mindustry/game/EventType.java
#	core/src/mindustry/game/Schematics.java
#	core/src/mindustry/input/InputHandler.java
#	core/src/mindustry/io/TypeIO.java
#	core/src/mindustry/world/Block.java
#	core/src/mindustry/world/blocks/distribution/Sorter.java
This commit is contained in:
Anuken
2020-03-04 08:38:36 -05:00
parent 2581353c5e
commit aeae286273
19 changed files with 55 additions and 62 deletions

View File

@@ -477,9 +477,10 @@ public class Block extends BlockStorage{
/** Called when arbitrary configuration is applied to a tile. */
public void configured(Tile tile, @Nullable Playerc player, @Nullable Object value){
if(value == null){
tapped(tile, player);
//TODO
//tapped(tile, player);
}else if(configurations.containsKey(value.getClass())){
configurations.get(value.getClass()).configured(tile, player, value);
configurations.get(value.getClass()).configured(tile, value);
}
}
@@ -929,7 +930,7 @@ public class Block extends BlockStorage{
}
public interface ConfigHandler<T>{
void configured(Tile tile, Player player, T value);
void configured(Tile tile, T value);
}
}

View File

@@ -37,17 +37,13 @@ public class ItemBridge extends Block{
layer = Layer.power;
expanded = true;
itemCapacity = 10;
posConfig = true;
configurable = true;
hasItems = true;
unloadable = false;
group = BlockGroup.transportation;
entityType = ItemBridgeEntity::new;
}
@Override
public void configured(Tile tile, Playerc player, int value){
tile.<ItemBridgeEntity>ent().link = value;
config(Integer.class, (tile, i) -> tile.<ItemBridgeEntity>ent().link = i);
}
@Override
@@ -371,7 +367,7 @@ public class ItemBridge extends Block{
public float cycleSpeed = 1f;
@Override
public int config(){
public Object config(){
return link;
}

View File

@@ -36,7 +36,6 @@ public class MassDriver extends Block{
super(name);
update = true;
solid = true;
posConfig = true;
configurable = true;
hasItems = true;
layer = Layer.turret;
@@ -46,7 +45,7 @@ public class MassDriver extends Block{
}
@Override
public void configured(Tile tile, Playerc player, int value){
public void configured(Tile tile, Playerc player, Object value){
tile.<MassDriverEntity>ent().link = value;
}

View File

@@ -30,7 +30,8 @@ public class Sorter extends Block{
configurable = true;
unloadable = false;
entityType = SorterEntity::new;
config(Item.class, (tile, player, item) -> tile.<SorterEntity>ent().sortItem = item);
config(Item.class, (tile, item) -> tile.<SorterEntity>ent().sortItem = item);
}
@Override
@@ -46,8 +47,8 @@ public class Sorter extends Block{
}
@Override
public void configured(Tile tile, Playerc player, int value){
tile.<SorterEntity>ent().sortItem = content.item(value);
public void configured(Tile tile, Playerc player, Object value){
tile.<SorterEntity>ent().sortItem = (Item)value;
if(!headless){
renderer.minimap.update(tile);
}
@@ -148,7 +149,7 @@ public class Sorter extends Block{
@Nullable Item sortItem;
@Override
public Item config(){
public Object config(){
return sortItem;
}

View File

@@ -62,7 +62,7 @@ public class LightBlock extends Block{
}
@Override
public void configured(Tile tile, Playerc player, int value){
public void configured(Tile tile, Playerc player, Object value){
tile.<LightEntity>ent().color = value;
}

View File

@@ -38,7 +38,7 @@ public class PowerNode extends PowerBlock{
}
@Override
public void configured(Tile tile, Playerc player, int value){
public void configured(Tile tile, Playerc player, Object value){
Tilec entity = tile.entity;
Tile other = world.tile(value);
boolean contains = entity.power().links.contains(value), valid = other != null && other.entity != null && other.entity.power() != null;

View File

@@ -30,7 +30,7 @@ public class ItemSource extends Block{
}
@Override
public void configured(Tile tile, Playerc player, int value){
public void configured(Tile tile, Playerc player, Object value){
tile.<ItemSourceEntity>ent().outputItem = content.item(value);
}

View File

@@ -28,6 +28,8 @@ public class LiquidSource extends Block{
configurable = true;
outputsLiquid = true;
entityType = LiquidSourceEntity::new;
config();
}
@Override
@@ -85,7 +87,7 @@ public class LiquidSource extends Block{
}
@Override
public void configured(Tile tile, Playerc player, int value){
public void configured(Tile tile, Playerc player, Object value){
tile.<LiquidSourceEntity>ent().source = value == -1 ? null : content.liquid(value);
}
@@ -93,8 +95,8 @@ public class LiquidSource extends Block{
public @Nullable Liquid source = null;
@Override
public int config(){
return source == null ? -1 : source.id;
public Object config(){
return source;
}
@Override

View File

@@ -55,7 +55,7 @@ public class Unloader extends Block{
}
@Override
public void configured(Tile tile, Playerc player, int value){
public void configured(Tile tile, Playerc player, Object value){
tile.entity.items().clear();
tile.<UnloaderEntity>ent().sortItem = content.item(value);
}

View File

@@ -103,7 +103,7 @@ public class CommandCenter extends Block{
}
@Override
public void configured(Tile tile, Playerc player, int value){
public void configured(Tile tile, Playerc player, Object value){
UnitCommand command = UnitCommand.all[value];
((CommandCenter)tile.block()).effect.at(tile);