mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-07-16 00:44:46 +00:00
basic interference fields; setting up operations for ce deployables
This commit is contained in:
parent
426ab84f0a
commit
6813778019
6 changed files with 124 additions and 36 deletions
|
|
@ -33,7 +33,7 @@ class DeployableToolbox {
|
||||||
* keys: categories, values: quantity storage object
|
* keys: categories, values: quantity storage object
|
||||||
*/
|
*/
|
||||||
private val categoryCounts =
|
private val categoryCounts =
|
||||||
DeployableCategory.values.toSeq.map(value => { value -> new DeployableToolbox.Bin }).toMap
|
DeployableCategory.values.map(value => { value -> new DeployableToolbox.Bin }).toMap
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* a map of bins for keeping track of the quantities of individual deployables
|
* a map of bins for keeping track of the quantities of individual deployables
|
||||||
|
|
@ -46,7 +46,7 @@ class DeployableToolbox {
|
||||||
* keys: categories, values: deployable objects
|
* keys: categories, values: deployable objects
|
||||||
*/
|
*/
|
||||||
private val deployableLists =
|
private val deployableLists =
|
||||||
DeployableCategory.values.toSeq
|
DeployableCategory.values
|
||||||
.map(value => { value -> mutable.ListBuffer[DeployableToolbox.AcceptableDeployable]() })
|
.map(value => { value -> mutable.ListBuffer[DeployableToolbox.AcceptableDeployable]() })
|
||||||
.toMap
|
.toMap
|
||||||
|
|
||||||
|
|
@ -73,7 +73,7 @@ class DeployableToolbox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def UpdateMaxCounts(certifications: Set[Certification]) = {
|
def UpdateMaxCounts(certifications: Set[Certification]): Unit = {
|
||||||
DeployableToolbox.UpdateMaxCounts(deployableCounts, categoryCounts, certifications)
|
DeployableToolbox.UpdateMaxCounts(deployableCounts, categoryCounts, certifications)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -247,7 +247,7 @@ class DeployableToolbox {
|
||||||
* @param category the target category
|
* @param category the target category
|
||||||
* @return any deployable that is found
|
* @return any deployable that is found
|
||||||
*/
|
*/
|
||||||
def DisplaceFirst(category: DeployableCategory.Value): Option[DeployableToolbox.AcceptableDeployable] = {
|
def DisplaceFirst(category: DeployableCategory): Option[DeployableToolbox.AcceptableDeployable] = {
|
||||||
val categoryList = deployableLists(category)
|
val categoryList = deployableLists(category)
|
||||||
if (categoryList.nonEmpty) {
|
if (categoryList.nonEmpty) {
|
||||||
val found = categoryList.remove(0)
|
val found = categoryList.remove(0)
|
||||||
|
|
@ -294,7 +294,7 @@ class DeployableToolbox {
|
||||||
* @param filter the type of deployable
|
* @param filter the type of deployable
|
||||||
* @return a list of globally unique identifiers that should be valid for the current zone
|
* @return a list of globally unique identifiers that should be valid for the current zone
|
||||||
*/
|
*/
|
||||||
def Category(filter: DeployableCategory.Value): List[PlanetSideGUID] = {
|
def Category(filter: DeployableCategory): List[PlanetSideGUID] = {
|
||||||
deployableLists(filter).map(_.GUID).toList
|
deployableLists(filter).map(_.GUID).toList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -478,7 +478,7 @@ object DeployableToolbox {
|
||||||
*/
|
*/
|
||||||
private def UpdateMaxCounts(
|
private def UpdateMaxCounts(
|
||||||
counts: Map[DeployedItem.Value, DeployableToolbox.Bin],
|
counts: Map[DeployedItem.Value, DeployableToolbox.Bin],
|
||||||
categories: Map[DeployableCategory.Value, DeployableToolbox.Bin],
|
categories: Map[DeployableCategory, DeployableToolbox.Bin],
|
||||||
certifications: Set[Certification]
|
certifications: Set[Certification]
|
||||||
): Unit = {
|
): Unit = {
|
||||||
import Certification._
|
import Certification._
|
||||||
|
|
|
||||||
|
|
@ -77,18 +77,18 @@ object Deployable {
|
||||||
}
|
}
|
||||||
|
|
||||||
object Category {
|
object Category {
|
||||||
def Of(item: DeployedItem.Value): DeployableCategory.Value = deployablesToCategories(item)
|
def Of(item: DeployedItem.Value): DeployableCategory = deployablesToCategories(item)
|
||||||
|
|
||||||
def Includes(category: DeployableCategory.Value): List[DeployedItem.Value] = {
|
def Includes(category: DeployableCategory): List[DeployedItem.Value] = {
|
||||||
(for {
|
(for {
|
||||||
(ce: DeployedItem.Value, cat: DeployableCategory.Value) <- deployablesToCategories
|
(ce: DeployedItem.Value, cat: DeployableCategory) <- deployablesToCategories
|
||||||
if cat == category
|
if cat == category
|
||||||
} yield ce) toList
|
} yield ce) toList
|
||||||
}
|
}
|
||||||
|
|
||||||
def OfAll(): Map[DeployedItem.Value, DeployableCategory.Value] = deployablesToCategories
|
def OfAll(): Map[DeployedItem.Value, DeployableCategory] = deployablesToCategories
|
||||||
|
|
||||||
private val deployablesToCategories: Map[DeployedItem.Value, DeployableCategory.Value] = Map(
|
private val deployablesToCategories: Map[DeployedItem.Value, DeployableCategory] = Map(
|
||||||
DeployedItem.boomer -> DeployableCategory.Boomers,
|
DeployedItem.boomer -> DeployableCategory.Boomers,
|
||||||
DeployedItem.he_mine -> DeployableCategory.Mines,
|
DeployedItem.he_mine -> DeployableCategory.Mines,
|
||||||
DeployedItem.jammer_mine -> DeployableCategory.Mines,
|
DeployedItem.jammer_mine -> DeployableCategory.Mines,
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,26 @@
|
||||||
// Copyright (c) 2017 PSForever
|
// Copyright (c) 2017 PSForever
|
||||||
package net.psforever.objects.ce
|
package net.psforever.objects.ce
|
||||||
|
|
||||||
object DeployableCategory extends Enumeration {
|
abstract class DeployableCategory(val name: String)
|
||||||
type Type = Value
|
|
||||||
|
|
||||||
val Boomers, Mines, SmallTurrets, Sensors, TankTraps, FieldTurrets, ShieldGenerators, Telepads = Value
|
object DeployableCategory {
|
||||||
|
case object None extends DeployableCategory(name = "None")
|
||||||
|
|
||||||
|
case object Boomers extends DeployableCategory(name = "Boomers")
|
||||||
|
|
||||||
|
case object Mines extends DeployableCategory(name = "Mines")
|
||||||
|
|
||||||
|
case object SmallTurrets extends DeployableCategory(name = "SmallTurrets")
|
||||||
|
|
||||||
|
case object Sensors extends DeployableCategory(name = "Sensors")
|
||||||
|
|
||||||
|
case object TankTraps extends DeployableCategory(name = "TankTraps")
|
||||||
|
|
||||||
|
case object FieldTurrets extends DeployableCategory(name = "FieldTurrets")
|
||||||
|
|
||||||
|
case object ShieldGenerators extends DeployableCategory(name = "ShieldGenerators")
|
||||||
|
|
||||||
|
case object Telepads extends DeployableCategory(name = "Telepads")
|
||||||
|
|
||||||
|
val values: Seq[DeployableCategory] = Seq(None, Boomers, Mines, SmallTurrets, Sensors, TankTraps, FieldTurrets, ShieldGenerators, Telepads)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,15 +19,15 @@ object DeployAnimation extends Enumeration {
|
||||||
}
|
}
|
||||||
|
|
||||||
trait BaseDeployableDefinition {
|
trait BaseDeployableDefinition {
|
||||||
private var category: DeployableCategory.Value = DeployableCategory.Boomers
|
private var category: DeployableCategory = DeployableCategory.None
|
||||||
private var deployTime: Long = (1 second).toMillis //ms
|
private var deployTime: Long = (1 second).toMillis //ms
|
||||||
var deployAnimation: DeployAnimation.Value = DeployAnimation.None
|
var deployAnimation: DeployAnimation.Value = DeployAnimation.None
|
||||||
|
|
||||||
def Item: DeployedItem.Value
|
def Item: DeployedItem.Value
|
||||||
|
|
||||||
def DeployCategory: DeployableCategory.Value = category
|
def DeployCategory: DeployableCategory = category
|
||||||
|
|
||||||
def DeployCategory_=(cat: DeployableCategory.Value): DeployableCategory.Value = {
|
def DeployCategory_=(cat: DeployableCategory): DeployableCategory = {
|
||||||
category = cat
|
category = cat
|
||||||
DeployCategory
|
DeployCategory
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,59 @@ import net.psforever.objects.geometry.GeometryForm
|
||||||
import net.psforever.objects.geometry.d3.VolumetricGeometry
|
import net.psforever.objects.geometry.d3.VolumetricGeometry
|
||||||
import net.psforever.types.OxygenState
|
import net.psforever.types.OxygenState
|
||||||
|
|
||||||
|
/*
|
||||||
|
Line 1316: add_property ams interference_range 125
|
||||||
|
Line 1392: add_property ams shared_interference_range 30
|
||||||
|
Line 5977: add_property boomer interference_range 0.2
|
||||||
|
Line 8735: add_property deployable_shield_generator deployable_interference_range 2.0
|
||||||
|
Line 8775: add_property deployable_shield_generator interference_range 125
|
||||||
|
Line 8798: add_property deployable_shield_generator shared_interference_range 60
|
||||||
|
Line 13684: add_property he_mine deployable_interference_range 0.1
|
||||||
|
Line 13695: add_property he_mine interference_range 7
|
||||||
|
Line 13709: add_property he_mine shared_interference_range 7
|
||||||
|
Line 14634: add_property jammer_mine deployable_interference_range 0.1
|
||||||
|
Line 14645: add_property jammer_mine interference_range 7
|
||||||
|
Line 14661: add_property jammer_mine shared_interference_range 7
|
||||||
|
Line 21038: add_property motion_alarm_sensor_dest interference_range 15
|
||||||
|
Line 21057: add_property motionalarmsensor deployable_interference_range 0.1
|
||||||
|
Line 21072: add_property motionalarmsensor interference_range 25
|
||||||
|
Line 24898: add_property portable_manned_turret deployable_interference_range 2.5
|
||||||
|
Line 24915: add_property portable_manned_turret interference_range 60
|
||||||
|
Line 24981: add_property portable_manned_turret shared_interference_range 40
|
||||||
|
Line 28196: add_property sensor_shield deployable_interference_range 0.1
|
||||||
|
Line 28205: add_property sensor_shield interference_range 20
|
||||||
|
Line 29572: add_property spitfire_aa deployable_interference_range 0.1
|
||||||
|
Line 29584: add_property spitfire_aa interference_range 25
|
||||||
|
Line 29608: add_property spitfire_aa shared_interference_range 25
|
||||||
|
Line 29819: add_property spitfire_cloaked deployable_interference_range 0.1
|
||||||
|
Line 29831: add_property spitfire_cloaked interference_range 25
|
||||||
|
Line 29855: add_property spitfire_cloaked shared_interference_range 25
|
||||||
|
Line 29939: add_property spitfire_turret deployable_interference_range 0.1
|
||||||
|
Line 29951: add_property spitfire_turret interference_range 25
|
||||||
|
Line 29975: add_property spitfire_turret shared_interference_range 25
|
||||||
|
Line 30231: add_property stationaryteleportpad deployable_interference_range 5.5
|
||||||
|
Line 30933: add_property tank_traps deployable_interference_range 3.0
|
||||||
|
Line 30943: add_property tank_traps interference_range 3.5
|
||||||
|
Line 30944: add_property tank_traps interference_range2 60
|
||||||
|
Line 30969: add_property tank_traps shared_interference_range 60
|
||||||
|
Line 37319: add_property zipline deployable_interference_range 5.5
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Block the deployment of certain entities within a certain distance.
|
||||||
|
* Deployable vehicles and combat engineer entities both have a deployment condition that can be influenced by these ranges.
|
||||||
|
* Vehicles of an object type block other vehicles of that object type.
|
||||||
|
* Combat engineering entities block combat engineering entities of the same category.
|
||||||
|
* @param main distance between which similar deployable entities block one another (m)
|
||||||
|
* @param shared na
|
||||||
|
* @param deployable distance between which this entity may block deployment of other combat engineering entities (m);
|
||||||
|
* defaults to 0
|
||||||
|
*/
|
||||||
|
final case class InterferenceRange(main: Float, shared: Float, deployable: Float = 0f)
|
||||||
|
|
||||||
|
object InterferenceRange {
|
||||||
|
val None: InterferenceRange = InterferenceRange(0f, 0f)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Associate an object's canned in-game representation with its basic game identification unit.
|
* Associate an object's canned in-game representation with its basic game identification unit.
|
||||||
* The extension of this `class` would identify the common data necessary to construct such a given game object.<br>
|
* The extension of this `class` would identify the common data necessary to construct such a given game object.<br>
|
||||||
|
|
@ -121,5 +174,10 @@ abstract class ObjectDefinition(private val objectId: Int)
|
||||||
*/
|
*/
|
||||||
var maxForwardSpeed: Float = 0f
|
var maxForwardSpeed: Float = 0f
|
||||||
|
|
||||||
|
/**
|
||||||
|
* na
|
||||||
|
*/
|
||||||
|
var interference: InterferenceRange = InterferenceRange.None
|
||||||
|
|
||||||
def ObjectId: Int = objectId
|
def ObjectId: Int = objectId
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import net.psforever.objects.ce.Deployable
|
||||||
import net.psforever.objects.sourcing.ObjectSource
|
import net.psforever.objects.sourcing.ObjectSource
|
||||||
import net.psforever.objects.vehicles.MountedWeapons
|
import net.psforever.objects.vehicles.MountedWeapons
|
||||||
import net.psforever.objects.vital.SpawningActivity
|
import net.psforever.objects.vital.SpawningActivity
|
||||||
|
import net.psforever.types.Vector3
|
||||||
|
|
||||||
import scala.annotation.tailrec
|
import scala.annotation.tailrec
|
||||||
import scala.collection.mutable
|
import scala.collection.mutable
|
||||||
|
|
@ -28,7 +29,7 @@ class ZoneDeployableActor(
|
||||||
|
|
||||||
def receive: Receive = {
|
def receive: Receive = {
|
||||||
case Zone.Deployable.Build(obj) =>
|
case Zone.Deployable.Build(obj) =>
|
||||||
if (DeployableBuild(obj, deployableList)) {
|
if (DeployableBuild(zone, obj, deployableList)) {
|
||||||
obj.Zone = zone
|
obj.Zone = zone
|
||||||
obj match {
|
obj match {
|
||||||
case mounting: MountedWeapons =>
|
case mounting: MountedWeapons =>
|
||||||
|
|
@ -40,11 +41,10 @@ class ZoneDeployableActor(
|
||||||
.foreach { guid =>
|
.foreach { guid =>
|
||||||
turretToMount.put(guid, dguid)
|
turretToMount.put(guid, dguid)
|
||||||
}
|
}
|
||||||
case _ => ;
|
case _ => ()
|
||||||
}
|
}
|
||||||
obj.Definition.Initialize(obj, context)
|
obj.Definition.Initialize(obj, context)
|
||||||
zone.actor ! ZoneActor.AddToBlockMap(obj, obj.Position)
|
obj.LogActivity(SpawningActivity(ObjectSource(obj), zone.Number, None))
|
||||||
//obj.History(EntitySpawn(SourceEntry(obj), obj.Zone))
|
|
||||||
obj.Actor ! Zone.Deployable.Setup()
|
obj.Actor ! Zone.Deployable.Setup()
|
||||||
} else {
|
} else {
|
||||||
log.warn(s"failed to build a ${obj.Definition.Name}")
|
log.warn(s"failed to build a ${obj.Definition.Name}")
|
||||||
|
|
@ -52,7 +52,7 @@ class ZoneDeployableActor(
|
||||||
}
|
}
|
||||||
|
|
||||||
case Zone.Deployable.BuildByOwner(obj, owner, tool) =>
|
case Zone.Deployable.BuildByOwner(obj, owner, tool) =>
|
||||||
if (DeployableBuild(obj, deployableList)) {
|
if (DeployableBuild(zone, obj, deployableList)) {
|
||||||
obj.Zone = zone
|
obj.Zone = zone
|
||||||
obj match {
|
obj match {
|
||||||
case mounting: MountedWeapons =>
|
case mounting: MountedWeapons =>
|
||||||
|
|
@ -64,10 +64,9 @@ class ZoneDeployableActor(
|
||||||
.foreach { guid =>
|
.foreach { guid =>
|
||||||
turretToMount.put(guid, dguid)
|
turretToMount.put(guid, dguid)
|
||||||
}
|
}
|
||||||
case _ => ;
|
case _ => ()
|
||||||
}
|
}
|
||||||
obj.Definition.Initialize(obj, context)
|
obj.Definition.Initialize(obj, context)
|
||||||
zone.actor ! ZoneActor.AddToBlockMap(obj, obj.Position)
|
|
||||||
obj.LogActivity(SpawningActivity(ObjectSource(obj), zone.Number, None))
|
obj.LogActivity(SpawningActivity(ObjectSource(obj), zone.Number, None))
|
||||||
owner.Actor ! Player.BuildDeployable(obj, tool)
|
owner.Actor ! Player.BuildDeployable(obj, tool)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -76,17 +75,16 @@ class ZoneDeployableActor(
|
||||||
}
|
}
|
||||||
|
|
||||||
case Zone.Deployable.Dismiss(obj) =>
|
case Zone.Deployable.Dismiss(obj) =>
|
||||||
if (DeployableDismiss(obj, deployableList)) {
|
if (DeployableDismiss(zone, obj, deployableList)) {
|
||||||
obj match {
|
obj match {
|
||||||
case _: MountedWeapons =>
|
case _: MountedWeapons =>
|
||||||
val dguid = obj.GUID.guid
|
val dguid = obj.GUID.guid
|
||||||
turretToMount.filterInPlace { case (_, guid) => guid != dguid }
|
turretToMount.filterInPlace { case (_, guid) => guid != dguid }
|
||||||
case _ => ;
|
case _ => ()
|
||||||
}
|
}
|
||||||
obj.Actor ! Zone.Deployable.IsDismissed(obj)
|
obj.Actor ! Zone.Deployable.IsDismissed(obj)
|
||||||
obj.Definition.Uninitialize(obj, context)
|
obj.Definition.Uninitialize(obj, context)
|
||||||
obj.ClearHistory()
|
obj.ClearHistory()
|
||||||
zone.actor ! ZoneActor.RemoveFromBlockMap(obj)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case Zone.Deployable.IsBuilt(_) => ;
|
case Zone.Deployable.IsBuilt(_) => ;
|
||||||
|
|
@ -99,27 +97,41 @@ class ZoneDeployableActor(
|
||||||
|
|
||||||
object ZoneDeployableActor {
|
object ZoneDeployableActor {
|
||||||
def DeployableBuild(
|
def DeployableBuild(
|
||||||
obj: Deployable,
|
zone: Zone,
|
||||||
deployableList: ListBuffer[Deployable]
|
obj: Deployable,
|
||||||
): Boolean = {
|
deployableList: ListBuffer[Deployable]
|
||||||
|
): Boolean = {
|
||||||
|
val position = obj.Position
|
||||||
|
val positionxy = position.xy
|
||||||
deployableList.find(d => d == obj) match {
|
deployableList.find(d => d == obj) match {
|
||||||
case Some(_) =>
|
case None if {
|
||||||
false
|
val interference = obj.Definition.interference
|
||||||
case None =>
|
val category = obj.Definition.DeployCategory
|
||||||
|
val sector = zone.blockMap.sector(position, interference.main)
|
||||||
|
!sector.deployableList.exists { p =>
|
||||||
|
p.Definition.DeployCategory == category ||
|
||||||
|
Vector3.DistanceSquared(positionxy, p.Position.xy).toDouble < math.pow(p.Definition.interference.deployable.toDouble, 2)
|
||||||
|
}
|
||||||
|
} =>
|
||||||
deployableList += obj
|
deployableList += obj
|
||||||
|
zone.actor ! ZoneActor.AddToBlockMap(obj, position)
|
||||||
true
|
true
|
||||||
|
case _ =>
|
||||||
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def DeployableDismiss(
|
def DeployableDismiss(
|
||||||
obj: Deployable,
|
zone: Zone,
|
||||||
deployableList: ListBuffer[Deployable]
|
obj: Deployable,
|
||||||
): Boolean = {
|
deployableList: ListBuffer[Deployable]
|
||||||
|
): Boolean = {
|
||||||
recursiveFindDeployable(deployableList.iterator, obj) match {
|
recursiveFindDeployable(deployableList.iterator, obj) match {
|
||||||
case None =>
|
case None =>
|
||||||
false
|
false
|
||||||
case Some(index) =>
|
case Some(index) =>
|
||||||
deployableList.remove(index)
|
deployableList.remove(index)
|
||||||
|
zone.actor ! ZoneActor.RemoveFromBlockMap(obj)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue