spawn player in center of single player world
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
ddaab9a2db
commit
1ea758705f
@ -1230,6 +1230,7 @@ Refactoring native code
|
||||
Fix gravity tree not deactivating when body is disabled
|
||||
Refactoring world menu generators into dedicated class
|
||||
Fix single player loading
|
||||
Spawn player in center of single player world
|
||||
|
||||
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ import electrosphere.server.content.ServerContentManager;
|
||||
import electrosphere.server.datacell.GriddedDataCellManager;
|
||||
import electrosphere.server.datacell.Realm;
|
||||
import electrosphere.server.terrain.generation.DefaultChunkGenerator;
|
||||
import electrosphere.server.terrain.manager.ServerTerrainChunk;
|
||||
import electrosphere.util.FileUtils;
|
||||
|
||||
/**
|
||||
@ -86,6 +87,15 @@ public class SceneLoader {
|
||||
} break;
|
||||
case RealmDescriptor.REALM_DESCRIPTOR_PROCEDURAL: {
|
||||
realm = Globals.realmManager.createGriddedRealm(serverWorldData,serverContentManager);
|
||||
//generate spawns
|
||||
Vector3d spawnPoint = new Vector3d(serverWorldData.getWorldSizeDiscrete() * ServerTerrainChunk.CHUNK_PLACEMENT_OFFSET / 2);
|
||||
spawnPoint.y = serverWorldData.getServerTerrainManager().getElevation(
|
||||
serverWorldData.getWorldSizeDiscrete() / 2,
|
||||
serverWorldData.getWorldSizeDiscrete() / 2,
|
||||
ServerTerrainChunk.CHUNK_PLACEMENT_OFFSET / 2,
|
||||
ServerTerrainChunk.CHUNK_PLACEMENT_OFFSET / 2
|
||||
);
|
||||
realm.registerSpawnPoint(spawnPoint);
|
||||
} break;
|
||||
case RealmDescriptor.REALM_DESCRIPTOR_GENERATION_TESTING: {
|
||||
ServerWorldData newWorldData = ServerWorldData.createGenerationTestWorldData();
|
||||
|
||||
@ -123,7 +123,7 @@ public class CharacterProtocol implements ServerProtocolTemplate<CharacterMessag
|
||||
}
|
||||
Entity rVal = PlayerCharacterCreation.spawnPlayerCharacter(connectionHandler);
|
||||
Realm realm = Globals.playerManager.getPlayerRealm(connectionHandler.getPlayer());
|
||||
Vector3d spawnPoint = realm.getSpawnPoint();
|
||||
Vector3d spawnPoint = PlayerCharacterCreation.solveSpawnPoint(realm, connectionHandler);
|
||||
//set client initial discrete position
|
||||
connectionHandler.addMessagetoOutgoingQueue(
|
||||
PlayerMessage.constructSetInitialDiscretePositionMessage(
|
||||
@ -134,7 +134,7 @@ public class CharacterProtocol implements ServerProtocolTemplate<CharacterMessag
|
||||
);
|
||||
return rVal;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Swaps the type of the player character (to editor or vice-versa)
|
||||
* @param connectionHandler The connection handler to swap
|
||||
|
||||
@ -33,7 +33,7 @@ public class PlayerCharacterCreation {
|
||||
|
||||
//
|
||||
//spawn entity in world
|
||||
Vector3d spawnPoint = realm.getSpawnPoint();
|
||||
Vector3d spawnPoint = PlayerCharacterCreation.solveSpawnPoint(realm, connectionHandler);
|
||||
Entity newPlayerEntity = CreatureUtils.serverSpawnBasicCreature(realm,new Vector3d(spawnPoint.x,spawnPoint.y,spawnPoint.z),raceName,template);
|
||||
|
||||
//
|
||||
@ -84,4 +84,15 @@ public class PlayerCharacterCreation {
|
||||
ServerPlayerViewDirTree.attachServerPlayerViewDirTree(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Solves the spawn point for the player
|
||||
* @param realm The realm that the entity is being spawned in
|
||||
* @param connectionHandler The connection object
|
||||
* @return The spawn point for the player
|
||||
*/
|
||||
public static Vector3d solveSpawnPoint(Realm realm, ServerConnectionHandler connectionHandler){
|
||||
Vector3d spawnPoint = realm.getSpawnPoint();
|
||||
return spawnPoint;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user