Extensive network refactor
This commit is contained in:
@@ -40,7 +40,7 @@ public class Fire extends TimedEntity implements SaveTrait, SyncTrait{
|
||||
|
||||
/** Start a fire on the tile. If there already is a file there, refreshes its lifetime. */
|
||||
public static void create(Tile tile){
|
||||
if(Net.client() || tile == null) return; //not clientside.
|
||||
if(net.client() || tile == null) return; //not clientside.
|
||||
|
||||
Fire fire = map.get(tile.pos());
|
||||
|
||||
@@ -106,7 +106,7 @@ public class Fire extends TimedEntity implements SaveTrait, SyncTrait{
|
||||
time = Mathf.clamp(time + Time.delta(), 0, lifetime());
|
||||
map.put(tile.pos(), this);
|
||||
|
||||
if(Net.client()){
|
||||
if(net.client()){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
|
||||
|
||||
Puddle p = map.get(tile.pos());
|
||||
if(p == null){
|
||||
if(Net.client()) return; //not clientside.
|
||||
if(net.client()) return; //not clientside.
|
||||
|
||||
Puddle puddle = Pools.obtain(Puddle.class, Puddle::new);
|
||||
puddle.tile = tile;
|
||||
@@ -168,7 +168,7 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
|
||||
public void update(){
|
||||
|
||||
//no updating happens clientside
|
||||
if(Net.client()){
|
||||
if(net.client()){
|
||||
amount = Mathf.lerpDelta(amount, targetAmount, 0.15f);
|
||||
}else{
|
||||
//update code
|
||||
|
||||
@@ -48,7 +48,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
public static void onUnitDeath(BaseUnit unit){
|
||||
if(unit == null) return;
|
||||
|
||||
if(Net.server() || !Net.active()){
|
||||
if(net.server() || !net.active()){
|
||||
UnitDrops.dropItems(unit);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
unit.type.deathSound.at(unit);
|
||||
|
||||
//visual only.
|
||||
if(Net.client()){
|
||||
if(net.client()){
|
||||
Tile tile = world.tile(unit.spawner);
|
||||
if(tile != null){
|
||||
tile.block().unitRemoved(tile, unit);
|
||||
@@ -255,7 +255,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
|
||||
hitTime -= Time.delta();
|
||||
|
||||
if(Net.client()){
|
||||
if(net.client()){
|
||||
interpolate();
|
||||
status.update(this);
|
||||
return;
|
||||
@@ -297,7 +297,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
public void removed(){
|
||||
super.removed();
|
||||
Tile tile = world.tile(spawner);
|
||||
if(tile != null && !Net.client()){
|
||||
if(tile != null && !net.client()){
|
||||
tile.block().unitRemoved(tile, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ public abstract class FlyingUnit extends BaseUnit{
|
||||
public void update(){
|
||||
super.update();
|
||||
|
||||
if(!Net.client()){
|
||||
if(!net.client()){
|
||||
updateRotation();
|
||||
}
|
||||
wobble();
|
||||
@@ -176,7 +176,7 @@ public abstract class FlyingUnit extends BaseUnit{
|
||||
}
|
||||
|
||||
protected void wobble(){
|
||||
if(Net.client()) return;
|
||||
if(net.client()) return;
|
||||
|
||||
x += Mathf.sin(Time.time() + id * 999, 25f, 0.05f) * Time.delta();
|
||||
y += Mathf.cos(Time.time() + id * 999, 25f, 0.05f) * Time.delta();
|
||||
|
||||
@@ -1,34 +1,30 @@
|
||||
package io.anuke.mindustry.entities.type;
|
||||
|
||||
import io.anuke.annotations.Annotations.Loc;
|
||||
import io.anuke.annotations.Annotations.Remote;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.collection.Queue;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.annotations.Annotations.*;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.Angles;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.pooling.Pools;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.arc.util.pooling.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.traits.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.input.*;
|
||||
import io.anuke.mindustry.input.InputHandler.PlaceDraw;
|
||||
import io.anuke.mindustry.io.TypeIO;
|
||||
import io.anuke.mindustry.input.InputHandler.*;
|
||||
import io.anuke.mindustry.io.*;
|
||||
import io.anuke.mindustry.net.Administration.*;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.NetConnection;
|
||||
import io.anuke.mindustry.net.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
|
||||
import java.io.*;
|
||||
@@ -50,7 +46,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
||||
public float baseRotation;
|
||||
public float pointerX, pointerY;
|
||||
public String name = "name";
|
||||
public String uuid, usid;
|
||||
public @Nullable String uuid, usid;
|
||||
public boolean isAdmin, isTransferring, isShooting, isBoosting, isMobile, isTyping;
|
||||
public float boostHeat, shootHeat, destructTime;
|
||||
public boolean achievedFlight;
|
||||
@@ -59,13 +55,13 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
||||
public SpawnerTrait spawner, lastSpawner;
|
||||
public int respawns;
|
||||
|
||||
public NetConnection con;
|
||||
public @Nullable NetConnection con;
|
||||
public boolean isLocal = false;
|
||||
public Interval timer = new Interval(6);
|
||||
public TargetTrait target;
|
||||
public TargetTrait moveTarget;
|
||||
|
||||
public String lastText;
|
||||
public @Nullable String lastText;
|
||||
public float textFadeTime;
|
||||
|
||||
private float walktime, itemtime;
|
||||
@@ -229,7 +225,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
||||
@Override
|
||||
public void damage(float amount){
|
||||
hitTime = hitDuration;
|
||||
if(!Net.client()){
|
||||
if(!net.client()){
|
||||
health -= calculateDamage(amount);
|
||||
}
|
||||
|
||||
@@ -530,7 +526,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
||||
spawner = null;
|
||||
}
|
||||
|
||||
if(isLocal || Net.server()){
|
||||
if(isLocal || net.server()){
|
||||
avoidOthers();
|
||||
}
|
||||
|
||||
@@ -561,7 +557,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
||||
status.update(this); //status effect updating also happens with non locals for effect purposes
|
||||
updateVelocityStatus(); //velocity too, for visual purposes
|
||||
|
||||
if(Net.server()){
|
||||
if(net.server()){
|
||||
updateShooting(); //server simulates player shooting
|
||||
}
|
||||
return;
|
||||
@@ -847,7 +843,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
||||
}else if(spawner != null && spawner.isValid()){
|
||||
spawner.updateSpawning(this);
|
||||
}else if(!netServer.isWaitingForPlayers()){
|
||||
if(!Net.client()){
|
||||
if(!net.client()){
|
||||
if(lastSpawner != null && lastSpawner.isValid()){
|
||||
this.spawner = lastSpawner;
|
||||
}else if(getClosestCore() != null){
|
||||
|
||||
@@ -78,7 +78,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
|
||||
@Override
|
||||
public void damage(float amount){
|
||||
if(!Net.client()){
|
||||
if(!net.client()){
|
||||
super.damage(calculateDamage(amount));
|
||||
}
|
||||
hitTime = hitDuration;
|
||||
@@ -308,7 +308,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
|
||||
drownTime = Mathf.clamp(drownTime);
|
||||
|
||||
if(drownTime >= 0.999f && !Net.client()){
|
||||
if(drownTime >= 0.999f && !net.client()){
|
||||
damage(health + 1);
|
||||
}
|
||||
|
||||
@@ -347,7 +347,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
}
|
||||
|
||||
public void applyEffect(StatusEffect effect, float duration){
|
||||
if(dead || Net.client()) return; //effects are synced and thus not applied through clients
|
||||
if(dead || net.client()) return; //effects are synced and thus not applied through clients
|
||||
status.handleApply(this, effect, duration);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user