Added variable to control block syncing
This commit is contained in:
@@ -217,7 +217,7 @@ setting.sensitivity.name=Controller Sensitivity
|
|||||||
setting.saveinterval.name=Autosave Interval
|
setting.saveinterval.name=Autosave Interval
|
||||||
setting.seconds={0} Seconds
|
setting.seconds={0} Seconds
|
||||||
setting.fullscreen.name=Fullscreen
|
setting.fullscreen.name=Fullscreen
|
||||||
setting.multithread.name=Multithreading [scarlet](extremely unstable!)
|
setting.multithread.name=Multithreading [scarlet](unstable!)
|
||||||
setting.fps.name=Show FPS
|
setting.fps.name=Show FPS
|
||||||
setting.vsync.name=VSync
|
setting.vsync.name=VSync
|
||||||
setting.lasers.name=Show Power Lasers
|
setting.lasers.name=Show Power Lasers
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#Autogenerated file. Do not modify.
|
#Autogenerated file. Do not modify.
|
||||||
#Sat Feb 17 14:39:13 EST 2018
|
#Sat Feb 17 20:42:58 EST 2018
|
||||||
version=beta
|
version=beta
|
||||||
androidBuildCode=235
|
androidBuildCode=235
|
||||||
name=Mindustry
|
name=Mindustry
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ public class Vars{
|
|||||||
public static final boolean android = (Gdx.app.getType() == ApplicationType.Android) || testAndroid;
|
public static final boolean android = (Gdx.app.getType() == ApplicationType.Android) || testAndroid;
|
||||||
//shorthand for whether or not this is running on GWT
|
//shorthand for whether or not this is running on GWT
|
||||||
public static final boolean gwt = (Gdx.app.getType() == ApplicationType.WebGL);
|
public static final boolean gwt = (Gdx.app.getType() == ApplicationType.WebGL);
|
||||||
|
//whether to send block state change events to players
|
||||||
|
public static final boolean syncBlockState = false;
|
||||||
//how far away from the player blocks can be placed
|
//how far away from the player blocks can be placed
|
||||||
public static final float placerange = 66;
|
public static final float placerange = 66;
|
||||||
//respawn time in frames
|
//respawn time in frames
|
||||||
|
|||||||
@@ -498,8 +498,7 @@ public class Renderer extends RendererModule{
|
|||||||
public void drawBar(Color color, float x, float y, float fraction){
|
public void drawBar(Color color, float x, float y, float fraction){
|
||||||
fraction = Mathf.clamp(fraction);
|
fraction = Mathf.clamp(fraction);
|
||||||
|
|
||||||
if(fraction > 0)
|
if(fraction > 0) fraction = Mathf.clamp(fraction + 0.2f, 0.24f, 1f);
|
||||||
fraction = Mathf.clamp(fraction + 0.2f, 0.24f, 1f);
|
|
||||||
|
|
||||||
float len = 3;
|
float len = 3;
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import io.anuke.ucore.util.Bundles;
|
|||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.state;
|
import static io.anuke.mindustry.Vars.state;
|
||||||
|
import static io.anuke.mindustry.Vars.syncBlockState;
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
|
|
||||||
public class Block{
|
public class Block{
|
||||||
@@ -180,7 +181,7 @@ public class Block{
|
|||||||
* Tries to put this item into a nearby container, if there are no available
|
* Tries to put this item into a nearby container, if there are no available
|
||||||
* containers, it gets added to the block's inventory.*/
|
* containers, it gets added to the block's inventory.*/
|
||||||
public void offloadNear(Tile tile, Item item){
|
public void offloadNear(Tile tile, Item item){
|
||||||
if(Net.client()){
|
if(Net.client() && syncBlockState){
|
||||||
handleItem(item, tile, tile);
|
handleItem(item, tile, tile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -193,7 +194,7 @@ public class Block{
|
|||||||
if(other != null && other.block().acceptItem(item, other, tile)){
|
if(other != null && other.block().acceptItem(item, other, tile)){
|
||||||
other.block().handleItem(item, other, tile);
|
other.block().handleItem(item, other, tile);
|
||||||
tile.setDump((byte)((i+1)%4));
|
tile.setDump((byte)((i+1)%4));
|
||||||
if(Net.server()) NetEvents.handleTransfer(tile, i, item);
|
if(Net.server() && syncBlockState) NetEvents.handleTransfer(tile, i, item);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
@@ -212,7 +213,7 @@ public class Block{
|
|||||||
* Try dumping any item near the tile. -1 = any direction
|
* Try dumping any item near the tile. -1 = any direction
|
||||||
*/
|
*/
|
||||||
protected boolean tryDump(Tile tile, int direction, Item todump){
|
protected boolean tryDump(Tile tile, int direction, Item todump){
|
||||||
if(Net.client()) return false;
|
if(Net.client() && syncBlockState) return false;
|
||||||
|
|
||||||
int i = tile.getDump()%4;
|
int i = tile.getDump()%4;
|
||||||
|
|
||||||
@@ -228,7 +229,7 @@ public class Block{
|
|||||||
other.block().handleItem(item, other, tile);
|
other.block().handleItem(item, other, tile);
|
||||||
tile.entity.removeItem(item, 1);
|
tile.entity.removeItem(item, 1);
|
||||||
tile.setDump((byte)((i+1)%4));
|
tile.setDump((byte)((i+1)%4));
|
||||||
if(Net.server()) NetEvents.handleTransfer(tile, (byte)i, item);
|
if(Net.server() && syncBlockState) NetEvents.handleTransfer(tile, (byte)i, item);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ import java.io.DataInputStream;
|
|||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.syncBlockState;
|
||||||
|
|
||||||
public class Teleporter extends PowerBlock{
|
public class Teleporter extends PowerBlock{
|
||||||
public static final Color[] colorArray = {Color.ROYAL, Color.ORANGE, Color.SCARLET, Color.FOREST,
|
public static final Color[] colorArray = {Color.ROYAL, Color.ORANGE, Color.SCARLET, Color.FOREST,
|
||||||
Color.PURPLE, Color.GOLD, Color.PINK, Color.BLACK};
|
Color.PURPLE, Color.GOLD, Color.PINK, Color.BLACK};
|
||||||
@@ -130,7 +132,7 @@ public class Teleporter extends PowerBlock{
|
|||||||
Array<Tile> links = findLinks(tile, item);
|
Array<Tile> links = findLinks(tile, item);
|
||||||
|
|
||||||
if(links.size > 0){
|
if(links.size > 0){
|
||||||
if(Net.server() || !Net.active()){
|
if(!syncBlockState || Net.server() || !Net.active()){
|
||||||
Tile target = links.random();
|
Tile target = links.random();
|
||||||
target.block().offloadNear(target, item);
|
target.block().offloadNear(target, item);
|
||||||
}
|
}
|
||||||
@@ -181,7 +183,7 @@ public class Teleporter extends PowerBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(Tile remove : removal)
|
for(Tile remove : removal)
|
||||||
teleporters[entity.color].remove(remove);
|
teleporters[entity.color].remove(remove);
|
||||||
|
|
||||||
return returns;
|
return returns;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user