mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-01-19 18:44:45 +00:00
resolutions 4; unmerged local branch changes of inheritance to ZoneAware, AmenityOwner, etc.
This commit is contained in:
parent
a782e7bc46
commit
38a077744a
|
|
@ -52,7 +52,7 @@ class Player(private val core : Avatar) extends PlanetSideGameObject
|
|||
private var vehicleSeated : Option[PlanetSideGUID] = None
|
||||
private var vehicleOwned : Option[PlanetSideGUID] = None
|
||||
|
||||
private var continent : String = "home2" //the zone id
|
||||
Continent = "home2" //the zone id
|
||||
|
||||
var silenced : Boolean = false
|
||||
var firstLoad : Boolean = false
|
||||
|
|
@ -612,13 +612,6 @@ class Player(private val core : Avatar) extends PlanetSideGameObject
|
|||
VehicleOwned
|
||||
}
|
||||
|
||||
def Continent : String = continent
|
||||
|
||||
def Continent_=(zoneId : String) : String = {
|
||||
continent = zoneId
|
||||
Continent
|
||||
}
|
||||
|
||||
def DamageModel = exosuit.asInstanceOf[DamageResistanceModel]
|
||||
|
||||
def Definition : AvatarDefinition = core.Definition
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import net.psforever.objects.serverobject.deploy.Deployment
|
|||
import net.psforever.objects.serverobject.structures.AmenityOwner
|
||||
import net.psforever.objects.vehicles._
|
||||
import net.psforever.objects.vital.{DamageResistanceModel, StandardResistanceProfile, Vitality}
|
||||
import net.psforever.objects.zones.{Zone, ZoneAware}
|
||||
import net.psforever.packet.game.PlanetSideGUID
|
||||
import net.psforever.types.PlanetSideEmpire
|
||||
|
||||
|
|
@ -66,15 +65,13 @@ import scala.annotation.tailrec
|
|||
* stores and unloads pertinent information about the `Vehicle`'s configuration;
|
||||
* used in the initialization process (`loadVehicleDefinition`)
|
||||
*/
|
||||
class Vehicle(private val vehicleDef : VehicleDefinition) extends PlanetSideServerObject
|
||||
class Vehicle(private val vehicleDef : VehicleDefinition) extends AmenityOwner
|
||||
with FactionAffinity
|
||||
with ZoneAware
|
||||
with Mountable
|
||||
with MountedWeapons
|
||||
with Deployment
|
||||
with Vitality
|
||||
with OwnableByPlayer
|
||||
with AmenityOwner
|
||||
with StandardResistanceProfile
|
||||
with Container {
|
||||
private var faction : PlanetSideEmpire.Value = PlanetSideEmpire.TR
|
||||
|
|
@ -86,12 +83,6 @@ class Vehicle(private val vehicleDef : VehicleDefinition) extends PlanetSideServ
|
|||
private var cloaked : Boolean = false
|
||||
private var flying : Boolean = false
|
||||
private var capacitor : Int = 0
|
||||
/**
|
||||
* Normally, the vehicle is the resident of a `Zone` object and that is what it considers its "continent."
|
||||
* Since the `Vehicle` object can switch between `Zone` objects, however,
|
||||
* it may become useful to allow the vehicle to identify as belonging to its future zone earlier than reference assignment.
|
||||
*/
|
||||
private var continent : Option[String] = None //the zone id
|
||||
/**
|
||||
* Permissions control who gets to access different parts of the vehicle;
|
||||
* the groups are Driver (seat), Gunner (seats), Passenger (seats), and the Trunk
|
||||
|
|
@ -514,28 +505,6 @@ class Vehicle(private val vehicleDef : VehicleDefinition) extends PlanetSideServ
|
|||
*/
|
||||
def Definition : VehicleDefinition = vehicleDef
|
||||
|
||||
/**
|
||||
* When assigning a new `Zone` object for the `Vehicle` object, eliminate
|
||||
* @param zone a reference to the `Zone` object
|
||||
* @return a reference to the `Zone` object
|
||||
*/
|
||||
override def Zone_=(zone : Zone) : Zone = {
|
||||
continent = None
|
||||
super.Zone_=(zone)
|
||||
}
|
||||
|
||||
override def Continent : String = continent.getOrElse(Zone.Id)
|
||||
|
||||
/**
|
||||
* Give the `Vehicle` object a custom `Zone` identifier.
|
||||
* @param zoneId the custom identifier of the `Zone` object
|
||||
* @return the identifier of the `Zone` object
|
||||
*/
|
||||
override def Continent_=(zoneId : String) : String = {
|
||||
continent = Some(zoneId)
|
||||
Continent
|
||||
}
|
||||
|
||||
def canEqual(other: Any): Boolean = other.isInstanceOf[Vehicle]
|
||||
|
||||
override def equals(other : Any) : Boolean = other match {
|
||||
|
|
@ -645,7 +614,9 @@ object Vehicle {
|
|||
vehicle.utilities = vdef.Utilities.map({
|
||||
case(num, util) =>
|
||||
val obj = Utility(util, vehicle)
|
||||
obj().LocationOffset = vdef.UtilityOffset.get(num)
|
||||
val utilObj = obj()
|
||||
vehicle.Amenities = utilObj
|
||||
utilObj.LocationOffset = vdef.UtilityOffset.get(num)
|
||||
num -> obj
|
||||
}).toMap
|
||||
//trunk
|
||||
|
|
|
|||
|
|
@ -33,8 +33,4 @@ abstract class PlanetSideServerObject extends PlanetSideGameObject
|
|||
}
|
||||
actor
|
||||
}
|
||||
|
||||
def Continent : String = "nowhere"
|
||||
|
||||
def Continent_=(zone : String) = Continent
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +1,10 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.serverobject.structures
|
||||
|
||||
import net.psforever.objects.Vehicle
|
||||
import net.psforever.objects.serverobject.PlanetSideServerObject
|
||||
import net.psforever.objects.zones.{Zone => World }
|
||||
import net.psforever.objects.zones.Zone
|
||||
import net.psforever.types.{PlanetSideEmpire, Vector3}
|
||||
|
||||
/**
|
||||
* Amenities are elements of the game that belong to other elements of the game.
|
||||
* Their owners are also elements of the game, ones that understand that they belong to a specific `Zone` object.
|
||||
* @see `PlanetSideServerObject`
|
||||
* @see `Zone`
|
||||
* @see `ZoneAware`
|
||||
*/
|
||||
trait AmenityOwner extends PlanetSideServerObject {
|
||||
private var zoneRef : World = World.Nowhere
|
||||
|
||||
def Zone_=(zone : World) : World = {
|
||||
zoneRef = zone
|
||||
Zone
|
||||
}
|
||||
|
||||
def Zone : World = zoneRef
|
||||
}
|
||||
|
||||
/**
|
||||
* Amenities are elements of the game that belong to other elements of the game.<br>
|
||||
* <br>
|
||||
|
|
@ -31,7 +12,7 @@ trait AmenityOwner extends PlanetSideServerObject {
|
|||
* An `Amenity` is a server object that maintains a fixed association with another server object.
|
||||
* This association strips away at the internalization and redirects a reference to some properties somewhere else.
|
||||
* An `Amenity` object belongs to its `Owner` object;
|
||||
* the `Amenity` objects looks to its `Owner` object for some of its properties.
|
||||
* the `Amenity` objects look to its `Owner` object for some of its properties.
|
||||
* @see `FactionAffinity`
|
||||
*/
|
||||
abstract class Amenity extends PlanetSideServerObject {
|
||||
|
|
@ -73,9 +54,11 @@ abstract class Amenity extends PlanetSideServerObject {
|
|||
LocationOffset
|
||||
}
|
||||
|
||||
override def Continent = Owner match {
|
||||
case o : Building => o.Zone.Id
|
||||
case o : Vehicle => o.Continent
|
||||
case _ => super.Continent
|
||||
}
|
||||
override def Zone : Zone = Owner.Zone
|
||||
|
||||
override def Zone_=(zone : Zone) = Owner.Zone
|
||||
|
||||
override def Continent : String = Owner.Continent
|
||||
|
||||
override def Continent_=(str : String) : String = Owner.Continent
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright (c) 2019 PSForever
|
||||
package net.psforever.objects.serverobject.structures
|
||||
|
||||
import net.psforever.objects.serverobject.PlanetSideServerObject
|
||||
|
||||
/**
|
||||
* Amenities are elements of the game that belong to other elements of the game.
|
||||
* Their owners are also elements of the game, ones that understand that they belong to a specific `Zone` object.
|
||||
* @see `PlanetSideServerObject`
|
||||
*/
|
||||
abstract class AmenityOwner extends PlanetSideServerObject {
|
||||
private var amenities : List[Amenity] = List.empty
|
||||
|
||||
def Amenities : List[Amenity] = amenities
|
||||
|
||||
def Amenities_=(obj : Amenity) : List[Amenity] = {
|
||||
amenities = amenities :+ obj
|
||||
obj.Owner = this
|
||||
amenities
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,6 @@ import java.util.concurrent.TimeUnit
|
|||
import akka.actor.ActorContext
|
||||
import net.psforever.objects.{GlobalDefinitions, Player}
|
||||
import net.psforever.objects.definition.ObjectDefinition
|
||||
import net.psforever.objects.serverobject.PlanetSideServerObject
|
||||
import net.psforever.objects.serverobject.hackable.Hackable
|
||||
import net.psforever.objects.serverobject.resourcesilo.ResourceSilo
|
||||
import net.psforever.objects.serverobject.terminals.CaptureTerminal
|
||||
|
|
@ -20,14 +19,12 @@ class Building(private val name: String,
|
|||
private val map_id : Int,
|
||||
private val zone : Zone,
|
||||
private val buildingType : StructureType.Value,
|
||||
private val buildingDefinition : ObjectDefinition) extends PlanetSideServerObject
|
||||
with AmenityOwner {
|
||||
private val buildingDefinition : ObjectDefinition) extends AmenityOwner {
|
||||
/**
|
||||
* The map_id is the identifier number used in BuildingInfoUpdateMessage. This is the index that the building appears in the MPO file starting from index 1
|
||||
* The GUID is the identifier number used in SetEmpireMessage / Facility hacking / PlanetSideAttributeMessage.
|
||||
*/
|
||||
private var faction : PlanetSideEmpire.Value = PlanetSideEmpire.NEUTRAL
|
||||
private var amenities : List[Amenity] = List.empty
|
||||
private var playersInSOI : List[Player] = List.empty
|
||||
super.Zone_=(zone)
|
||||
|
||||
|
|
@ -46,14 +43,6 @@ class Building(private val name: String,
|
|||
Faction
|
||||
}
|
||||
|
||||
def Amenities : List[Amenity] = amenities
|
||||
|
||||
def Amenities_=(obj : Amenity) : List[Amenity] = {
|
||||
amenities = amenities :+ obj
|
||||
obj.Owner = this
|
||||
amenities
|
||||
}
|
||||
|
||||
def CaptureConsoleIsHacked : Boolean = {
|
||||
Amenities.find(x => x.Definition == GlobalDefinitions.capture_terminal).asInstanceOf[Option[CaptureTerminal]] match {
|
||||
case Some(obj: CaptureTerminal) =>
|
||||
|
|
@ -80,10 +69,9 @@ class Building(private val name: String,
|
|||
// Get all lattice neighbours matching the specified faction
|
||||
def Neighbours(faction: PlanetSideEmpire.Value): Option[Set[Building]] = {
|
||||
this.Neighbours match {
|
||||
case Some(x: Set[Building]) => {
|
||||
case Some(x: Set[Building]) =>
|
||||
val matching = x.filter(b => b.Faction == faction)
|
||||
if(matching.isEmpty) None else Some(matching)
|
||||
}
|
||||
case None => None
|
||||
}
|
||||
}
|
||||
|
|
@ -99,14 +87,14 @@ class Building(private val name: String,
|
|||
Boolean, Boolean
|
||||
) = {
|
||||
//if we have a silo, get the NTU level
|
||||
val ntuLevel : Int = amenities.find(_.Definition == GlobalDefinitions.resource_silo) match {
|
||||
val ntuLevel : Int = Amenities.find(_.Definition == GlobalDefinitions.resource_silo) match {
|
||||
case Some(obj: ResourceSilo) =>
|
||||
obj.CapacitorDisplay.toInt
|
||||
case _ => //we have no silo; we have unlimited power
|
||||
10
|
||||
}
|
||||
//if we have a capture terminal, get the hack status & time (in milliseconds) from control console if it exists
|
||||
val (hacking, hackingFaction, hackTime) : (Boolean, PlanetSideEmpire.Value, Long) = amenities.find(_.Definition == GlobalDefinitions.capture_terminal) match {
|
||||
val (hacking, hackingFaction, hackTime) : (Boolean, PlanetSideEmpire.Value, Long) = Amenities.find(_.Definition == GlobalDefinitions.capture_terminal) match {
|
||||
case Some(obj: CaptureTerminal with Hackable) =>
|
||||
obj.HackedBy match {
|
||||
case Some(Hackable.HackInfo(_, _, hfaction, _, start, length)) =>
|
||||
|
|
@ -122,7 +110,7 @@ class Building(private val name: String,
|
|||
val (generatorState, bootGeneratorPain) = (PlanetSideGeneratorState.Normal, false)
|
||||
//if we have spawn tubes, determine if any of them are active
|
||||
val (spawnTubesNormal, boostSpawnPain) : (Boolean, Boolean) = {
|
||||
val o = amenities.collect({ case _ : SpawnTube => true }) ///TODO obj.Health > 0
|
||||
val o = Amenities.collect({ case _ : SpawnTube => true }) ///TODO obj.Health > 0
|
||||
if(o.nonEmpty) {
|
||||
(o.foldLeft(false)(_ || _), false) //TODO poll pain field strength
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.zones
|
||||
|
||||
import net.psforever.objects.zones.{ Zone => World }
|
||||
|
||||
/**
|
||||
* The object must be able to recall on which of the defined game worlds (zones) that it exists on command.
|
||||
* The entity must be able to recall on which of the defined game worlds (zones) that it exists on command.
|
||||
* The game world identifier string produced should be equivalent to a `Zone.Id` string for some equivalent `Zone` object.
|
||||
* The identifier "nowhere" is recommended as the default invalid location.
|
||||
* @see `InterstellarCluster`
|
||||
|
|
@ -10,7 +12,37 @@ package net.psforever.objects.zones
|
|||
* @see `Zone`
|
||||
*/
|
||||
trait ZoneAware {
|
||||
def Continent : String
|
||||
private var zoneRef : World = World.Nowhere
|
||||
/**
|
||||
* Normally, an entity is the resident of a `Zone` object and that is what it considers its "continent".
|
||||
* Since the entity may switch between `Zone` objects, however,
|
||||
* if the type of entity is allowed to do that,
|
||||
* it may become useful to allow the entity to identify as belonging to its future zone earlier than reference assignment.
|
||||
*/
|
||||
private var continent : Option[String] = None
|
||||
|
||||
def Continent_=(zone : String) : String
|
||||
def Zone : World = zoneRef
|
||||
|
||||
/**
|
||||
* When assigning a new `Zone` object for the `Vehicle` object, eliminate
|
||||
* @param zone a reference to the `Zone` object
|
||||
* @return a reference to the `Zone` object
|
||||
*/
|
||||
def Zone_=(zone : World) : World = {
|
||||
continent = None
|
||||
zoneRef = zone
|
||||
Zone
|
||||
}
|
||||
|
||||
def Continent : String = continent.getOrElse(Zone.Id)
|
||||
|
||||
/**
|
||||
* Give the entity a custom `Zone` identifier.
|
||||
* @param zoneId the custom identifier of the `Zone` object
|
||||
* @return the identifier of the `Zone` object
|
||||
*/
|
||||
def Continent_=(zoneId : String) : String = {
|
||||
continent = Some(zoneId)
|
||||
Continent
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue