Visual server respawning fix
This commit is contained in:
@@ -89,7 +89,15 @@ public class Control implements ApplicationListener{
|
|||||||
});
|
});
|
||||||
|
|
||||||
Events.on(WorldLoadEvent.class, event -> {
|
Events.on(WorldLoadEvent.class, event -> {
|
||||||
Core.app.post(() -> Core.app.post(() -> Core.camera.position.set(player)));
|
Core.app.post(() -> Core.app.post(() -> {
|
||||||
|
if(Net.active() && player.getClosestCore() != null){
|
||||||
|
//set to closest core since that's where the player will probably respawn; prevents camera jumps
|
||||||
|
Core.camera.position.set(player.getClosestCore());
|
||||||
|
}else{
|
||||||
|
//locally, set to player position since respawning occurs immediately
|
||||||
|
Core.camera.position.set(player);
|
||||||
|
}
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
Events.on(ResetEvent.class, event -> {
|
Events.on(ResetEvent.class, event -> {
|
||||||
|
|||||||
@@ -794,10 +794,12 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
|
|||||||
if(spawner != null && spawner.isValid()){
|
if(spawner != null && spawner.isValid()){
|
||||||
spawner.updateSpawning(this);
|
spawner.updateSpawning(this);
|
||||||
}else if(!netServer.isWaitingForPlayers()){
|
}else if(!netServer.isWaitingForPlayers()){
|
||||||
if(lastSpawner != null && lastSpawner.isValid()){
|
if(!Net.client()){
|
||||||
this.spawner = lastSpawner;
|
if(lastSpawner != null && lastSpawner.isValid()){
|
||||||
}else if(getClosestCore() != null){
|
this.spawner = lastSpawner;
|
||||||
this.spawner = (SpawnerTrait)getClosestCore();
|
}else if(getClosestCore() != null){
|
||||||
|
this.spawner = (SpawnerTrait)getClosestCore();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}else if(getClosestCore() != null){
|
}else if(getClosestCore() != null){
|
||||||
set(getClosestCore().getX(), getClosestCore().getY());
|
set(getClosestCore().getX(), getClosestCore().getY());
|
||||||
@@ -898,12 +900,13 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
|
|||||||
}else{
|
}else{
|
||||||
mining = world.tile(mine);
|
mining = world.tile(mine);
|
||||||
isBoosting = boosting;
|
isBoosting = boosting;
|
||||||
Tile tile = world.tile(spawner);
|
}
|
||||||
if(tile != null && tile.entity instanceof SpawnerTrait){
|
|
||||||
this.spawner = (SpawnerTrait)tile.entity;
|
Tile tile = world.tile(spawner);
|
||||||
}else{
|
if(tile != null && tile.entity instanceof SpawnerTrait){
|
||||||
this.spawner = null;
|
this.spawner = (SpawnerTrait)tile.entity;
|
||||||
}
|
}else{
|
||||||
|
this.spawner = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package io.anuke.mindustry.net;
|
package io.anuke.mindustry.net;
|
||||||
|
|
||||||
import io.anuke.arc.Core;
|
|
||||||
import io.anuke.arc.collection.ObjectMap;
|
import io.anuke.arc.collection.ObjectMap;
|
||||||
import io.anuke.arc.collection.ObjectMap.Entry;
|
import io.anuke.arc.collection.ObjectMap.Entry;
|
||||||
import io.anuke.arc.util.Time;
|
import io.anuke.arc.util.Time;
|
||||||
@@ -122,10 +121,6 @@ public class NetworkIO{
|
|||||||
for(int j = 0; j < cores; j++){
|
for(int j = 0; j < cores; j++){
|
||||||
state.teams.get(team).cores.add(world.tile(stream.readInt()));
|
state.teams.get(team).cores.add(world.tile(stream.readInt()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(team == player.getTeam() && cores > 0){
|
|
||||||
Core.camera.position.set(state.teams.get(team).cores.first().drawx(), state.teams.get(team).cores.first().drawy());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}catch(IOException e){
|
}catch(IOException e){
|
||||||
|
|||||||
Reference in New Issue
Block a user