PSF-BotServer/src/test/scala/objects/OrbitalShuttlePadTest.scala
Fate-JH 71ab35ecab
Hart (#723)
* initial OrbitalShuttleTimeMsg packet and tests; new objects to support HART shuttle transport system

* master was stale

* grouped scheduling for timing orbital shuttle activity

* door lock controls for HART shuttle lifecycle, and specifically for the doors that lead into the shuttle boarding hallway

* separation of the door from the door unlocking logic, which now has to be provided if performed by an outside source; a door that is locked either by bolt, HART routine, or other reason, can now be shut immediately; message when HART is not docked with a corresponding entry hallway door

* better degree of door logic control; all shuttle-related messages have been moved to LocalService; careful managing of 'original state' for the shuttle's cycle

* modification of seat mounting and cargo mounting support entities to expand functionality

* absolutely very little to do with the feature of this branch and a lot to do with yak-shaving; long story short, class inheritance is greatly modified and mountable seats can now accept multiple players if initialized properly

* a lot has changed: distribution of MountableBehavior, mount point information is more complex, vehicles convert differently, the routine of the shuttle timer is initialized differently; you can now successfully utilize the HART shuttle to drop into a zone

* swap of shutle from pad to pad control; tests and comments

* eject players from HART gantry hallway as if passengers dismounting from seat when not boarding through the use of environmental geometry; HART system uses duration from config settings to set scheduler

* rebase to curious master; repairs to vector rotation calculations; regression of mountable changes involving seats with occupancy greater than 1; orbital shuttle as a unique vehicle and amenity; corrected dismount offsets and offset calculations; weird angle of nc hart a building has been properly accommodated; hart events have prerequisite animation states

* rebase with master; looks like rebase with merged_master, which is also a commit

* lots of tests (though not nearly enough); checking the permission group of a shuttle seat no longer creates that seat

* fixing explosions

* fixed the persistence monitor service potentially using non-printable unicode in actor names

* can not use a droppod to gain access to one's own sanctuary

* removed hart facility update that causing open bay doors and beeping

* PR review changes

* fix for aggravation issues
2021-03-23 09:44:10 -04:00

100 lines
4 KiB
Scala

// Copyright (c) 2021 PSForever
package objects
import akka.actor.{ActorRef, Props}
import akka.routing.RandomPool
import akka.testkit.TestProbe
import base.FreedContextActorTest
import net.psforever.actors.zone.BuildingActor
import net.psforever.objects.guid.actor.UniqueNumberSystem
import net.psforever.objects.{GlobalDefinitions, Vehicle}
import net.psforever.objects.guid.{NumberPoolHub, TaskResolver}
import net.psforever.objects.guid.source.MaxNumberSource
import net.psforever.objects.serverobject.doors.Door
import net.psforever.objects.serverobject.shuttle.{OrbitalShuttle, OrbitalShuttlePad, OrbitalShuttlePadControl, ShuttleAmenity}
import net.psforever.objects.serverobject.structures.{Building, StructureType}
import net.psforever.objects.zones.{Zone, ZoneMap, ZoneVehicleActor}
import net.psforever.services.{InterstellarClusterService, Service, ServiceManager}
import net.psforever.services.galaxy.GalaxyService
import net.psforever.services.hart.HartService
import net.psforever.types.PlanetSideEmpire
import scala.collection.concurrent.TrieMap
import scala.collection.mutable.ListBuffer
import scala.concurrent.duration._
class OrbitalShuttlePadControltest extends FreedContextActorTest {
import akka.actor.typed.scaladsl.adapter._
system.spawn(InterstellarClusterService(Nil), InterstellarClusterService.InterstellarClusterServiceKey.id)
val services = ServiceManager.boot(system)
services ! ServiceManager.Register(Props[GalaxyService](), "galaxy")
services ! ServiceManager.Register(Props[HartService](), "hart")
expectNoMessage(1000 milliseconds)
var buildingMap = new TrieMap[Int, Building]()
val vehicles = ListBuffer[Vehicle]()
val guid = new NumberPoolHub(new MaxNumberSource(max = 15))
guid.AddPool("dynamic", (11 to 15).toList)
val catchall = new TestProbe(system).ref
val resolver = context.actorOf(RandomPool(1).props(Props[TaskResolver]()), s"test-taskResolver")
val uns = context.actorOf(
RandomPool(1).props(
Props(classOf[UniqueNumberSystem], guid, UniqueNumberSystem.AllocateNumberPoolActors(this.guid))
),
s"test-uns"
)
val zone = new Zone("test", new ZoneMap("test-map"), 0) {
val transport: ActorRef = context.actorOf(Props(classOf[ZoneVehicleActor], this, vehicles), s"zone-test-vehicles")
override def SetupNumberPools() = {}
GUID(guid)
override def GUID = { uns }
override def AvatarEvents = catchall
override def LocalEvents = catchall
override def VehicleEvents = catchall
override def Activity = catchall
override def Transport = { transport }
override def Vehicles = { vehicles.toList }
override def Buildings = { buildingMap.toMap }
override def tasks = { resolver }
}
val building = new Building(
name = "test-orbital-building-tr",
building_guid = 1,
map_id = 0,
zone,
StructureType.Building,
GlobalDefinitions.orbital_building_tr
)
building.Faction = PlanetSideEmpire.TR
buildingMap += 1 -> building
building.Actor = context.spawn(BuildingActor(zone, building), "test-orbital-building-tr-control").toClassic
building.Invalidate()
guid.register(building, number = 1)
(3 to 10).foreach { index =>
val door = Door(GlobalDefinitions.gr_door_mb_orb)
building.Amenities = door
door.Actor = catchall
guid.register(door, index)
}
val pad = new OrbitalShuttlePad(GlobalDefinitions.obbasemesh)
guid.register(pad, number = 2)
pad.Actor = system.actorOf(Props(classOf[OrbitalShuttlePadControl], pad), "test-shuttle-pad")
building.Amenities = pad
"OrbitalShuttlePad" should {
"startup and create the shuttle" in {
assert(building.Amenities.size == 9)
assert(vehicles.isEmpty)
pad.Actor ! Service.Startup()
expectNoMessage(max = 5 seconds)
assert(building.Amenities.size == 10)
assert(vehicles.size == 1)
assert(building.Amenities(9).isInstanceOf[ShuttleAmenity]) //the shuttle is an amenity of the building now
assert(vehicles.head.isInstanceOf[OrbitalShuttle]) //here is the shuttle
}
}
}
object OrbitalShuttlePadTest { /* intentionally blank */ }