@@ -15,7 +15,6 @@ import org.valkyrienskies.core.api.ships.ServerTickListener
15
15
import org.valkyrienskies.core.api.ships.ShipForcesInducer
16
16
import org.valkyrienskies.core.api.ships.getAttachment
17
17
import org.valkyrienskies.core.api.ships.saveAttachment
18
- import org.valkyrienskies.core.impl.game.ships.PhysShipImpl
19
18
import org.valkyrienskies.eureka.EurekaConfig
20
19
import org.valkyrienskies.mod.api.SeatedControllingPlayer
21
20
import org.valkyrienskies.mod.common.util.toJOMLD
@@ -92,13 +91,11 @@ class EurekaShipControl : ShipForcesInducer, ServerTickListener {
92
91
// Disable fluid drag when helms are present, because it makes ships hard to drive
93
92
physShip.doFluidDrag = EurekaConfig .SERVER .doFluidDrag
94
93
95
- physShip as PhysShipImpl
96
-
97
94
val ship = ship ? : return
98
- val mass = physShip.inertia.shipMass
99
- val moiTensor = physShip.inertia.momentOfInertiaTensor
100
- val omega: Vector3dc = physShip.poseVel. omega
101
- val vel: Vector3dc = physShip.poseVel.vel
95
+ val mass = physShip.mass
96
+ val moiTensor = physShip.momentOfInertia
97
+ val omega: Vector3dc = physShip.omega
98
+ val vel: Vector3dc = physShip.velocity
102
99
val balloonForceProvided = balloons * forcePerBalloon
103
100
104
101
val buoyantFactorPerFloater = min(
@@ -123,7 +120,7 @@ class EurekaShipControl : ShipForcesInducer, ServerTickListener {
123
120
124
121
// region Aligning
125
122
126
- val invRotation = physShip.poseVel.rot .invert(Quaterniond ())
123
+ val invRotation = physShip.transform.shipToWorldRotation .invert(Quaterniond ())
127
124
val invRotationAxisAngle = AxisAngle4d (invRotation)
128
125
// Floor makes a number 0 to 3, which corresponds to direction
129
126
val alignTarget = floor((invRotationAxisAngle.angle / (PI * 0.5 )) + 4.5 ).toInt() % 4
@@ -233,16 +230,16 @@ class EurekaShipControl : ShipForcesInducer, ServerTickListener {
233
230
return currentControlData
234
231
}
235
232
236
- private fun applyPlayerControl (control : ControlData , physShip : PhysShipImpl ) {
233
+ private fun applyPlayerControl (control : ControlData , physShip : PhysShip ) {
237
234
238
235
val ship = ship ? : return
239
236
val transform = physShip.transform
240
237
val aabb = ship.worldAABB
241
238
val center = transform.positionInWorld
242
239
243
240
// region Player controlled rotation
244
- val moiTensor = physShip.inertia.momentOfInertiaTensor
245
- val omega: Vector3dc = physShip.poseVel. omega
241
+ val moiTensor = physShip.momentOfInertia
242
+ val omega: Vector3dc = physShip.omega
246
243
247
244
val largestDistance = run {
248
245
var dist = center.distance(aabb.minX(), center.y(), aabb.minZ())
@@ -277,42 +274,42 @@ class EurekaShipControl : ShipForcesInducer, ServerTickListener {
277
274
physShip.applyInvariantForce(getPlayerForwardVel(control, physShip))
278
275
}
279
276
280
- private fun getPlayerControlledBanking (control : ControlData , physShip : PhysShipImpl , moiTensor : Matrix3dc , strength : Double ): Vector3d {
277
+ private fun getPlayerControlledBanking (control : ControlData , physShip : PhysShip , moiTensor : Matrix3dc , strength : Double ): Vector3d {
281
278
val rotationVector = control.seatInDirection.normal.toJOMLD()
282
- physShip.poseVel.transformDirection (rotationVector)
279
+ physShip.transform.shipToWorldRotation.transform (rotationVector)
283
280
rotationVector.y = 0.0
284
281
rotationVector.mul(strength * 1.5 )
285
282
286
- physShip.poseVel.rot .transform(
283
+ physShip.transform.shipToWorldRotation .transform(
287
284
moiTensor.transform(
288
- physShip.poseVel.rot .transformInverse(rotationVector)
285
+ physShip.transform.shipToWorldRotation .transformInverse(rotationVector)
289
286
)
290
287
)
291
288
292
289
return rotationVector
293
290
}
294
291
295
292
// Player controlled forward and backward thrust
296
- private fun getPlayerForwardVel (control : ControlData , physShip : PhysShipImpl ): Vector3d {
293
+ private fun getPlayerForwardVel (control : ControlData , physShip : PhysShip ): Vector3d {
297
294
298
- val scaledMass = physShip.inertia.shipMass * EurekaConfig .SERVER .speedMassScale
299
- val vel: Vector3dc = physShip.poseVel.vel
295
+ val scaledMass = physShip.mass * EurekaConfig .SERVER .speedMassScale
296
+ val vel: Vector3dc = physShip.velocity
300
297
301
298
// region Player controlled forward and backward thrust
302
299
val forwardVector = control.seatInDirection.normal.toJOMLD()
303
- physShip.poseVel.rot .transform(forwardVector)
300
+ physShip.transform.shipToWorldRotation .transform(forwardVector)
304
301
forwardVector.normalize()
305
302
306
303
val s = 1 / smoothingATanMax(
307
304
EurekaConfig .SERVER .linearMaxMass,
308
- physShip.inertia.shipMass * EurekaConfig .SERVER .linearMassScaling + EurekaConfig .SERVER .linearBaseMass
305
+ physShip.mass * EurekaConfig .SERVER .linearMassScaling + EurekaConfig .SERVER .linearBaseMass
309
306
)
310
307
311
308
val maxSpeed = EurekaConfig .SERVER .linearMaxSpeed / 15
312
309
oldSpeed = max(min(oldSpeed * (1 - s) + control.forwardImpulse.toDouble() * s, maxSpeed), - maxSpeed)
313
310
forwardVector.mul(oldSpeed)
314
311
315
- val playerUpDirection = physShip.poseVel.transformDirection (Vector3d (0.0 , 1.0 , 0.0 ))
312
+ val playerUpDirection = physShip.transform.shipToWorldRotation.transform (Vector3d (0.0 , 1.0 , 0.0 ))
316
313
val velOrthogonalToPlayerUp = vel.sub(playerUpDirection.mul(playerUpDirection.dot(vel)), Vector3d ())
317
314
318
315
// This is the speed that the ship is always allowed to go out, without engines
@@ -321,8 +318,8 @@ class EurekaShipControl : ShipForcesInducer, ServerTickListener {
321
318
322
319
if (extraForceLinear != 0.0 ) {
323
320
// engine boost
324
- val boost = max((extraForceLinear - EurekaConfig .SERVER .enginePowerLinear * EurekaConfig .SERVER .engineBoostOffset) * EurekaConfig .SERVER .engineBoost, 0.0 );
325
- extraForceLinear + = boost + boost * boost * EurekaConfig .SERVER .engineBoostExponentialPower;
321
+ val boost = max((extraForceLinear - EurekaConfig .SERVER .enginePowerLinear * EurekaConfig .SERVER .engineBoostOffset) * EurekaConfig .SERVER .engineBoost, 0.0 )
322
+ extraForceLinear + = boost + boost * boost * EurekaConfig .SERVER .engineBoostExponentialPower
326
323
327
324
// This is the maximum speed we want to go in any scenario (when not sprinting)
328
325
val idealForwardVel = Vector3d (forwardVector).mul(EurekaConfig .SERVER .maxCasualSpeed)
0 commit comments