mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-03-25 14:59:07 +00:00
Standardize constructors to have position as the first param and add positions to terminals (#294)
* Standardize constructors to have position as the first param and add positions to terminals * Actually assign the position to the terminal object
This commit is contained in:
parent
a5a85e6cc3
commit
2662be8778
24 changed files with 8287 additions and 8283 deletions
|
|
@ -189,7 +189,7 @@ object VehicleSpawnPad {
|
|||
* @param context a context to allow the object to properly set up `ActorSystem` functionality
|
||||
* @return the `VehicleSpawnPad` object
|
||||
*/
|
||||
def Constructor(pdef: VehicleSpawnPadDefinition, pos : Vector3, orient : Vector3)(id : Int, context : ActorContext) : VehicleSpawnPad = {
|
||||
def Constructor(pos : Vector3, pdef: VehicleSpawnPadDefinition, orient : Vector3)(id : Int, context : ActorContext) : VehicleSpawnPad = {
|
||||
import akka.actor.Props
|
||||
import net.psforever.objects.GlobalDefinitions
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ object ProximityTerminal {
|
|||
* @param context a context to allow the object to properly set up `ActorSystem` functionality
|
||||
* @return the `Terminal` object
|
||||
*/
|
||||
def Constructor(tdef : ProximityTerminalDefinition, pos : Vector3)(id : Int, context : ActorContext) : Terminal = {
|
||||
def Constructor(pos : Vector3, tdef : ProximityTerminalDefinition)(id : Int, context : ActorContext) : Terminal = {
|
||||
import akka.actor.Props
|
||||
val obj = ProximityTerminal(tdef)
|
||||
obj.Position = pos
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import net.psforever.objects.definition.VehicleDefinition
|
|||
import net.psforever.objects.serverobject.hackable.Hackable
|
||||
import net.psforever.objects.serverobject.structures.Amenity
|
||||
import net.psforever.packet.game.{ItemTransactionMessage, TriggeredSound}
|
||||
import net.psforever.types.Vector3
|
||||
|
||||
/**
|
||||
* A server object that can be accessed for services and other amenities.
|
||||
|
|
@ -180,15 +181,17 @@ object Terminal {
|
|||
import akka.actor.ActorContext
|
||||
/**
|
||||
* Instantiate an configure a `Terminal` object
|
||||
* @param pos The location of the object
|
||||
* @param tdef the `ObjectDefinition` that constructs this object and maintains some of its immutable fields
|
||||
* @param id the unique id that will be assigned to this entity
|
||||
* @param context a context to allow the object to properly set up `ActorSystem` functionality
|
||||
* @return the `Terminal` object
|
||||
*/
|
||||
def Constructor(tdef : TerminalDefinition)(id : Int, context : ActorContext) : Terminal = {
|
||||
def Constructor(pos: Vector3, tdef : TerminalDefinition)(id : Int, context : ActorContext) : Terminal = {
|
||||
import akka.actor.Props
|
||||
|
||||
val obj = Terminal(tdef)
|
||||
obj.Position = pos
|
||||
obj.Actor = context.actorOf(Props(classOf[TerminalControl], obj), s"${tdef.Name}_$id")
|
||||
obj
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ object SpawnTube {
|
|||
* @return the `SpawnTube` object
|
||||
*/
|
||||
def Constructor(pos : Vector3, orient : Vector3)(id : Int, context : ActorContext) : SpawnTube = {
|
||||
Constructor(GlobalDefinitions.respawn_tube, pos, orient)(id, context)
|
||||
Constructor(pos, GlobalDefinitions.respawn_tube, orient)(id, context)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -47,7 +47,7 @@ object SpawnTube {
|
|||
* @param context a context to allow the object to properly set up `ActorSystem` functionality
|
||||
* @return the `SpawnTube` object
|
||||
*/
|
||||
def Constructor(tdef : SpawnTubeDefinition, pos : Vector3, orient : Vector3)(id : Int, context : ActorContext) : SpawnTube = {
|
||||
def Constructor(pos : Vector3, tdef : SpawnTubeDefinition, orient : Vector3)(id : Int, context : ActorContext) : SpawnTube = {
|
||||
import akka.actor.Props
|
||||
|
||||
val obj = SpawnTube(tdef)
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ object FacilityTurret {
|
|||
obj
|
||||
}
|
||||
|
||||
def Constructor(tdef : TurretDefinition, pos: Vector3)(id : Int, context : ActorContext) : FacilityTurret = {
|
||||
def Constructor(pos: Vector3, tdef : TurretDefinition)(id : Int, context : ActorContext) : FacilityTurret = {
|
||||
import akka.actor.Props
|
||||
val obj = FacilityTurret(tdef)
|
||||
obj.Position = pos
|
||||
|
|
|
|||
|
|
@ -119,13 +119,14 @@ class TerminalObjectBuilderTest extends ActorTest {
|
|||
"Terminal object" should {
|
||||
"build" in {
|
||||
val hub = ServerObjectBuilderTest.NumberPoolHub
|
||||
val actor = system.actorOf(Props(classOf[ServerObjectBuilderTest.BuilderTestActor], ServerObjectBuilder(1, Terminal.Constructor(order_terminal)), hub), "term")
|
||||
val actor = system.actorOf(Props(classOf[ServerObjectBuilderTest.BuilderTestActor], ServerObjectBuilder(1, Terminal.Constructor(Vector3(1.1f, 2.2f, 3.3f), order_terminal)), hub), "term")
|
||||
actor ! "!"
|
||||
|
||||
val reply = receiveOne(Duration.create(1000, "ms"))
|
||||
assert(reply.isInstanceOf[Terminal])
|
||||
assert(reply.asInstanceOf[Terminal].HasGUID)
|
||||
assert(reply.asInstanceOf[Terminal].GUID == PlanetSideGUID(1))
|
||||
assert(reply.asInstanceOf[Terminal].Position == Vector3(1.1f, 2.2f, 3.3f))
|
||||
assert(reply == hub(1).get)
|
||||
}
|
||||
}
|
||||
|
|
@ -156,7 +157,7 @@ class VehicleSpawnPadObjectBuilderTest extends ActorTest {
|
|||
"build" in {
|
||||
val hub = ServerObjectBuilderTest.NumberPoolHub
|
||||
val actor = system.actorOf(Props(classOf[ServerObjectBuilderTest.BuilderTestActor], ServerObjectBuilder(1,
|
||||
VehicleSpawnPad.Constructor(GlobalDefinitions.mb_pad_creation, Vector3(1.1f, 2.2f, 3.3f), Vector3(4.4f, 5.5f, 6.6f))
|
||||
VehicleSpawnPad.Constructor(Vector3(1.1f, 2.2f, 3.3f), GlobalDefinitions.mb_pad_creation, Vector3(4.4f, 5.5f, 6.6f))
|
||||
), hub), "pad")
|
||||
actor ! "!"
|
||||
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ class ZoneActorTest extends ActorTest {
|
|||
val map6 = new ZoneMap("map6") {
|
||||
LocalBuilding(building_guid = 1, map_id = 1, FoundationBuilder(Building.Structure(StructureType.Building, Vector3(1,1,1))))
|
||||
LocalObject(1, SpawnTube.Constructor(Vector3.Zero, Vector3.Zero))
|
||||
LocalObject(2, Terminal.Constructor(GlobalDefinitions.dropship_vehicle_terminal))
|
||||
LocalObject(2, Terminal.Constructor(Vector3.Zero, GlobalDefinitions.dropship_vehicle_terminal))
|
||||
LocalObject(3, SpawnTube.Constructor(Vector3.Zero, Vector3.Zero))
|
||||
ObjectToBuilding(1, 1)
|
||||
ObjectToBuilding(2, 1)
|
||||
|
|
@ -185,9 +185,9 @@ class ZoneActorTest extends ActorTest {
|
|||
ObjectToBuilding(7, 2)
|
||||
|
||||
LocalBuilding(building_guid = 3, map_id = 3, FoundationBuilder(Building.Structure(StructureType.Building, Vector3(1,1,1))))
|
||||
LocalObject(4, Terminal.Constructor(GlobalDefinitions.dropship_vehicle_terminal))
|
||||
LocalObject(4, Terminal.Constructor(Vector3.Zero, GlobalDefinitions.dropship_vehicle_terminal))
|
||||
LocalObject(5, SpawnTube.Constructor(Vector3.Zero, Vector3.Zero))
|
||||
LocalObject(6, Terminal.Constructor(GlobalDefinitions.dropship_vehicle_terminal))
|
||||
LocalObject(6, Terminal.Constructor(Vector3.Zero, GlobalDefinitions.dropship_vehicle_terminal))
|
||||
ObjectToBuilding(4, 3)
|
||||
ObjectToBuilding(5, 3)
|
||||
ObjectToBuilding(6, 3)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue