Ship flight now properly accounts for desired target location in new system when switching systems
This commit is contained in:
parent
2a23c579bc
commit
c0c63b9240
@ -309,40 +309,44 @@ class ServerConnection(val server: StarboundServer, type: ConnectionType) : Conn
|
|||||||
|
|
||||||
var currentFlightJob: Job? = null
|
var currentFlightJob: Job? = null
|
||||||
|
|
||||||
|
suspend fun flyShipInSystem(location: SystemWorldLocation) {
|
||||||
|
currentFlightJob?.cancel()
|
||||||
|
val flight = world.flyShip(this, location)
|
||||||
|
|
||||||
|
shipWorld.eventLoop.execute {
|
||||||
|
shipWorld.sky.startFlying(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
currentFlightJob = scope.launch {
|
||||||
|
systemWorldLocation = location
|
||||||
|
val coords = flight.await()
|
||||||
|
val action = coords.orbitalAction(world)
|
||||||
|
currentOrbitalWarpAction = action
|
||||||
|
|
||||||
|
for (client in shipWorld.clients) {
|
||||||
|
client.client.orbitalWarpAction = action
|
||||||
|
}
|
||||||
|
|
||||||
|
val sky = coords.skyParameters(world)
|
||||||
|
|
||||||
|
shipWorld.eventLoop.execute {
|
||||||
|
shipWorld.sky.stopFlyingAt(sky)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
currentOrbitalWarpAction = KOptional()
|
||||||
|
|
||||||
|
for (client in shipWorld.clients) {
|
||||||
|
client.client.orbitalWarpAction = KOptional()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
val (system, location) = flyShipQueue.receive()
|
val (system, location) = flyShipQueue.receive()
|
||||||
|
|
||||||
if (system == world.location) {
|
if (system == world.location) {
|
||||||
// fly ship in current system
|
// fly ship in current system
|
||||||
currentFlightJob?.cancel()
|
flyShipInSystem(location)
|
||||||
val flight = world.flyShip(this, location)
|
|
||||||
|
|
||||||
shipWorld.eventLoop.execute {
|
|
||||||
shipWorld.sky.startFlying(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
currentFlightJob = scope.launch {
|
|
||||||
systemWorldLocation = location
|
|
||||||
val coords = flight.await()
|
|
||||||
val action = coords.orbitalAction(world)
|
|
||||||
currentOrbitalWarpAction = action
|
|
||||||
|
|
||||||
for (client in shipWorld.clients) {
|
|
||||||
client.client.orbitalWarpAction = action
|
|
||||||
}
|
|
||||||
|
|
||||||
val sky = coords.skyParameters(world)
|
|
||||||
|
|
||||||
shipWorld.eventLoop.execute {
|
|
||||||
shipWorld.sky.stopFlyingAt(sky)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
currentOrbitalWarpAction = KOptional()
|
|
||||||
|
|
||||||
for (client in shipWorld.clients) {
|
|
||||||
client.client.orbitalWarpAction = KOptional()
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// we need to travel to other system
|
// we need to travel to other system
|
||||||
val exists = server.universe.parameters(UniversePos(system)) != null
|
val exists = server.universe.parameters(UniversePos(system)) != null
|
||||||
@ -378,6 +382,11 @@ class ServerConnection(val server: StarboundServer, type: ConnectionType) : Conn
|
|||||||
|
|
||||||
// this seems to be way too big isn't it?
|
// this seems to be way too big isn't it?
|
||||||
delay((Globals.universeServer.queuedFlightWaitTime * 1000.0).toLong())
|
delay((Globals.universeServer.queuedFlightWaitTime * 1000.0).toLong())
|
||||||
|
|
||||||
|
if (location != SystemWorldLocation.Transit) {
|
||||||
|
// player clicked on specific planet in remote system view
|
||||||
|
flyShipInSystem(location)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,6 +182,7 @@ class ServerSystemWorld : SystemWorld {
|
|||||||
var diff = Globals.systemWorld.objectSpawnCycle.coerceAtMost(clock.time - lastSpawn)
|
var diff = Globals.systemWorld.objectSpawnCycle.coerceAtMost(clock.time - lastSpawn)
|
||||||
lastSpawn = clock.time - diff
|
lastSpawn = clock.time - diff
|
||||||
|
|
||||||
|
// persistent spawning (e.g. we simulate time passing as if we were always loaded)
|
||||||
while (diff > objectSpawnTime) {
|
while (diff > objectSpawnTime) {
|
||||||
lastSpawn += objectSpawnTime
|
lastSpawn += objectSpawnTime
|
||||||
objectSpawnTime = random.nextRange(Globals.systemWorld.objectSpawnInterval)
|
objectSpawnTime = random.nextRange(Globals.systemWorld.objectSpawnInterval)
|
||||||
|
Loading…
Reference in New Issue
Block a user