mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-03-17 19:10:37 +00:00
* created base damage interaction classes and replaced various projectile-based damage that utilized ResolvedProjectile; not refined, maintains redundancy and overloads, but should work * continuing to reduce the exposure of ResolvedProjectile and replacing it with applications of DamageInteraction, DamageResult, and DamageReason * removed ResolvedProjectile from the project; adjusted remaining code paths to work around it * vitals.test became vital.base; no one liked this * lots of inheritance, polymorphism, and other chicanery; moved around files, so it also looks like more files have changed when they have not (even if they did) * codecov file correction * master rebase; vital directory structure changed, so file imports have been modified in several other files; ResolutionSelection has been removed, requiring direct function literal assignment; tests repaired, where necessary; no actual functional change * code comments * DamageResult is its own case class now, wrapping around a before/after target and the interaction used in its calaculations; tests have been corrected * adjusted Player.Die() to demonstrate a damage-based suicide approach * resolved circular inheritance in projectile damage modifiers; better employed explosion reason, damages players around exploding vehicle as example * expanded explosions to other object types; exploding is now a flag and the damage is an innate property of the object type; removed advanced references to properties on the damage source, since the damage source is easily accessible; wrote comments; fixed tests * overhaul to painbox damage to align with normal player damage handling, thus assimilating it properly into the damage system * future development; normal vector from euler angles; custom proximity test * where 'innateDamage' should have not replaced 'explosion' * moved the hitPos for the generator test; attempting to imrpove the reliability of the auto-repair integration tests (didn't ...) * spelling and private val
52 lines
2 KiB
Scala
52 lines
2 KiB
Scala
// Copyright (c) 2020 PSForever
|
|
package net.psforever.objects
|
|
|
|
import akka.actor.{Actor, ActorContext, Props}
|
|
import net.psforever.objects.ce.{ComplexDeployable, Deployable, DeployedItem}
|
|
import net.psforever.objects.definition.converter.TRAPConverter
|
|
import net.psforever.objects.definition.{ComplexDeployableDefinition, SimpleDeployableDefinition}
|
|
import net.psforever.objects.serverobject.PlanetSideServerObject
|
|
import net.psforever.objects.serverobject.damage.{Damageable, DamageableEntity}
|
|
import net.psforever.objects.serverobject.repair.RepairableEntity
|
|
import net.psforever.objects.vital.SimpleResolutions
|
|
import net.psforever.objects.vital.interaction.DamageResult
|
|
import net.psforever.objects.zones.Zone
|
|
|
|
class TrapDeployable(cdef: TrapDeployableDefinition) extends ComplexDeployable(cdef)
|
|
|
|
class TrapDeployableDefinition(objectId: Int) extends ComplexDeployableDefinition(objectId) {
|
|
Model = SimpleResolutions.calculate
|
|
Packet = new TRAPConverter
|
|
|
|
override def Initialize(obj: PlanetSideServerObject with Deployable, context: ActorContext) = {
|
|
obj.Actor = context.actorOf(Props(classOf[TrapDeployableControl], obj), PlanetSideServerObject.UniqueActorName(obj))
|
|
}
|
|
|
|
override def Uninitialize(obj: PlanetSideServerObject with Deployable, context: ActorContext) = {
|
|
SimpleDeployableDefinition.SimpleUninitialize(obj, context)
|
|
}
|
|
}
|
|
|
|
object TrapDeployableDefinition {
|
|
def apply(dtype: DeployedItem.Value): TrapDeployableDefinition = {
|
|
new TrapDeployableDefinition(dtype.id)
|
|
}
|
|
}
|
|
|
|
class TrapDeployableControl(trap: TrapDeployable) extends Actor with DamageableEntity with RepairableEntity {
|
|
def DamageableObject = trap
|
|
def RepairableObject = trap
|
|
|
|
def receive: Receive =
|
|
takesDamage
|
|
.orElse(canBeRepairedByNanoDispenser)
|
|
.orElse {
|
|
case _ =>
|
|
}
|
|
|
|
override protected def DestructionAwareness(target: Damageable.Target, cause: DamageResult): Unit = {
|
|
super.DestructionAwareness(target, cause)
|
|
Deployables.AnnounceDestroyDeployable(trap, None)
|
|
Zone.causeExplosion(target.Zone, target, Some(cause))
|
|
}
|
|
}
|