Fix for off-screen players and laggy interpolation
This commit is contained in:
@@ -45,7 +45,7 @@ import static io.anuke.mindustry.Vars.*;
|
|||||||
public class NetClient extends Module{
|
public class NetClient extends Module{
|
||||||
private final static float dataTimeout = 60 * 18;
|
private final static float dataTimeout = 60 * 18;
|
||||||
private final static float playerSyncTime = 2;
|
private final static float playerSyncTime = 2;
|
||||||
private final static float viewScale = 1.75f;
|
private final static float viewScale = 2f;
|
||||||
|
|
||||||
private Timer timer = new Timer(5);
|
private Timer timer = new Timer(5);
|
||||||
/**Whether the client is currently connecting.*/
|
/**Whether the client is currently connecting.*/
|
||||||
|
|||||||
@@ -494,7 +494,7 @@ public class NetServer extends Module{
|
|||||||
//check for syncable groups
|
//check for syncable groups
|
||||||
for(EntityGroup<?> group : Entities.getAllGroups()){
|
for(EntityGroup<?> group : Entities.getAllGroups()){
|
||||||
if(group.isEmpty() || !(group.all().get(0) instanceof SyncTrait)) continue;
|
if(group.isEmpty() || !(group.all().get(0) instanceof SyncTrait)) continue;
|
||||||
//clipping is done by represntatives
|
//clipping is done by representatives
|
||||||
SyncTrait represent = (SyncTrait) group.all().get(0);
|
SyncTrait represent = (SyncTrait) group.all().get(0);
|
||||||
|
|
||||||
//make sure mapping is enabled for this group
|
//make sure mapping is enabled for this group
|
||||||
|
|||||||
@@ -809,6 +809,12 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
|
|
||||||
//region read and write methods
|
//region read and write methods
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isClipped(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeSave(DataOutput stream) throws IOException{
|
public void writeSave(DataOutput stream) throws IOException{
|
||||||
stream.writeBoolean(isLocal);
|
stream.writeBoolean(isLocal);
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package io.anuke.mindustry.entities.traits;
|
package io.anuke.mindustry.entities.traits;
|
||||||
|
|
||||||
import io.anuke.mindustry.net.Interpolator;
|
import io.anuke.mindustry.net.Interpolator;
|
||||||
|
import io.anuke.ucore.core.Core;
|
||||||
import io.anuke.ucore.entities.trait.Entity;
|
import io.anuke.ucore.entities.trait.Entity;
|
||||||
|
import io.anuke.ucore.util.Tmp;
|
||||||
|
|
||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
@@ -24,8 +26,18 @@ public interface SyncTrait extends Entity, TypeTrait{
|
|||||||
|
|
||||||
/**Interpolate entity position only. Override if you need to interpolate rotations or other values.*/
|
/**Interpolate entity position only. Override if you need to interpolate rotations or other values.*/
|
||||||
default void interpolate(){
|
default void interpolate(){
|
||||||
if(getInterpolator() == null)
|
if(getInterpolator() == null){
|
||||||
throw new RuntimeException("This entity must have an interpolator to interpolate()!");
|
throw new RuntimeException("This entity must have an interpolator to interpolate()!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isClipped()){
|
||||||
|
//move off screen when no longer in bounds
|
||||||
|
if(!Tmp.r1.setSize(Core.camera.viewportWidth * Core.camera.zoom, Core.camera.viewportHeight * Core.camera.zoom)
|
||||||
|
.setCenter(Core.camera.position.x, Core.camera.position.y).contains(getX(), getY())){
|
||||||
|
set(-99999f, -99999f);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getInterpolator().update();
|
getInterpolator().update();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user