mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-07-16 00:44:46 +00:00
changing to square distance during mine checks; repeating entity geometric distance check function
This commit is contained in:
parent
b00f4283ab
commit
3956c1edad
2 changed files with 22 additions and 3 deletions
|
|
@ -23,7 +23,7 @@ class InteractWithMines(val range: Float)
|
|||
*/
|
||||
private var skipTargets: List[PlanetSideGUID] = List()
|
||||
|
||||
def Type = MineInteraction
|
||||
def Type: MineInteraction.type = MineInteraction
|
||||
|
||||
/**
|
||||
* Trample upon active mines in our current detection sector and alert those mines.
|
||||
|
|
@ -32,12 +32,13 @@ class InteractWithMines(val range: Float)
|
|||
*/
|
||||
def interaction(sector: SectorPopulation, target: InteractsWithZone): Unit = {
|
||||
val faction = target.Faction
|
||||
lazy val targetGeometry = target.Definition.Geometry(target)
|
||||
val targets = sector
|
||||
.deployableList
|
||||
.filter {
|
||||
case _: BoomerDeployable => false //boomers are specific types of ExplosiveDeployable but do not count here
|
||||
case _: BoomerDeployable => false //boomers are a specific type of ExplosiveDeployable that do not count here
|
||||
case ex: ExplosiveDeployable => ex.Faction != faction &&
|
||||
Zone.distanceCheck(target, ex, ex.Definition.triggerRadius)
|
||||
Zone.distanceCheck(targetGeometry, ex, ex.Definition.triggerRadius * ex.Definition.triggerRadius)
|
||||
case _ => false
|
||||
}
|
||||
val notSkipped = targets.filterNot { t => skipTargets.contains(t.GUID) }
|
||||
|
|
|
|||
|
|
@ -1901,6 +1901,24 @@ object Zone {
|
|||
distanceCheck(obj1.Definition.Geometry(obj1), obj2.Definition.Geometry(obj2), maxDistance)
|
||||
}
|
||||
|
||||
/**
|
||||
* Two game entities are considered "near" each other if they are within a certain distance of one another.
|
||||
* A default function literal mainly used for `serverSideDamage`.
|
||||
* Best used when one entity - `obj1` - is to be reused in tests against multiple other entities
|
||||
* as it skips repeatedly calculating the volumetric geometry of the repeating entity.
|
||||
* @see `ObjectDefinition.Geometry`
|
||||
* @see `serverSideDamage`
|
||||
* @param obj1 the geometric representation of a game entity
|
||||
* @param obj2 a game entity
|
||||
* @param maxDistance the square of the maximum distance permissible between game entities
|
||||
* before they are no longer considered "near"
|
||||
* @return `true`, if the two entities are near enough to each other;
|
||||
* `false`, otherwise
|
||||
*/
|
||||
def distanceCheck(obj1: VolumetricGeometry, obj2: PlanetSideGameObject, maxDistance: Float): Boolean = {
|
||||
distanceCheck(obj1, obj2.Definition.Geometry(obj2), maxDistance)
|
||||
}
|
||||
|
||||
/**
|
||||
* Two game entities are considered "near" each other if they are within a certain distance of one another.
|
||||
* @param g1 the geometric representation of a game entity
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue