PSF-BotServer/src/test/scala/objects/MountableTest.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

87 lines
3.3 KiB
Scala

// Copyright (c) 2017 PSForever
package objects
import akka.actor.{Actor, ActorRef, Props}
import base.ActorTest
import net.psforever.objects.Player
import net.psforever.objects.avatar.Avatar
import net.psforever.objects.definition.ObjectDefinition
import net.psforever.objects.serverobject.mount._
import net.psforever.objects.serverobject.PlanetSideServerObject
import net.psforever.types.{CharacterGender, CharacterVoice, PlanetSideEmpire, PlanetSideGUID}
import scala.concurrent.duration.Duration
class MountableControl1Test extends ActorTest {
"MountableControl" should {
"construct" in {
val obj = new MountableTest.MountableTestObject
obj.Actor = system.actorOf(Props(classOf[MountableTest.MountableTestControl], obj), "mech")
assert(obj.Actor != ActorRef.noSender)
}
}
}
class MountableControl2Test extends ActorTest {
"MountableControl" should {
"let a player mount" in {
val player = Player(Avatar(0, "test", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute))
val obj = new MountableTest.MountableTestObject
obj.Actor = system.actorOf(Props(classOf[MountableTest.MountableTestControl], obj), "mountable")
val msg = Mountable.TryMount(player, 0)
obj.Actor ! msg
val reply = receiveOne(Duration.create(100, "ms"))
assert(reply.isInstanceOf[Mountable.MountMessages])
val reply2 = reply.asInstanceOf[Mountable.MountMessages]
assert(reply2.player == player)
assert(reply2.response.isInstanceOf[Mountable.CanMount])
val reply3 = reply2.response.asInstanceOf[Mountable.CanMount]
assert(reply3.obj == obj)
assert(reply3.seat_number == 0)
}
}
}
class MountableControl3Test extends ActorTest {
"MountableControl" should {
"block a player from mounting" in {
val player1 = Player(Avatar(0, "test1", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute))
val player2 = Player(Avatar(1, "test2", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute))
val obj = new MountableTest.MountableTestObject
obj.Actor = system.actorOf(Props(classOf[MountableTest.MountableTestControl], obj), "mountable")
obj.Actor ! Mountable.TryMount(player1, 0)
receiveOne(Duration.create(100, "ms")) //consume reply
obj.Actor ! Mountable.TryMount(player2, 0)
val reply = receiveOne(Duration.create(100, "ms"))
assert(reply.isInstanceOf[Mountable.MountMessages])
val reply2 = reply.asInstanceOf[Mountable.MountMessages]
assert(reply2.player == player2)
assert(reply2.response.isInstanceOf[Mountable.CanNotMount])
val reply3 = reply2.response.asInstanceOf[Mountable.CanNotMount]
assert(reply3.obj == obj)
assert(reply3.mount_point == 0)
}
}
}
object MountableTest {
class MountableTestObject extends PlanetSideServerObject with Mountable {
seats += 0 -> new Seat(new SeatDefinition())
GUID = PlanetSideGUID(1)
//eh whatever
def Faction = PlanetSideEmpire.TR
def Definition = new ObjectDefinition(1) with MountableDefinition {
MountPoints += 0 -> MountInfo(0)
}
}
class MountableTestControl(obj: PlanetSideServerObject with Mountable)
extends Actor
with MountableBehavior {
override def MountableObject = obj
def receive: Receive = mountBehavior.orElse(dismountBehavior)
}
}