deployable vehicles should properly deploy again now that they don't have to fight with themselves for the ability to deploy

This commit is contained in:
Fate-JH 2024-05-24 23:51:44 -04:00
parent 46cc8bae14
commit 445176006f
4 changed files with 21 additions and 17 deletions

View file

@ -282,7 +282,6 @@ class VehicleLogic(val ops: VehicleOperations, implicit val context: ActorContex
log.warn(s"${player.Name} must be mounted as the driver to request a deployment change")
} else {
log.info(s"${player.Name} is requesting a deployment change for ${obj.Definition.Name} - $deploy_state")
obj.Actor ! Deployment.TryDeploymentChange(deploy_state)
continent.Transport ! Zone.Vehicle.TryDeploymentChange(obj, deploy_state)
}
obj

View file

@ -1,7 +1,8 @@
// Copyright (c) 2017 PSForever
package net.psforever.objects.serverobject.deploy
import akka.actor.Actor
import akka.actor.{Actor, Cancellable}
import net.psforever.objects.Default
import net.psforever.types.{DriveState, Vector3}
import net.psforever.services.Service
import net.psforever.services.vehicle.{VehicleAction, VehicleServiceMessage}
@ -22,8 +23,14 @@ import scala.concurrent.duration._
trait DeploymentBehavior {
_: Actor =>
private var deploymentTimer: Cancellable = Default.Cancellable
def DeploymentObject: Deployment.DeploymentObject
def deploymentPostStop(): Unit = {
deploymentTimer.cancel()
}
val deployBehavior: Receive = {
case Deployment.TryDeploymentChange(state) =>
sender() ! TryDeploymentStateChange(state)
@ -98,9 +105,10 @@ trait DeploymentBehavior {
obj.Velocity = Some(Vector3.Zero) //no velocity
zone.VehicleEvents ! VehicleServiceMessage(
zoneChannel,
VehicleAction.DeployRequest(GUID0, guid, state, 0, false, Vector3.Zero)
VehicleAction.DeployRequest(GUID0, guid, state, 0, unk2=false, Vector3.Zero)
)
context.system.scheduler.scheduleOnce(
deploymentTimer.cancel()
deploymentTimer = context.system.scheduler.scheduleOnce(
obj.DeployTime milliseconds,
obj.Actor,
Deployment.TryDeploy(DriveState.Deployed)
@ -110,7 +118,7 @@ trait DeploymentBehavior {
obj.Velocity = Some(Vector3.Zero) //no velocity
zone.VehicleEvents ! VehicleServiceMessage(
zoneChannel,
VehicleAction.DeployRequest(GUID0, guid, state, 0, false, Vector3.Zero)
VehicleAction.DeployRequest(GUID0, guid, state, 0, unk2=false, Vector3.Zero)
)
state
} else {
@ -130,10 +138,11 @@ trait DeploymentBehavior {
if (state == DriveState.Undeploying) {
zone.VehicleEvents ! VehicleServiceMessage(
zoneChannel,
VehicleAction.DeployRequest(GUID0, guid, state, 0, false, Vector3.Zero)
VehicleAction.DeployRequest(GUID0, guid, state, 0, unk2=false, Vector3.Zero)
)
import scala.concurrent.ExecutionContext.Implicits.global
context.system.scheduler.scheduleOnce(
deploymentTimer.cancel()
deploymentTimer = context.system.scheduler.scheduleOnce(
obj.UndeployTime milliseconds,
obj.Actor,
Deployment.TryUndeploy(DriveState.Mobile)
@ -142,7 +151,7 @@ trait DeploymentBehavior {
} else if (state == DriveState.Mobile) {
zone.VehicleEvents ! VehicleServiceMessage(
zoneChannel,
VehicleAction.DeployRequest(GUID0, guid, state, 0, false, Vector3.Zero)
VehicleAction.DeployRequest(GUID0, guid, state, 0, unk2=false, Vector3.Zero)
)
state
} else {

View file

@ -22,6 +22,11 @@ class DeployingVehicleControl(vehicle: Vehicle)
with DeploymentBehavior {
def DeploymentObject: Vehicle = vehicle
override def postStop(): Unit = {
super.postStop()
deploymentPostStop()
}
override def commonEnabledBehavior : Receive = super.commonEnabledBehavior.orElse(deployBehavior)
/**

View file

@ -75,15 +75,6 @@ class VehicleControl(vehicle: Vehicle)
def CargoObject: Vehicle = vehicle
def AffectedObject: Vehicle = vehicle
// SetInteraction(EnvironmentAttribute.Water, doInteractingWithWater)
// SetInteraction(EnvironmentAttribute.Lava, doInteractingWithLava)
// SetInteraction(EnvironmentAttribute.Death, doInteractingWithDeath)
// SetInteraction(EnvironmentAttribute.MovementFieldTrigger, doInteractingWithMovementTrigger)
// if (!GlobalDefinitions.isFlightVehicle(vehicle.Definition)) {
// //can recover from sinking disability
// SetInteractionStop(EnvironmentAttribute.Water, stopInteractingWithWater)
// }
/** cheap flag for whether the vehicle is decaying */
var decaying : Boolean = false
/** primary vehicle decay timer */