2022-03-27 19:57:32 -04:00
|
|
|
// Copyright (c) 2022 PSForever
|
|
|
|
|
package net.psforever.objects
|
|
|
|
|
|
2023-03-06 14:16:56 -05:00
|
|
|
import net.psforever.objects.ballistics.Projectile
|
2022-03-27 19:57:32 -04:00
|
|
|
import net.psforever.objects.definition.{ObjectDefinition, ProjectileDefinition}
|
|
|
|
|
import net.psforever.objects.serverobject.affinity.FactionAffinity
|
|
|
|
|
import net.psforever.objects.vital.resolution.{DamageAndResistance, DamageResistanceModel}
|
|
|
|
|
import net.psforever.objects.vital.{Vitality, VitalityDefinition}
|
2023-03-06 14:16:56 -05:00
|
|
|
import net.psforever.types.{PlanetSideEmpire, PlanetSideGUID, Vector3}
|
2022-03-27 19:57:32 -04:00
|
|
|
|
|
|
|
|
class DummyExplodingEntity(
|
|
|
|
|
private val obj: PlanetSideGameObject,
|
|
|
|
|
private val faction: PlanetSideEmpire.Value
|
|
|
|
|
)
|
|
|
|
|
extends PlanetSideGameObject
|
|
|
|
|
with FactionAffinity
|
|
|
|
|
with Vitality {
|
2023-03-06 14:16:56 -05:00
|
|
|
override def GUID: PlanetSideGUID = obj.GUID
|
2022-03-27 19:57:32 -04:00
|
|
|
|
|
|
|
|
override def Position: Vector3 = {
|
|
|
|
|
if (super.Position == Vector3.Zero) {
|
|
|
|
|
obj.Position
|
|
|
|
|
} else {
|
|
|
|
|
super.Position
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override def Orientation: Vector3 = {
|
|
|
|
|
if (super.Orientation == Vector3.Zero) {
|
|
|
|
|
obj.Orientation
|
|
|
|
|
} else {
|
|
|
|
|
super.Orientation
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override def Velocity : Option[Vector3] = {
|
|
|
|
|
super.Velocity.orElse(obj.Velocity)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def Faction: PlanetSideEmpire.Value = faction
|
|
|
|
|
|
|
|
|
|
def DamageModel: DamageAndResistance = DummyExplodingEntity.DefaultDamageResistanceModel
|
|
|
|
|
|
|
|
|
|
def Definition: ObjectDefinition with VitalityDefinition = {
|
2023-03-06 14:16:56 -05:00
|
|
|
new DefinitionWrappedInVitality(obj)
|
2022-03-27 19:57:32 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-06 14:16:56 -05:00
|
|
|
private class DefinitionWrappedInVitality(private val entity: PlanetSideGameObject)
|
|
|
|
|
extends ObjectDefinition(entity.Definition.ObjectId)
|
2022-03-27 19:57:32 -04:00
|
|
|
with VitalityDefinition {
|
2023-03-06 14:16:56 -05:00
|
|
|
private val internalDefinition = entity.Definition
|
|
|
|
|
|
|
|
|
|
innateDamage = internalDefinition match {
|
2022-03-27 19:57:32 -04:00
|
|
|
case v: VitalityDefinition if v.innateDamage.nonEmpty => v.innateDamage.get
|
|
|
|
|
case p: ProjectileDefinition => p
|
|
|
|
|
case _ => GlobalDefinitions.no_projectile
|
|
|
|
|
}
|
2023-03-06 14:16:56 -05:00
|
|
|
|
|
|
|
|
Name = internalDefinition.Name
|
|
|
|
|
|
2022-03-27 19:57:32 -04:00
|
|
|
DefaultHealth = 1 //just cuz
|
2023-03-06 14:16:56 -05:00
|
|
|
|
|
|
|
|
override def ObjectId: Int = entity match {
|
|
|
|
|
case p: Projectile => p.tool_def.ObjectId //projectiles point back to the weapon of origin
|
|
|
|
|
case _ => internalDefinition.ObjectId //what are we?
|
|
|
|
|
}
|
2022-03-27 19:57:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object DummyExplodingEntity {
|
|
|
|
|
final val DefaultDamageResistanceModel = new DamageResistanceModel { }
|
|
|
|
|
|
|
|
|
|
def apply(obj: PlanetSideGameObject): DummyExplodingEntity = new DummyExplodingEntity(obj, PlanetSideEmpire.NEUTRAL)
|
|
|
|
|
}
|