mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-04-21 20:35:22 +00:00
Deployable Behaviors (#840)
* unifying the split code pathways that separated telepads from other deloyables; in other words, no more SimpleDeployables and ComplexDeployables, just Deployables * moved some aspects of the build logic into a deployable control mixin; aspects governing the deplpoyable toolbox have been transferred into the player control agency * moving aspects of teleportation system establishment and decomposition into specialized Telepad control agencies * retiring deployable disposal code path that required a dedicated remover; each deployable now handles its own removal, and some do special things when being removed; process still has some rough edges and tests are probably thoroughly broken * additional modifications to support boomers and telepads; consolidation of code for deployable acknowledgement by owner and during failure conditions; tests for behavior * retooled a significant portion of the build sequence and deconstruct sequence to: eliminate duplicate messages, give the player more input to and control over the process, remove undue responsibility thrust on SessionActor * messaging issue where player did not re-raise hand after exchanging a used construction tool for a new construction tool * modification to deconstruct path to make certain deplayble is unregistered last; ridding requirement of AlertDestroyDeployable; fixing test * create paths for unowned deployable building and (standard) owned deployable building; corrected activation and connection between telepad deployable and internal roouter telepad; wrote tests for connection between telepad deployable and internal telepad * modifiying the conditions of a deployable construction item being moved into a visible player slot such that the construction item's initial output is valid given the player's current certifications * by forcing the fire mode to revert briefly before the ammo type updates, the construction item can be made to remain consistent between fire mode shifts * construction tools now keep track of fire mode ammo types for a period of time, allowing one mode's last setting to be retained * greatly delayed rebase with master * minor changes; test correction (?) * router is go?
This commit is contained in:
parent
7b4f955cbf
commit
2f9c4a7cf2
56 changed files with 2825 additions and 2124 deletions
333
src/test/scala/objects/TelepadRouterTest.scala
Normal file
333
src/test/scala/objects/TelepadRouterTest.scala
Normal file
|
|
@ -0,0 +1,333 @@
|
|||
// Copyright (c) 2021 PSForever
|
||||
package objects
|
||||
|
||||
import akka.actor.{ActorRef, Props}
|
||||
import akka.testkit.TestProbe
|
||||
import base.ActorTest
|
||||
import net.psforever.objects._
|
||||
import net.psforever.objects.ce.{DeployableCategory, DeployedItem, TelepadLike}
|
||||
import net.psforever.objects.guid.NumberPoolHub
|
||||
import net.psforever.objects.guid.source.MaxNumberSource
|
||||
import net.psforever.objects.serverobject.deploy.Deployment
|
||||
import net.psforever.objects.vehicles.{Utility, UtilityType, VehicleControl}
|
||||
import net.psforever.objects.zones.{Zone, ZoneDeployableActor, ZoneMap}
|
||||
import net.psforever.packet.game.objectcreate.ObjectCreateMessageParent
|
||||
import net.psforever.packet.game._
|
||||
import net.psforever.services.avatar.{AvatarAction, AvatarServiceMessage}
|
||||
import net.psforever.services.local.{LocalAction, LocalServiceMessage}
|
||||
import net.psforever.types.{DriveState, PlanetSideGUID, Vector3}
|
||||
|
||||
import scala.collection.mutable.ListBuffer
|
||||
import scala.concurrent.duration._
|
||||
|
||||
class TelepadDeployableNoRouterTest extends ActorTest {
|
||||
val eventsProbe = new TestProbe(system)
|
||||
val telepad = Deployables.Make(DeployedItem.router_telepad_deployable)() //guid=1
|
||||
val deployableList = new ListBuffer()
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(max = 5))
|
||||
val zone = new Zone(id = "test", new ZoneMap(name = "test"), zoneNumber = 0) {
|
||||
private val deployables = system.actorOf(Props(classOf[ZoneDeployableActor], this, deployableList), name = "test-zone-deployables")
|
||||
|
||||
override def SetupNumberPools(): Unit = {}
|
||||
GUID(guid)
|
||||
override def AvatarEvents: ActorRef = eventsProbe.ref
|
||||
override def LocalEvents: ActorRef = eventsProbe.ref
|
||||
override def Deployables: ActorRef = deployables
|
||||
}
|
||||
guid.register(telepad, number = 1)
|
||||
|
||||
"TelepadDeployable" should {
|
||||
"fail to activate without a router" in {
|
||||
assert(deployableList.isEmpty, "no-router telepad deployable test - deployable list is not empty")
|
||||
zone.Deployables ! Zone.Deployable.Build(telepad)
|
||||
|
||||
val eventsMsgs = eventsProbe.receiveN(4, 10.seconds)
|
||||
eventsMsgs.head match {
|
||||
case AvatarServiceMessage("test", AvatarAction.DeployItem(PlanetSideGUID(0), obj)) =>
|
||||
assert(obj eq telepad, "no-router telepad deployable testt - not same telepad")
|
||||
case _ =>
|
||||
assert( false, "no-router telepad deployable test - wrong deploy message")
|
||||
}
|
||||
eventsMsgs(1) match {
|
||||
case LocalServiceMessage(
|
||||
"NEUTRAL",
|
||||
LocalAction.DeployableMapIcon(
|
||||
PlanetSideGUID(0),
|
||||
DeploymentAction.Build,
|
||||
DeployableInfo(PlanetSideGUID(1), DeployableIcon.RouterTelepad, Vector3.Zero, PlanetSideGUID(0))
|
||||
)
|
||||
) => ;
|
||||
case _ => assert(false, "no-router telepad deployable test - no icon or wrong icon")
|
||||
}
|
||||
eventsMsgs(2) match {
|
||||
case LocalServiceMessage("test", LocalAction.EliminateDeployable(`telepad`, PlanetSideGUID(1), Vector3.Zero, 2)) => ;
|
||||
case _ => assert(false, "no-router telepad deployable test - not eliminating deployable")
|
||||
}
|
||||
eventsMsgs(3) match {
|
||||
case LocalServiceMessage(
|
||||
"NEUTRAL",
|
||||
LocalAction.DeployableMapIcon(
|
||||
PlanetSideGUID(0),
|
||||
DeploymentAction.Dismiss,
|
||||
DeployableInfo(PlanetSideGUID(1), DeployableIcon.RouterTelepad, Vector3.Zero, PlanetSideGUID(0))
|
||||
)
|
||||
) => ;
|
||||
case _ => assert(false, "no-router telepad deployable test - no icon or wrong icon cleared")
|
||||
}
|
||||
assert(deployableList.isEmpty, "no-router telepad deployable test - deployable is being tracked")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TelepadDeployableNoActivationTest extends ActorTest {
|
||||
val eventsProbe = new TestProbe(system)
|
||||
val routerProbe = new TestProbe(system)
|
||||
val telepad = Deployables.Make(DeployedItem.router_telepad_deployable)() //guid=1
|
||||
val router = Vehicle(GlobalDefinitions.router) //guid=2
|
||||
val internal = router.Utility(UtilityType.internal_router_telepad_deployable).get //guid=3
|
||||
val deployableList = new ListBuffer()
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(max = 5))
|
||||
val zone = new Zone(id = "test", new ZoneMap(name = "test"), zoneNumber = 0) {
|
||||
private val deployables = system.actorOf(Props(classOf[ZoneDeployableActor], this, deployableList), name = "test-zone-deployables")
|
||||
|
||||
override def SetupNumberPools(): Unit = {}
|
||||
GUID(guid)
|
||||
override def AvatarEvents: ActorRef = eventsProbe.ref
|
||||
override def LocalEvents: ActorRef = eventsProbe.ref
|
||||
override def Deployables: ActorRef = deployables
|
||||
override def Vehicles: List[Vehicle] = List(router)
|
||||
}
|
||||
guid.register(telepad, number = 1)
|
||||
guid.register(router, number = 2)
|
||||
guid.register(internal, number = 3)
|
||||
router.Actor = eventsProbe.ref
|
||||
internal.Actor = routerProbe.ref
|
||||
|
||||
"TelepadDeployable" should {
|
||||
"fail to activate without a connected router" in {
|
||||
assert(deployableList.isEmpty, "no-activate telepad deployable test - deployable list is not empty")
|
||||
zone.Deployables ! Zone.Deployable.Build(telepad)
|
||||
|
||||
val eventsMsgs = eventsProbe.receiveN(4, 10.seconds)
|
||||
eventsMsgs.head match {
|
||||
case AvatarServiceMessage("test", AvatarAction.DeployItem(PlanetSideGUID(0), obj)) =>
|
||||
assert(obj eq telepad, "no-activate telepad deployable testt - not same telepad")
|
||||
case _ =>
|
||||
assert( false, "no-activate telepad deployable test - wrong deploy message")
|
||||
}
|
||||
eventsMsgs(1) match {
|
||||
case LocalServiceMessage(
|
||||
"NEUTRAL",
|
||||
LocalAction.DeployableMapIcon(
|
||||
PlanetSideGUID(0),
|
||||
DeploymentAction.Build,
|
||||
DeployableInfo(PlanetSideGUID(1), DeployableIcon.RouterTelepad, Vector3.Zero, PlanetSideGUID(0))
|
||||
)
|
||||
) => ;
|
||||
case _ =>
|
||||
assert( false, "no-activate telepad deployable test - no icon or wrong icon")
|
||||
}
|
||||
eventsMsgs(2) match {
|
||||
case LocalServiceMessage("test", LocalAction.EliminateDeployable(`telepad`, PlanetSideGUID(1), Vector3.Zero, 2)) => ;
|
||||
case _ => assert(false, "no-activate telepad deployable test - not eliminating deployable")
|
||||
}
|
||||
eventsMsgs(3) match {
|
||||
case LocalServiceMessage(
|
||||
"NEUTRAL",
|
||||
LocalAction.DeployableMapIcon(
|
||||
PlanetSideGUID(0),
|
||||
DeploymentAction.Dismiss,
|
||||
DeployableInfo(PlanetSideGUID(1), DeployableIcon.RouterTelepad, Vector3.Zero, PlanetSideGUID(0))
|
||||
)
|
||||
) => ;
|
||||
case _ => assert(false, "no-activate telepad deployable test - no icon or wrong icon")
|
||||
}
|
||||
routerProbe.expectNoMessage(100.millisecond)
|
||||
assert(deployableList.isEmpty, "no-activate telepad deployable test - deployable is being tracked")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TelepadDeployableAttemptTest extends ActorTest {
|
||||
val eventsProbe = new TestProbe(system)
|
||||
val routerProbe = new TestProbe(system)
|
||||
val telepad = new TelepadDeployable(TelepadRouterTest.router_telepad_deployable) //guid=1
|
||||
val router = Vehicle(GlobalDefinitions.router) //guid=2
|
||||
val internal = router.Utility(UtilityType.internal_router_telepad_deployable).get //guid=3
|
||||
val deployableList = new ListBuffer()
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(max = 5))
|
||||
val zone = new Zone(id = "test", new ZoneMap(name = "test"), zoneNumber = 0) {
|
||||
private val deployables = system.actorOf(Props(classOf[ZoneDeployableActor], this, deployableList), name = "test-zone-deployables")
|
||||
|
||||
override def SetupNumberPools(): Unit = {}
|
||||
GUID(guid)
|
||||
override def AvatarEvents: ActorRef = eventsProbe.ref
|
||||
override def LocalEvents: ActorRef = eventsProbe.ref
|
||||
override def Deployables: ActorRef = deployables
|
||||
override def Vehicles: List[Vehicle] = List(router)
|
||||
}
|
||||
guid.register(telepad, number = 1)
|
||||
guid.register(router, number = 2)
|
||||
guid.register(internal, number = 3)
|
||||
router.Actor = eventsProbe.ref
|
||||
internal.Actor = routerProbe.ref
|
||||
telepad.Router = PlanetSideGUID(2) //artificial
|
||||
|
||||
"TelepadDeployable" should {
|
||||
"attempt to link with a connected router" in {
|
||||
assert(deployableList.isEmpty, "link attempt telepad deployable test - deployable list is not empty")
|
||||
zone.Deployables ! Zone.Deployable.Build(telepad)
|
||||
|
||||
val eventsMsgs = eventsProbe.receiveN(2, 10.seconds)
|
||||
val routerMsgs = routerProbe.receiveN(1, 10.seconds)
|
||||
eventsMsgs.head match {
|
||||
case AvatarServiceMessage("test", AvatarAction.DeployItem(PlanetSideGUID(0), obj)) =>
|
||||
assert(obj eq telepad, "link attempt telepad deployable testt - not same telepad")
|
||||
case _ =>
|
||||
assert( false, "link attempt telepad deployable test - wrong deploy message")
|
||||
}
|
||||
eventsMsgs(1) match {
|
||||
case LocalServiceMessage(
|
||||
"NEUTRAL",
|
||||
LocalAction.DeployableMapIcon(
|
||||
PlanetSideGUID(0),
|
||||
DeploymentAction.Build,
|
||||
DeployableInfo(PlanetSideGUID(1), DeployableIcon.RouterTelepad, Vector3.Zero, PlanetSideGUID(0))
|
||||
)
|
||||
) => ;
|
||||
case _ => assert(false, "link attempt telepad deployable test - no icon or wrong icon")
|
||||
}
|
||||
routerMsgs.head match {
|
||||
case TelepadLike.RequestLink(tpad) if tpad eq telepad => ;
|
||||
case _ => assert(false, "link attempt telepad deployable test - did not try to link")
|
||||
}
|
||||
assert(deployableList.contains(telepad), "link attempt telepad deployable test - deployable list is not empty")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TelepadDeployableResponseFromRouterTest extends ActorTest {
|
||||
val eventsProbe = new TestProbe(system)
|
||||
val telepad = new TelepadDeployable(TelepadRouterTest.router_telepad_deployable) //guid=1
|
||||
val router = Vehicle(GlobalDefinitions.router) //guid=2
|
||||
val internal = router
|
||||
.Utility(UtilityType.internal_router_telepad_deployable)
|
||||
.get
|
||||
.asInstanceOf[Utility.InternalTelepad] //guid=3
|
||||
val deployableList = new ListBuffer()
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(max = 5))
|
||||
val zone = new Zone(id = "test", new ZoneMap(name = "test"), zoneNumber = 0) {
|
||||
private val deployables = system.actorOf(Props(classOf[ZoneDeployableActor], this, deployableList), name = "test-zone-deployables")
|
||||
|
||||
override def SetupNumberPools(): Unit = {}
|
||||
GUID(guid)
|
||||
override def AvatarEvents: ActorRef = eventsProbe.ref
|
||||
override def LocalEvents: ActorRef = eventsProbe.ref
|
||||
override def VehicleEvents: ActorRef = eventsProbe.ref
|
||||
override def Deployables: ActorRef = deployables
|
||||
override def Vehicles: List[Vehicle] = List(router)
|
||||
}
|
||||
guid.register(telepad, number = 1)
|
||||
guid.register(router, number = 2)
|
||||
guid.register(internal, number = 3)
|
||||
guid.register(router.Utility(UtilityType.teleportpad_terminal).get, number = 4) //necessary
|
||||
router.Zone = zone
|
||||
router.Actor = system.actorOf(Props(classOf[VehicleControl], router), "test-router")
|
||||
telepad.Router = PlanetSideGUID(2) //artificial
|
||||
|
||||
"TelepadDeployable" should {
|
||||
"link with a connected router" in {
|
||||
assert(!telepad.Active, "link to router test - telepad active earlier than intended (1)")
|
||||
assert(!internal.Active, "link to router test - router internals active earlier than intended")
|
||||
router.Actor.tell(Deployment.TryDeploy(DriveState.Deploying), new TestProbe(system).ref)
|
||||
eventsProbe.receiveN(10, 10.seconds) //flush all messages related to deployment
|
||||
assert(!telepad.Active, "link to router test - telepad active earlier than intended (2)")
|
||||
assert(internal.Active, "link to router test - router internals active not active when expected")
|
||||
|
||||
assert(deployableList.isEmpty, "link to router test - deployable list is not empty")
|
||||
zone.Deployables ! Zone.Deployable.Build(telepad)
|
||||
|
||||
val eventsMsgs = eventsProbe.receiveN(9, 10.seconds)
|
||||
eventsMsgs.head match {
|
||||
case AvatarServiceMessage("test", AvatarAction.DeployItem(PlanetSideGUID(0), obj)) =>
|
||||
assert(obj eq telepad, "link to router test - not same telepad")
|
||||
case _ =>
|
||||
assert( false, "link to router test - wrong deploy message")
|
||||
}
|
||||
eventsMsgs(1) match {
|
||||
case LocalServiceMessage(
|
||||
"NEUTRAL",
|
||||
LocalAction.DeployableMapIcon(
|
||||
PlanetSideGUID(0),
|
||||
DeploymentAction.Build,
|
||||
DeployableInfo(PlanetSideGUID(1), DeployableIcon.RouterTelepad, Vector3.Zero, PlanetSideGUID(0))
|
||||
)
|
||||
) => ;
|
||||
case _ => assert(false, "link to router test - no icon or wrong icon")
|
||||
}
|
||||
eventsMsgs(2) match {
|
||||
case LocalServiceMessage(
|
||||
"test",
|
||||
LocalAction.SendResponse(
|
||||
ObjectCreateMessage(_, 744, PlanetSideGUID(3), Some(ObjectCreateMessageParent(PlanetSideGUID(2), 2)), _)
|
||||
)
|
||||
) => ;
|
||||
case _ => assert(false, "link to router test - did not create the internal router telepad (1)")
|
||||
}
|
||||
eventsMsgs(3) match {
|
||||
case LocalServiceMessage(
|
||||
"test",
|
||||
LocalAction.SendResponse(GenericObjectActionMessage(PlanetSideGUID(3), 27))
|
||||
) => ;
|
||||
case _ => assert(false, "link to router test - did not create the internal router telepad (2)")
|
||||
}
|
||||
eventsMsgs(4) match {
|
||||
case LocalServiceMessage(
|
||||
"test",
|
||||
LocalAction.SendResponse(GenericObjectActionMessage(PlanetSideGUID(3), 30))
|
||||
) => ;
|
||||
case _ => assert(false, "link to router test - did not create the internal router telepad (3)")
|
||||
}
|
||||
eventsMsgs(5) match {
|
||||
case LocalServiceMessage(
|
||||
"test",
|
||||
LocalAction.SendResponse(GenericObjectActionMessage(PlanetSideGUID(3), 27))
|
||||
) => ;
|
||||
case _ => assert(false, "link to router test - did not link the internal telepad (1)")
|
||||
}
|
||||
eventsMsgs(6) match {
|
||||
case LocalServiceMessage(
|
||||
"test",
|
||||
LocalAction.SendResponse(GenericObjectActionMessage(PlanetSideGUID(3), 28))
|
||||
) => ;
|
||||
case _ => assert(false, "link to router test - did not link the internal telepad (2)")
|
||||
}
|
||||
eventsMsgs(7) match {
|
||||
case LocalServiceMessage(
|
||||
"test",
|
||||
LocalAction.SendResponse(GenericObjectActionMessage(PlanetSideGUID(1), 27))
|
||||
) => ;
|
||||
case _ => assert(false, "link to router test - did not link the telepad (1)")
|
||||
}
|
||||
eventsMsgs(8) match {
|
||||
case LocalServiceMessage(
|
||||
"test",
|
||||
LocalAction.SendResponse(GenericObjectActionMessage(PlanetSideGUID(1), 28))
|
||||
) => ;
|
||||
case _ => assert(false, "link to router test - did not link the telepad (2)")
|
||||
}
|
||||
assert(telepad.Active, "link to router test - telepad not active when expected")
|
||||
assert(internal.Active, "link to router test - router internals active not active when expected (2)")
|
||||
assert(deployableList.contains(telepad), "link to router test - deployable list is not empty")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object TelepadRouterTest {
|
||||
val router_telepad_deployable = new TelepadDeployableDefinition(DeployedItem.router_telepad_deployable.id) {
|
||||
Name = "test_telepad_dep"
|
||||
DeployTime = Duration.create(1, "ms")
|
||||
DeployCategory = DeployableCategory.Telepads
|
||||
linkTime = 1.second
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue