mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-02-22 16:13:35 +00:00
introduced a 'more elegant' method of adding objects to the Zones via ServerObjectBuilder; pushed information about specifics of Zone into ZoneMap object; shuffled around initialization responsibility to make this agreeable
This commit is contained in:
parent
2076100b50
commit
186c4ccba9
9 changed files with 84 additions and 106 deletions
|
|
@ -6,6 +6,7 @@ import net.psforever.objects.definition.converter.{CommandDetonaterConverter, Lo
|
|||
import net.psforever.objects.equipment.CItem.DeployedItem
|
||||
import net.psforever.objects.equipment._
|
||||
import net.psforever.objects.inventory.InventoryTile
|
||||
import net.psforever.objects.terminals.OrderTerminalDefinition
|
||||
import net.psforever.packet.game.objectcreate.ObjectClass
|
||||
import net.psforever.types.PlanetSideEmpire
|
||||
|
||||
|
|
@ -1169,4 +1170,7 @@ object GlobalDefinitions {
|
|||
fury.Weapons += 1 -> fury_weapon_systema
|
||||
fury.TrunkSize = InventoryTile(11, 11)
|
||||
fury.TrunkOffset = 30
|
||||
|
||||
val
|
||||
orderTerminal = new OrderTerminalDefinition
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class IntergalacticCluster(zones : List[Zone]) extends Actor {
|
|||
case Some(continent) =>
|
||||
sender ! IntergalacticCluster.GiveWorld(zoneId, continent)
|
||||
case None =>
|
||||
sender ! IntergalacticCluster.GiveWorld(zoneId, Zone.Nowhere)
|
||||
log.error(s"Requested zone with id $zoneId could not be found")
|
||||
}
|
||||
|
||||
case IntergalacticCluster.RequestZoneInitialization(tplayer) =>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.continent
|
||||
|
||||
import akka.actor.ActorContext
|
||||
import net.psforever.objects.PlanetSideGameObject
|
||||
import net.psforever.objects.guid.NumberPoolHub
|
||||
|
||||
trait ServerObjectBuilder {
|
||||
def Build(implicit context : ActorContext, guid : NumberPoolHub) : PlanetSideGameObject
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.continent
|
||||
|
||||
import net.psforever.objects.terminals.{Terminal, TerminalDefinition}
|
||||
|
||||
class TerminalObjectBuilder(tdef : TerminalDefinition, id : Int) extends ServerObjectBuilder {
|
||||
import akka.actor.ActorContext
|
||||
import net.psforever.objects.guid.NumberPoolHub
|
||||
|
||||
def Build(implicit context : ActorContext, guid : NumberPoolHub) : Terminal = {
|
||||
val obj = Terminal(tdef)
|
||||
guid.register(obj, id)
|
||||
obj.Actor
|
||||
obj
|
||||
}
|
||||
}
|
||||
|
||||
object TerminalObjectBuilder {
|
||||
def apply(tdef : TerminalDefinition, id : Int) : TerminalObjectBuilder = {
|
||||
new TerminalObjectBuilder(tdef, id)
|
||||
}
|
||||
}
|
||||
|
|
@ -3,10 +3,9 @@ package net.psforever.objects.continent
|
|||
|
||||
import akka.actor.{ActorContext, ActorRef, Props}
|
||||
import net.psforever.objects.{PlanetSideGameObject, Player}
|
||||
import net.psforever.objects.entity.IdentifiableEntity
|
||||
import net.psforever.objects.equipment.Equipment
|
||||
import net.psforever.objects.guid.NumberPoolHub
|
||||
import net.psforever.objects.guid.actor.{NumberPoolAccessorActor, NumberPoolActor, Register}
|
||||
import net.psforever.objects.guid.actor.{NumberPoolAccessorActor, NumberPoolActor}
|
||||
import net.psforever.objects.guid.selector.RandomSelector
|
||||
import net.psforever.objects.guid.source.LimitedNumberSource
|
||||
import net.psforever.packet.GamePacket
|
||||
|
|
@ -15,23 +14,24 @@ import net.psforever.types.Vector3
|
|||
|
||||
import scala.collection.mutable.ListBuffer
|
||||
|
||||
class Zone(id : String, zoneNumber : Int, map : String) {
|
||||
class Zone(id : String, map : ZoneMap, zoneNumber : Int) {
|
||||
private var actor = ActorRef.noSender
|
||||
private var accessor : ActorRef = ActorRef.noSender
|
||||
private var startupUtilities : List[(PlanetSideGameObject, Int)] = List()
|
||||
//private var startupUtilities : List[ServerObjectBuilder] = List()
|
||||
private var guid : NumberPoolHub = new NumberPoolHub(new LimitedNumberSource(65536))
|
||||
|
||||
def Actor : ActorRef = actor
|
||||
|
||||
def Init(implicit context : ActorContext) : Unit = {
|
||||
//TODO wrong initialization
|
||||
implicit val guid = this.guid
|
||||
val pool = guid.AddPool("pool", (200 to 1000).toList)
|
||||
pool.Selector = new RandomSelector
|
||||
val poolActor = context.actorOf(Props(classOf[NumberPoolActor], pool), name = s"$ZoneId-poolActor")
|
||||
accessor = context.actorOf(Props(classOf[NumberPoolAccessorActor], guid, pool, poolActor), s"$ZoneId-accessor")
|
||||
|
||||
StartupUtilities.foreach({case ((obj, uid)) =>
|
||||
guid.register(obj, uid)
|
||||
map.LocalObjects.foreach({builderObject =>
|
||||
builderObject.Build
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ class Zone(id : String, zoneNumber : Int, map : String) {
|
|||
|
||||
def ZoneNumber : Int = zoneNumber
|
||||
|
||||
def Map : String = map
|
||||
def Map : ZoneMap = map
|
||||
|
||||
def GUID : ActorRef = accessor
|
||||
|
||||
|
|
@ -70,15 +70,15 @@ class Zone(id : String, zoneNumber : Int, map : String) {
|
|||
|
||||
def EquipmentOnGround : ListBuffer[Equipment] = equipmentOnGround
|
||||
|
||||
def AddUtility(obj : PlanetSideGameObject, id : Int) : Unit = {
|
||||
startupUtilities = startupUtilities :+ (obj, id)
|
||||
}
|
||||
|
||||
def StartupUtilities : List[(IdentifiableEntity, Int)] = {
|
||||
val utilities = startupUtilities
|
||||
startupUtilities = Nil
|
||||
utilities
|
||||
}
|
||||
// def AddUtility(obj : ServerObjectBuilder) : Unit = {
|
||||
// startupUtilities = startupUtilities :+ obj
|
||||
// }
|
||||
//
|
||||
// def StartupUtilities : List[ServerObjectBuilder] = {
|
||||
// val utilities = startupUtilities
|
||||
// startupUtilities = Nil
|
||||
// utilities
|
||||
// }
|
||||
|
||||
def ClientInitialization() : List[GamePacket] = {
|
||||
List.empty[GamePacket]
|
||||
|
|
@ -90,8 +90,6 @@ class Zone(id : String, zoneNumber : Int, map : String) {
|
|||
}
|
||||
|
||||
object Zone {
|
||||
final def Nowhere : Zone = { Zone("nowhere", 0, "nowhere") } //TODO needs overrides
|
||||
|
||||
final case class DropItemOnGround(item : Equipment, pos : Vector3, orient : Vector3)
|
||||
|
||||
final case class GetItemOnGround(player : Player, item_guid : PlanetSideGUID)
|
||||
|
|
@ -100,7 +98,7 @@ object Zone {
|
|||
|
||||
final case class ClientInitialization(list : List[GamePacket])
|
||||
|
||||
def apply(zoneId : String, zoneNumber : Int, map : String) : Zone = {
|
||||
new Zone(zoneId, zoneNumber, map)
|
||||
def apply(id : String, map : ZoneMap, number : Int) : Zone = {
|
||||
new Zone(id, map, number)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package net.psforever.objects.continent
|
|||
|
||||
import akka.actor.Actor
|
||||
import net.psforever.objects.equipment.Equipment
|
||||
import net.psforever.objects.guid.actor.Register
|
||||
import net.psforever.packet.game.PlanetSideGUID
|
||||
|
||||
import scala.annotation.tailrec
|
||||
|
|
@ -13,7 +12,6 @@ class ZoneActor(zone : Zone) extends Actor {
|
|||
|
||||
override def preStart() : Unit = {
|
||||
super.preStart()
|
||||
log.info(s"Calling ${zone.ZoneId} init ...")
|
||||
zone.Init
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.continent
|
||||
|
||||
class ZoneMap(private val name : String) {
|
||||
private var localObjects : List[ServerObjectBuilder] = List()
|
||||
|
||||
def Name : String = name
|
||||
|
||||
def LocalObject(obj : ServerObjectBuilder) : Unit = {
|
||||
localObjects = localObjects :+ obj
|
||||
}
|
||||
|
||||
def LocalObjects : List[ServerObjectBuilder] = {
|
||||
val utilities = localObjects
|
||||
localObjects = Nil
|
||||
utilities
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue