Better API for saving block configs
This commit is contained in:
@@ -294,6 +294,7 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
//build method using same params/returns
|
//build method using same params/returns
|
||||||
MethodSpec.Builder mbuilder = MethodSpec.methodBuilder(first.name()).addModifiers(first.is(Modifier.PRIVATE) ? Modifier.PRIVATE : Modifier.PUBLIC);
|
MethodSpec.Builder mbuilder = MethodSpec.methodBuilder(first.name()).addModifiers(first.is(Modifier.PRIVATE) ? Modifier.PRIVATE : Modifier.PUBLIC);
|
||||||
if(isFinal || entry.value.contains(s -> s.has(Final.class))) mbuilder.addModifiers(Modifier.FINAL);
|
if(isFinal || entry.value.contains(s -> s.has(Final.class))) mbuilder.addModifiers(Modifier.FINAL);
|
||||||
|
if(entry.value.contains(s -> s.has(CallSuper.class))) mbuilder.addAnnotation(CallSuper.class); //add callSuper here if necessary
|
||||||
if(first.is(Modifier.STATIC)) mbuilder.addModifiers(Modifier.STATIC);
|
if(first.is(Modifier.STATIC)) mbuilder.addModifiers(Modifier.STATIC);
|
||||||
mbuilder.addTypeVariables(first.typeVariables().map(TypeVariableName::get));
|
mbuilder.addTypeVariables(first.typeVariables().map(TypeVariableName::get));
|
||||||
mbuilder.returns(first.retn());
|
mbuilder.returns(first.retn());
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public class PhysicsProcess implements AsyncProcess{
|
|||||||
ref.position.set(entity);
|
ref.position.set(entity);
|
||||||
|
|
||||||
//add delta velocity - this doesn't work very well yet
|
//add delta velocity - this doesn't work very well yet
|
||||||
entity.vel().add(ref.velocity).sub(ref.lastVelocity);
|
//entity.vel().add(ref.velocity).sub(ref.lastVelocity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -144,6 +144,18 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
|
|||||||
//endregion
|
//endregion
|
||||||
//region utility methods
|
//region utility methods
|
||||||
|
|
||||||
|
/** Configure with the current, local player. */
|
||||||
|
public void configure(Object value){
|
||||||
|
//save last used config
|
||||||
|
block.lastConfig = value;
|
||||||
|
Call.onTileConfig(player, this, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Configure from a server. */
|
||||||
|
public void configureAny(Object value){
|
||||||
|
Call.onTileConfig(null, this, value);
|
||||||
|
}
|
||||||
|
|
||||||
public void applyBoost(float intensity, float duration){
|
public void applyBoost(float intensity, float duration){
|
||||||
timeScale = Math.max(timeScale, intensity);
|
timeScale = Math.max(timeScale, intensity);
|
||||||
timeScaleDuration = Math.max(timeScaleDuration, duration);
|
timeScaleDuration = Math.max(timeScaleDuration, duration);
|
||||||
@@ -670,7 +682,9 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
|
|||||||
/** Called after the block is placed by this client. */
|
/** Called after the block is placed by this client. */
|
||||||
@CallSuper
|
@CallSuper
|
||||||
public void playerPlaced(){
|
public void playerPlaced(){
|
||||||
|
if(block.saveConfig && block.lastConfig != null){
|
||||||
|
configure(block.lastConfig);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called after the block is placed by anyone. */
|
/** Called after the block is placed by anyone. */
|
||||||
@@ -692,7 +706,7 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
|
|||||||
if(!tempTiles.isEmpty()){
|
if(!tempTiles.isEmpty()){
|
||||||
Tile toLink = tempTiles.first();
|
Tile toLink = tempTiles.first();
|
||||||
if(!toLink.entity.power().links.contains(pos())){
|
if(!toLink.entity.power().links.contains(pos())){
|
||||||
toLink.configureAny(pos());
|
toLink.entity.configureAny(pos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -287,7 +287,9 @@ public class Schematics implements Loadable{
|
|||||||
tile.rotation(st.rotation);
|
tile.rotation(st.rotation);
|
||||||
|
|
||||||
Object config = st.config;
|
Object config = st.config;
|
||||||
tile.configureAny(config);
|
if(tile.entity != null){
|
||||||
|
tile.entity.configureAny(config);
|
||||||
|
}
|
||||||
|
|
||||||
if(st.block instanceof Drill){
|
if(st.block instanceof Drill){
|
||||||
tile.getLinkedTiles(t -> t.setOverlay(Blocks.oreCopper));
|
tile.getLinkedTiles(t -> t.setOverlay(Blocks.oreCopper));
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import arc.struct.Array;
|
|||||||
import arc.struct.EnumSet;
|
import arc.struct.EnumSet;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
|
import arc.util.ArcAnnotate.*;
|
||||||
import arc.util.pooling.*;
|
import arc.util.pooling.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
@@ -55,6 +56,10 @@ public class Block extends UnlockableContent{
|
|||||||
public final BlockBars bars = new BlockBars();
|
public final BlockBars bars = new BlockBars();
|
||||||
public final Consumers consumes = new Consumers();
|
public final Consumers consumes = new Consumers();
|
||||||
|
|
||||||
|
/** the last configuration value applied to this block. */
|
||||||
|
public @Nullable Object lastConfig;
|
||||||
|
/** whether to save the last config and apply it to newly placed blocks */
|
||||||
|
public boolean saveConfig = false;
|
||||||
/** whether this block has a tile entity that updates */
|
/** whether this block has a tile entity that updates */
|
||||||
public boolean update;
|
public boolean update;
|
||||||
/** whether this block has health and can be destroyed */
|
/** whether this block has health and can be destroyed */
|
||||||
|
|||||||
@@ -95,15 +95,6 @@ public class Tile implements Position, QuadTreeObject{
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Configure a tile with the current, local player. */
|
|
||||||
public void configure(Object value){
|
|
||||||
if(entity != null) Call.onTileConfig(player, entity, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void configureAny(Object value){
|
|
||||||
if(entity != null) Call.onTileConfig(null, entity, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T extends TileEntity> T ent(){
|
public <T extends TileEntity> T ent(){
|
||||||
return (T)entity;
|
return (T)entity;
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class Door extends Wall{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tile.configure(!open);
|
configure(!open);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -20,15 +20,15 @@ import mindustry.world.meta.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class ItemBridge extends Block{
|
public class ItemBridge extends Block{
|
||||||
|
private static BuildRequest otherReq;
|
||||||
|
|
||||||
public final int timerTransport = timers++;
|
public final int timerTransport = timers++;
|
||||||
public int range;
|
public int range;
|
||||||
public float transportTime = 2f;
|
public float transportTime = 2f;
|
||||||
public @Load("@-end") TextureRegion endRegion;
|
public @Load("@-end") TextureRegion endRegion;
|
||||||
public @Load("@-bridge") TextureRegion bridgeRegion;
|
public @Load("@-bridge") TextureRegion bridgeRegion;
|
||||||
public @Load("@-arrow") TextureRegion arrowRegion;
|
public @Load("@-arrow") TextureRegion arrowRegion;
|
||||||
|
public int lastPlaced = -1;
|
||||||
private static BuildRequest otherReq;
|
|
||||||
private static int lastPlaced = -1;
|
|
||||||
|
|
||||||
public ItemBridge(String name){
|
public ItemBridge(String name){
|
||||||
super(name);
|
super(name);
|
||||||
@@ -132,7 +132,7 @@ public class ItemBridge extends Block{
|
|||||||
public void playerPlaced(){
|
public void playerPlaced(){
|
||||||
Tile link = findLink(tile.x, tile.y);
|
Tile link = findLink(tile.x, tile.y);
|
||||||
if(linkValid(tile, link)){
|
if(linkValid(tile, link)){
|
||||||
link.configure(tile.pos());
|
configure(tile.pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
lastPlaced = tile.pos();
|
lastPlaced = tile.pos();
|
||||||
@@ -165,9 +165,9 @@ public class ItemBridge extends Block{
|
|||||||
public boolean onConfigureTileTapped(Tilec other){
|
public boolean onConfigureTileTapped(Tilec other){
|
||||||
if(linkValid(tile, other.tile())){
|
if(linkValid(tile, other.tile())){
|
||||||
if(link == other.pos()){
|
if(link == other.pos()){
|
||||||
tile.configure(-1);
|
configure(-1);
|
||||||
}else{
|
}else{
|
||||||
tile.configure(other.pos());
|
configure(other.pos());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,15 +213,15 @@ public class MassDriver extends Block{
|
|||||||
@Override
|
@Override
|
||||||
public boolean onConfigureTileTapped(Tilec other){
|
public boolean onConfigureTileTapped(Tilec other){
|
||||||
if(this == other){
|
if(this == other){
|
||||||
tile.configure(-1);
|
configure(-1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(link == other.pos()){
|
if(link == other.pos()){
|
||||||
tile.configure(-1);
|
configure(-1);
|
||||||
return false;
|
return false;
|
||||||
}else if(other.block() instanceof MassDriver && other.dst(tile) <= range && other.team() == team){
|
}else if(other.block() instanceof MassDriver && other.dst(tile) <= range && other.team() == team){
|
||||||
tile.configure(other.pos());
|
configure(other.pos());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import mindustry.world.meta.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class Sorter extends Block{
|
public class Sorter extends Block{
|
||||||
private static Item lastItem;
|
|
||||||
public boolean invert;
|
public boolean invert;
|
||||||
|
|
||||||
public Sorter(String name){
|
public Sorter(String name){
|
||||||
@@ -27,6 +26,8 @@ public class Sorter extends Block{
|
|||||||
group = BlockGroup.transportation;
|
group = BlockGroup.transportation;
|
||||||
configurable = true;
|
configurable = true;
|
||||||
unloadable = false;
|
unloadable = false;
|
||||||
|
saveConfig = true;
|
||||||
|
|
||||||
config(Item.class, (tile, item) -> ((SorterEntity)tile).sortItem = item);
|
config(Item.class, (tile, item) -> ((SorterEntity)tile).sortItem = item);
|
||||||
configClear(tile -> ((SorterEntity)tile).sortItem = null);
|
configClear(tile -> ((SorterEntity)tile).sortItem = null);
|
||||||
}
|
}
|
||||||
@@ -49,13 +50,6 @@ public class Sorter extends Block{
|
|||||||
public class SorterEntity extends TileEntity{
|
public class SorterEntity extends TileEntity{
|
||||||
@Nullable Item sortItem;
|
@Nullable Item sortItem;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void playerPlaced(){
|
|
||||||
if(lastItem != null){
|
|
||||||
tile.configure(lastItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configured(Playerc player, Object value){
|
public void configured(Playerc player, Object value){
|
||||||
super.configured(player, value);
|
super.configured(player, value);
|
||||||
@@ -140,14 +134,14 @@ public class Sorter extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildConfiguration(Table table){
|
public void buildConfiguration(Table table){
|
||||||
ItemSelection.buildTable(table, content.items(), () -> sortItem, item -> tile.configure(lastItem = item));
|
ItemSelection.buildTable(table, content.items(), () -> sortItem, item -> configure(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onConfigureTileTapped(Tilec other){
|
public boolean onConfigureTileTapped(Tilec other){
|
||||||
if(this == other){
|
if(this == other){
|
||||||
control.input.frag.config.hideConfig();
|
control.input.frag.config.hideConfig();
|
||||||
tile.configure(lastItem = null);
|
configure(null);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public class MessageBlock extends Block{
|
|||||||
text = message;
|
text = message;
|
||||||
multiline = true;
|
multiline = true;
|
||||||
maxLength = maxTextLength;
|
maxLength = maxTextLength;
|
||||||
accepted = tile::configure;
|
accepted = str -> configure(str);
|
||||||
}});
|
}});
|
||||||
}else{
|
}else{
|
||||||
FloatingDialog dialog = new FloatingDialog("$editmessage");
|
FloatingDialog dialog = new FloatingDialog("$editmessage");
|
||||||
@@ -115,7 +115,7 @@ public class MessageBlock extends Block{
|
|||||||
});
|
});
|
||||||
a.setMaxLength(maxTextLength);
|
a.setMaxLength(maxTextLength);
|
||||||
dialog.buttons.button("$ok", () -> {
|
dialog.buttons.button("$ok", () -> {
|
||||||
tile.configure(a.getText());
|
configure(a.getText());
|
||||||
dialog.hide();
|
dialog.hide();
|
||||||
}).size(130f, 60f);
|
}).size(130f, 60f);
|
||||||
dialog.update(() -> {
|
dialog.update(() -> {
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ import mindustry.world.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class LightBlock extends Block{
|
public class LightBlock extends Block{
|
||||||
private static int lastColor = 0;
|
|
||||||
|
|
||||||
public float brightness = 0.9f;
|
public float brightness = 0.9f;
|
||||||
public float radius = 200f;
|
public float radius = 200f;
|
||||||
public @Load("@-top") TextureRegion topRegion;
|
public @Load("@-top") TextureRegion topRegion;
|
||||||
@@ -24,19 +22,14 @@ public class LightBlock extends Block{
|
|||||||
hasPower = true;
|
hasPower = true;
|
||||||
update = true;
|
update = true;
|
||||||
configurable = true;
|
configurable = true;
|
||||||
|
saveConfig = true;
|
||||||
|
|
||||||
config(Integer.class, (tile, value) -> ((LightEntity)tile).color = value);
|
config(Integer.class, (tile, value) -> ((LightEntity)tile).color = value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LightEntity extends TileEntity{
|
public class LightEntity extends TileEntity{
|
||||||
public int color = Pal.accent.rgba();
|
public int color = Pal.accent.rgba();
|
||||||
|
|
||||||
@Override
|
|
||||||
public void playerPlaced(){
|
|
||||||
if(lastColor != 0){
|
|
||||||
tile.configure(lastColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
super.draw();
|
super.draw();
|
||||||
@@ -50,10 +43,7 @@ public class LightBlock extends Block{
|
|||||||
@Override
|
@Override
|
||||||
public void buildConfiguration(Table table){
|
public void buildConfiguration(Table table){
|
||||||
table.button(Icon.pencil, () -> {
|
table.button(Icon.pencil, () -> {
|
||||||
ui.picker.show(Tmp.c1.set(color).a(0.5f), false, res -> {
|
ui.picker.show(Tmp.c1.set(color).a(0.5f), false, res -> configure(res.rgba()));
|
||||||
color = res.rgba();
|
|
||||||
lastColor = color;
|
|
||||||
});
|
|
||||||
control.input.frag.config.hideConfig();
|
control.input.frag.config.hideConfig();
|
||||||
}).size(40f);
|
}).size(40f);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ public class PowerNode extends PowerBlock{
|
|||||||
});
|
});
|
||||||
tempTileEnts.each(valid, other -> {
|
tempTileEnts.each(valid, other -> {
|
||||||
if(!power.links.contains(other.pos())){
|
if(!power.links.contains(other.pos())){
|
||||||
tile.configureAny(other.pos());
|
configureAny(other.pos());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -300,7 +300,7 @@ public class PowerNode extends PowerBlock{
|
|||||||
@Override
|
@Override
|
||||||
public boolean onConfigureTileTapped(Tilec other){
|
public boolean onConfigureTileTapped(Tilec other){
|
||||||
if(linkValid(this, other)){
|
if(linkValid(this, other)){
|
||||||
tile.configure(other.pos());
|
configure(other.pos());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,12 +309,12 @@ public class PowerNode extends PowerBlock{
|
|||||||
int[] total = {0};
|
int[] total = {0};
|
||||||
getPotentialLinks(tile, link -> {
|
getPotentialLinks(tile, link -> {
|
||||||
if(!insulated(this, link) && total[0]++ < maxNodes){
|
if(!insulated(this, link) && total[0]++ < maxNodes){
|
||||||
tile.configure(link.pos());
|
configure(link.pos());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
while(power.links.size > 0){
|
while(power.links.size > 0){
|
||||||
tile.configure(power.links.get(0));
|
configure(power.links.get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package mindustry.world.blocks.sandbox;
|
package mindustry.world.blocks.sandbox;
|
||||||
|
|
||||||
import arc.*;
|
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
@@ -15,7 +14,6 @@ import mindustry.world.meta.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class ItemSource extends Block{
|
public class ItemSource extends Block{
|
||||||
private static Item lastItem;
|
|
||||||
|
|
||||||
public ItemSource(String name){
|
public ItemSource(String name){
|
||||||
super(name);
|
super(name);
|
||||||
@@ -24,6 +22,8 @@ public class ItemSource extends Block{
|
|||||||
solid = true;
|
solid = true;
|
||||||
group = BlockGroup.transportation;
|
group = BlockGroup.transportation;
|
||||||
configurable = true;
|
configurable = true;
|
||||||
|
saveConfig = true;
|
||||||
|
|
||||||
config(Item.class, (tile, item) -> ((ItemSourceEntity)tile).outputItem = item);
|
config(Item.class, (tile, item) -> ((ItemSourceEntity)tile).outputItem = item);
|
||||||
configClear(tile -> ((ItemSourceEntity)tile).outputItem = null);
|
configClear(tile -> ((ItemSourceEntity)tile).outputItem = null);
|
||||||
}
|
}
|
||||||
@@ -47,13 +47,6 @@ public class ItemSource extends Block{
|
|||||||
public class ItemSourceEntity extends TileEntity{
|
public class ItemSourceEntity extends TileEntity{
|
||||||
Item outputItem;
|
Item outputItem;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void playerPlaced(){
|
|
||||||
if(lastItem != null){
|
|
||||||
Core.app.post(() -> tile.configure(lastItem));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
super.draw();
|
super.draw();
|
||||||
@@ -76,14 +69,14 @@ public class ItemSource extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildConfiguration(Table table){
|
public void buildConfiguration(Table table){
|
||||||
ItemSelection.buildTable(table, content.items(), () -> outputItem, item -> tile.configure(lastItem = item));
|
ItemSelection.buildTable(table, content.items(), () -> outputItem, item -> configure(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onConfigureTileTapped(Tilec other){
|
public boolean onConfigureTileTapped(Tilec other){
|
||||||
if(this == other){
|
if(this == other){
|
||||||
control.input.frag.config.hideConfig();
|
control.input.frag.config.hideConfig();
|
||||||
tile.configure(lastItem = null);
|
configure(null);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package mindustry.world.blocks.sandbox;
|
package mindustry.world.blocks.sandbox;
|
||||||
|
|
||||||
import arc.*;
|
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
@@ -16,7 +15,6 @@ import mindustry.world.blocks.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class LiquidSource extends Block{
|
public class LiquidSource extends Block{
|
||||||
public static Liquid lastLiquid;
|
|
||||||
|
|
||||||
public LiquidSource(String name){
|
public LiquidSource(String name){
|
||||||
super(name);
|
super(name);
|
||||||
@@ -68,27 +66,20 @@ public class LiquidSource extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildConfiguration(Table table){
|
public void buildConfiguration(Table table){
|
||||||
ItemSelection.buildTable(table, content.liquids(), () -> source, liquid -> tile.configure(lastLiquid = liquid));
|
ItemSelection.buildTable(table, content.liquids(), () -> source, liquid -> configure(liquid));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onConfigureTileTapped(Tilec other){
|
public boolean onConfigureTileTapped(Tilec other){
|
||||||
if(this == other){
|
if(this == other){
|
||||||
control.input.frag.config.hideConfig();
|
control.input.frag.config.hideConfig();
|
||||||
tile.configure(lastLiquid = null);
|
configure(null);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void playerPlaced(){
|
|
||||||
if(lastLiquid != null){
|
|
||||||
Core.app.post(() -> tile.configure(lastLiquid));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Liquid config(){
|
public Liquid config(){
|
||||||
return source;
|
return source;
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ public class Unloader extends Block{
|
|||||||
public float speed = 1f;
|
public float speed = 1f;
|
||||||
public final int timerUnload = timers++;
|
public final int timerUnload = timers++;
|
||||||
|
|
||||||
private static Item lastItem;
|
|
||||||
|
|
||||||
public Unloader(String name){
|
public Unloader(String name){
|
||||||
super(name);
|
super(name);
|
||||||
update = true;
|
update = true;
|
||||||
@@ -26,6 +24,8 @@ public class Unloader extends Block{
|
|||||||
health = 70;
|
health = 70;
|
||||||
hasItems = true;
|
hasItems = true;
|
||||||
configurable = true;
|
configurable = true;
|
||||||
|
saveConfig = true;
|
||||||
|
|
||||||
config(Item.class, (tile, item) -> {
|
config(Item.class, (tile, item) -> {
|
||||||
tile.items().clear();
|
tile.items().clear();
|
||||||
((UnloaderEntity)tile).sortItem = item;
|
((UnloaderEntity)tile).sortItem = item;
|
||||||
@@ -69,13 +69,6 @@ public class Unloader extends Block{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void playerPlaced(){
|
|
||||||
if(lastItem != null){
|
|
||||||
tile.configure(lastItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTile(){
|
public void updateTile(){
|
||||||
if(timer(timerUnload, speed / timeScale()) && items.total() == 0){
|
if(timer(timerUnload, speed / timeScale()) && items.total() == 0){
|
||||||
@@ -101,14 +94,14 @@ public class Unloader extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildConfiguration(Table table){
|
public void buildConfiguration(Table table){
|
||||||
ItemSelection.buildTable(table, content.items(), () -> tile.<UnloaderEntity>ent().sortItem, item -> tile.configure(lastItem = item));
|
ItemSelection.buildTable(table, content.items(), () -> tile.<UnloaderEntity>ent().sortItem, item -> configure(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onConfigureTileTapped(Tilec other){
|
public boolean onConfigureTileTapped(Tilec other){
|
||||||
if(this == other){
|
if(this == other){
|
||||||
control.input.frag.config.hideConfig();
|
control.input.frag.config.hideConfig();
|
||||||
tile.configure(lastItem = null);
|
configure(null);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class CommandCenter extends Block{
|
|||||||
Table buttons = new Table();
|
Table buttons = new Table();
|
||||||
|
|
||||||
for(UnitCommand cmd : UnitCommand.all){
|
for(UnitCommand cmd : UnitCommand.all){
|
||||||
buttons.button(commandRegions[cmd.ordinal()], Styles.clearToggleTransi, () -> tile.configure(cmd.ordinal()))
|
buttons.button(commandRegions[cmd.ordinal()], Styles.clearToggleTransi, () -> configure(cmd.ordinal()))
|
||||||
.size(44).group(group).update(b -> b.setChecked(command == cmd));
|
.size(44).group(group).update(b -> b.setChecked(command == cmd));
|
||||||
}
|
}
|
||||||
table.add(buttons);
|
table.add(buttons);
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ public class UnitFactory extends Block{
|
|||||||
public void buildConfiguration(Table table){
|
public void buildConfiguration(Table table){
|
||||||
Array<UnitType> units = Array.with(plans).map(u -> u.unit);
|
Array<UnitType> units = Array.with(plans).map(u -> u.unit);
|
||||||
|
|
||||||
ItemSelection.buildTable(table, units, () -> currentPlan == -1 ? null : plans[currentPlan].unit, unit -> tile.configure(units.indexOf(unit)));
|
ItemSelection.buildTable(table, units, () -> currentPlan == -1 ? null : plans[currentPlan].unit, unit -> configure(units.indexOf(unit)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user