Bugfixes, cleanup / Created stub processor class

This commit is contained in:
Anuken
2020-03-17 11:51:33 -04:00
parent 08488857da
commit 0ed21a1d5f
6 changed files with 58 additions and 39 deletions

View File

@@ -41,20 +41,6 @@ public class EditorTile extends Tile{
super.setFloor(type);
}
@Override
public void setBlock(Block type){
if(state.is(State.playing)){
super.setBlock(type);
return;
}
if(block == type) return;
op(OpType.block, block.id);
if(rotation != 0) op(OpType.rotation, rotation);
if(team() != Team.derelict) op(OpType.team, team().id);
super.setBlock(type);
}
@Override
public void setBlock(Block type, Team team, int rotation){
if(state.is(State.playing)){
@@ -62,9 +48,10 @@ public class EditorTile extends Tile{
return;
}
setBlock(type);
setTeam(team);
rotation(rotation);
op(OpType.block, block.id);
if(rotation != 0) op(OpType.rotation, (byte)rotation);
if(team() != Team.derelict) op(OpType.team, team().id);
super.setBlock(type, team, rotation);
}
@Override
@@ -93,20 +80,15 @@ public class EditorTile extends Tile{
@Override
public void setOverlay(Block overlay){
setOverlayID(overlay.id);
}
@Override
public void setOverlayID(short overlay){
if(state.is(State.playing)){
super.setOverlayID(overlay);
super.setOverlay(overlay);
return;
}
if(floor.isLiquid) return;
if(overlayID() == overlay) return;
if(overlay() == overlay) return;
op(OpType.overlay, this.overlay.id);
super.setOverlayID(overlay);
super.setOverlay(overlay);
}
@Override

View File

@@ -421,10 +421,8 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc{
for(int i = 0; i < proximity.size; i++){
incrementDump(proximity.size);
Tilec other = proximity.get((i + dump) % proximity.size);
//TODO fix position
Tilec in = Edges.getFacingEdge(tile(), other.tile()).entity;
if(other.team() == team() && other.acceptItem(in, item) && canDump(other, item)){
other.handleItem(in, item);
if(other.team() == team() && other.acceptItem(this, item) && canDump(other, item)){
other.handleItem(this, item);
return;
}
}
@@ -451,24 +449,22 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc{
for(int i = 0; i < proximity.size; i++){
Tilec other = proximity.get((i + dump) % proximity.size);
//TODO fix position
Tilec in = Edges.getFacingEdge(tile, other.tile()).entity;
if(todump == null){
for(int ii = 0; ii < content.items().size; ii++){
Item item = content.item(ii);
if(other.team() == team() && items.has(item) && other.acceptItem(in, item) && canDump(other, item)){
other.handleItem(in, item);
if(other.team() == team() && items.has(item) && other.acceptItem(this, item) && canDump(other, item)){
other.handleItem(this, item);
items.remove(item, 1);
incrementDump(proximity.size);
return true;
}
}
}else{
if(other.team() == team() && other.acceptItem(in, todump) && canDump(other, todump)){
other.handleItem(in, todump);
if(other.team() == team() && other.acceptItem(this, todump) && canDump(other, todump)){
other.handleItem(this, todump);
items.remove(todump, 1);
incrementDump(proximity.size);
return true;
@@ -798,10 +794,10 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc{
/**
* Called when another tile is tapped while this block is selected.
* Returns whether or not this block should be deselected.
* @return whether or not this block should be deselected.
*/
public boolean onConfigureTileTapped(Tilec other){
return tile != other;
return this != other;
}
/** Returns whether this config menu should show when the specified player taps it. */

View File

@@ -570,6 +570,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
boolean tileTapped(@Nullable Tilec tile){
if(tile == null){
frag.inv.hide();
frag.config.hideConfig();
return false;
}
boolean consumed = false, showedInventory = false;

View File

@@ -497,6 +497,10 @@ public class Tile implements Position{
other.entity = null;
}
other.block = Blocks.air;
//manually call changed event
other.updateOcclusion();
world.notifyChanged(other);
}
}
}

View File

@@ -21,8 +21,7 @@ public class BurstTurret extends ItemTurret{
for(int i = 0; i < shots; i++){
Time.run(burstSpacing * i, () -> {
if(!(tile.entity instanceof TurretEntity) ||
!hasAmmo()) return;
if(!(tile.entity instanceof TurretEntity) || !hasAmmo()) return;
recoil = recoilAmount;

View File

@@ -0,0 +1,37 @@
package mindustry.world.blocks.logic;
import arc.scene.ui.layout.*;
import arc.struct.*;
import mindustry.gen.*;
import mindustry.world.*;
public class ProcessorBlock extends Block{
public ProcessorBlock(String name){
super(name);
configurable = true;
}
public class ProcessorEntity extends TileEntity{
//all tiles in the block network - does not include itself
Array<Tilec> network = new Array<>();
@Override
public boolean onConfigureTileTapped(Tilec other){
if(other == this) return true;
if(!network.contains(other)){
network.add(other);
}else{
network.remove(other);
}
return false;
}
@Override
public void buildConfiguration(Table table){
super.buildConfiguration(table);
}
}
}