Merge branch 'master' of https://github.com/Anuken/Mindustry into mechs-balance-altfire
# Conflicts: # core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java
This commit is contained in:
@@ -28,12 +28,10 @@ import io.anuke.ucore.util.Translator;
|
||||
import java.util.Locale;
|
||||
|
||||
public class Vars{
|
||||
//respawn time in frames
|
||||
public static final float respawnduration = 60 * 4;
|
||||
//time between waves in frames (on normal mode)
|
||||
public static final float wavespace = 60 * 60 * 1.5f;
|
||||
//set ridiculously high for now
|
||||
public static final float coreBuildRange = 800999f;
|
||||
public static final float coreBuildRange = 999999f;
|
||||
//team of the player by default
|
||||
public static final Team defaultTeam = Team.blue;
|
||||
//team of the enemy in waves
|
||||
|
||||
@@ -352,7 +352,7 @@ public class Control extends Module{
|
||||
throw new RuntimeException(error);
|
||||
}
|
||||
|
||||
if(Inputs.keyTap("console")){
|
||||
if(debug && Inputs.keyTap("console")){
|
||||
console = !console;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,8 +66,6 @@ public class Logic extends Module{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Events.fire(PlayEvent.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,18 +80,8 @@ public class NetClient extends Module{
|
||||
|
||||
player.isAdmin = false;
|
||||
|
||||
Net.setClientLoaded(false);
|
||||
removed.clear();
|
||||
timeoutTime = 0f;
|
||||
connecting = true;
|
||||
quiet = false;
|
||||
lastSent = 0;
|
||||
lastSnapshotBase = null;
|
||||
currentSnapshot = null;
|
||||
currentSnapshotID = -1;
|
||||
lastSnapshotBaseID = -1;
|
||||
reset();
|
||||
|
||||
ui.chatfrag.clearMessages();
|
||||
ui.loadfrag.hide();
|
||||
ui.loadfrag.show("$text.connecting.data");
|
||||
|
||||
@@ -102,8 +92,6 @@ public class NetClient extends Module{
|
||||
Net.disconnect();
|
||||
});
|
||||
|
||||
Entities.clear();
|
||||
|
||||
ConnectPacket c = new ConnectPacket();
|
||||
c.name = player.name;
|
||||
c.mobile = mobile;
|
||||
@@ -161,6 +149,29 @@ public class NetClient extends Module{
|
||||
ui.loadfrag.hide();
|
||||
}
|
||||
|
||||
@Remote(variants = Variant.both)
|
||||
public static void onInfoMessage(String message){
|
||||
threads.runGraphics(() -> ui.showText("", message));
|
||||
}
|
||||
|
||||
@Remote(variants = Variant.both)
|
||||
public static void onWorldDataBegin(){
|
||||
Entities.clear();
|
||||
ui.chatfrag.clearMessages();
|
||||
Net.setClientLoaded(false);
|
||||
|
||||
threads.runGraphics(() -> {
|
||||
ui.loadfrag.show("$text.connecting.data");
|
||||
|
||||
ui.loadfrag.setButton(() -> {
|
||||
ui.loadfrag.hide();
|
||||
netClient.connecting = false;
|
||||
netClient.quiet = true;
|
||||
Net.disconnect();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Remote(variants = Variant.one)
|
||||
public static void onPositionSet(float x, float y){
|
||||
players[0].x = x;
|
||||
@@ -285,7 +296,6 @@ public class NetClient extends Module{
|
||||
|
||||
//go through each entity
|
||||
for(int j = 0; j < amount; j++){
|
||||
int position = netClient.byteStream.position(); //save position to check read/write correctness
|
||||
int id = input.readInt();
|
||||
byte typeID = input.readByte();
|
||||
|
||||
@@ -304,11 +314,6 @@ public class NetClient extends Module{
|
||||
//read the entity
|
||||
entity.read(input, timestamp);
|
||||
|
||||
byte readLength = input.readByte();
|
||||
//if(netClient.byteStream.position() - position - 1 != readLength){
|
||||
// throw new RuntimeException("Error reading entity of type '" + group.getType() + "': Read length mismatch [write=" + readLength + ", read=" + (netClient.byteStream.position() - position - 1) + "]");
|
||||
//}
|
||||
|
||||
if(add){
|
||||
entity.add();
|
||||
netClient.addRemovedEntity(entity.getID());
|
||||
@@ -352,6 +357,22 @@ public class NetClient extends Module{
|
||||
Timers.runTask(40f, Platform.instance::updateRPC);
|
||||
}
|
||||
|
||||
private void reset(){
|
||||
Net.setClientLoaded(false);
|
||||
removed.clear();
|
||||
timeoutTime = 0f;
|
||||
connecting = true;
|
||||
quiet = false;
|
||||
lastSent = 0;
|
||||
lastSnapshotBase = null;
|
||||
currentSnapshot = null;
|
||||
currentSnapshotID = -1;
|
||||
lastSnapshotBaseID = -1;
|
||||
|
||||
Entities.clear();
|
||||
ui.chatfrag.clearMessages();
|
||||
}
|
||||
|
||||
public void beginConnecting(){
|
||||
connecting = true;
|
||||
}
|
||||
|
||||
@@ -190,15 +190,7 @@ public class NetServer extends Module{
|
||||
|
||||
trace.playerid = player.id;
|
||||
|
||||
//TODO try DeflaterOutputStream
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
DeflaterOutputStream def = new DeflaterOutputStream(stream);
|
||||
NetworkIO.writeWorld(player, def);
|
||||
WorldStream data = new WorldStream();
|
||||
data.stream = new ByteArrayInputStream(stream.toByteArray());
|
||||
Net.sendStream(id, data);
|
||||
|
||||
Log.info("Packed {0} uncompressed bytes of WORLD data.", stream.size());
|
||||
sendWorldData(player, id);
|
||||
|
||||
Platform.instance.updateRPC();
|
||||
});
|
||||
@@ -317,6 +309,17 @@ public class NetServer extends Module{
|
||||
}
|
||||
}
|
||||
|
||||
public void sendWorldData(Player player, int clientID){
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
DeflaterOutputStream def = new DeflaterOutputStream(stream);
|
||||
NetworkIO.writeWorld(player, def);
|
||||
WorldStream data = new WorldStream();
|
||||
data.stream = new ByteArrayInputStream(stream.toByteArray());
|
||||
Net.sendStream(clientID, data);
|
||||
|
||||
Log.info("Packed {0} compressed bytes of world data.", stream.size());
|
||||
}
|
||||
|
||||
public static void onDisconnect(Player player){
|
||||
if(player.con.hasConnected){
|
||||
Call.sendMessage("[accent]" + player.name + "[accent] has disconnected.");
|
||||
@@ -483,7 +486,6 @@ public class NetServer extends Module{
|
||||
int length = syncStream.position() - position; //length must always be less than 127 bytes
|
||||
if(length > 127)
|
||||
throw new RuntimeException("Write size for entity of type " + group.getType() + " must not exceed 127!");
|
||||
dataStream.writeByte(length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -702,7 +702,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
dead = true;
|
||||
trail.clear();
|
||||
health = maxHealth();
|
||||
mech = (mobile ? Mechs.starterMobile : Mechs.starterDesktop);
|
||||
mech = (isMobile ? Mechs.starterMobile : Mechs.starterDesktop);
|
||||
placeQueue.clear();
|
||||
|
||||
add();
|
||||
|
||||
@@ -320,7 +320,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
|
||||
if(target != null) behavior();
|
||||
|
||||
if(!isWave){
|
||||
if(!isWave && !isFlying()){
|
||||
x = Mathf.clamp(x, 0, world.width() * tilesize);
|
||||
y = Mathf.clamp(y, 0, world.height() * tilesize);
|
||||
}
|
||||
|
||||
@@ -21,10 +21,12 @@ public enum GameMode{
|
||||
isPvp = true;
|
||||
hidden = true;
|
||||
enemyCoreBuildRadius = 600f;
|
||||
respawnTime = 60 * 10;
|
||||
}};
|
||||
|
||||
public boolean infiniteResources, disableWaveTimer, disableWaves, hidden, autoSpawn, isPvp;
|
||||
public float enemyCoreBuildRadius = 400f;
|
||||
public float respawnTime = 60 * 4;
|
||||
|
||||
public String description(){
|
||||
return Bundles.get("mode." + name() + ".description");
|
||||
|
||||
@@ -248,7 +248,7 @@ public class WorldGenerator{
|
||||
double iceridge = rid.getValue(x+99999, y, 1f / 300f) + sim3.octaveNoise2D(2, 1f, 1f/14f, x, y)/11f;
|
||||
double elevation = elevationOf(x, y, detailed);
|
||||
double temp = vn.noise(x, y, 1f / 300f) * sim3.octaveNoise2D(detailed ? 2 : 1, 1, 1f / 13f, x, y)/13f
|
||||
+ sim3.octaveNoise2D(detailed ? 12 : 6, 0.6, 1f / 920f, x, y);
|
||||
+ sim3.octaveNoise2D(detailed ? 12 : 9, 0.6, 1f / 920f, x, y);
|
||||
|
||||
int lerpDst = 20;
|
||||
lerpDst *= lerpDst;
|
||||
@@ -272,6 +272,10 @@ public class WorldGenerator{
|
||||
floor = Blocks.water;
|
||||
}else if(elevation < 0.85){
|
||||
floor = Blocks.sand;
|
||||
}else if(temp < 0.42){
|
||||
floor = Blocks.snow;
|
||||
}else if(temp < 0.5){
|
||||
floor = Blocks.stone;
|
||||
}else if(temp < 0.55){
|
||||
floor = Blocks.grass;
|
||||
}else if(temp < 0.6){
|
||||
@@ -288,14 +292,6 @@ public class WorldGenerator{
|
||||
floor = Blocks.blackstone;
|
||||
}
|
||||
|
||||
if(temp < 0.6f){
|
||||
if(elevation > 3){
|
||||
floor = Blocks.snow;
|
||||
}else if(elevation > 2.5){
|
||||
floor = Blocks.stone;
|
||||
}
|
||||
}
|
||||
|
||||
if(elevation > 3.3 && iceridge > 0.25 && temp < 0.6f){
|
||||
elevation ++;
|
||||
floor = Blocks.ice;
|
||||
@@ -317,7 +313,7 @@ public class WorldGenerator{
|
||||
|
||||
double elevationOf(int x, int y, boolean detailed){
|
||||
double ridge = rid.getValue(x, y, 1f / 400f);
|
||||
return sim.octaveNoise2D(detailed ? 7 : 2, 0.62, 1f / 640, x, y) * 6.1 - 1 - ridge;
|
||||
return sim.octaveNoise2D(detailed ? 7 : 4, 0.62, 1f / 640, x, y) * 6.1 - 1 - ridge;
|
||||
}
|
||||
|
||||
public static class GenResult{
|
||||
|
||||
@@ -118,6 +118,8 @@ public class NetworkIO{
|
||||
i += consecutives;
|
||||
}
|
||||
|
||||
stream.write(Team.all.length);
|
||||
|
||||
//write team data
|
||||
for(Team team : Team.all){
|
||||
TeamData data = state.teams.get(team);
|
||||
|
||||
@@ -14,7 +14,7 @@ public class ItemImage extends Stack{
|
||||
public ItemImage(TextureRegion region, Supplier<CharSequence> text){
|
||||
Table t = new Table().left().bottom();
|
||||
|
||||
t.label(text).color(Color.DARK_GRAY).padBottom(-22).get().setFontScale(Unit.dp.scl(0.5f));
|
||||
t.label(text).color(Color.DARK_GRAY).padBottom(-21).get().setFontScale(Unit.dp.scl(0.5f));
|
||||
t.row();
|
||||
t.label(text).get().setFontScale(Unit.dp.scl(0.5f));
|
||||
|
||||
@@ -25,7 +25,7 @@ public class ItemImage extends Stack{
|
||||
public ItemImage(ItemStack stack){
|
||||
Table t = new Table().left().bottom();
|
||||
|
||||
t.add(stack.amount + "").color(Color.DARK_GRAY).padBottom(-22).get().setFontScale(Unit.dp.scl(0.5f));
|
||||
t.add(stack.amount + "").color(Color.DARK_GRAY).padBottom(-21).get().setFontScale(Unit.dp.scl(0.5f));
|
||||
t.row();
|
||||
t.add(stack.amount + "").get().setFontScale(Unit.dp.scl(0.5f));
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ public class CoreBlock extends StorageBlock{
|
||||
if(entity.currentUnit != null){
|
||||
entity.heat = Mathf.lerpDelta(entity.heat, 1f, 0.1f);
|
||||
entity.time += Timers.delta();
|
||||
entity.progress += 1f / (entity.currentUnit instanceof Player ? respawnduration : droneRespawnDuration) * Timers.delta();
|
||||
entity.progress += 1f / (entity.currentUnit instanceof Player ? state.mode.respawnTime : droneRespawnDuration) * Timers.delta();
|
||||
|
||||
//instant build for fast testing.
|
||||
if(debug){
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ConsumeLiquid extends Consume{
|
||||
|
||||
@Override
|
||||
public boolean valid(Block block, TileEntity entity){
|
||||
return entity.liquids.get(liquid) >= use(block);
|
||||
return entity != null && entity.liquids != null && entity.liquids.get(liquid) >= use(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user