PSF-LoginServer/src/main/scala/net/psforever/objects/Ntu.scala
Fate-JH 6ae0b44848
Lump of Coal (#982)
* preliminary elements needed to battle frame robotics; mostly from previous branch

* introduction of FrameVehicleStateMessage and anticipated event system paths for BFR's; spawning amenities for BFR's are parsed and built from the zonemap files, but their coordinates are currently incorrect, and the resulting entity will not function atm

* bfr's spawn correctly; default arm weapons will spawn correctly; bfr rearm terminal added but arm swap not working correctly; bfr shields charge if not full; proper separation of vehicle spawn pad types

* arm weapon swapping in bfr's; swapped weapons switch, contextually, to either *_left or to *_right depending on the mounting; partial support for entities that do not have an OCDM packet form

* crouching improves shield regeneration

* some projectiles damage the bfr regardless of its shield

* delay the final vehicle explosion; start of vehicle subsystems

* handling for bfr shield ui updates; more of vehicle subsystems; corrections to TradeMessage packet; clarifications for FrameVehicleStateMessage package; report on flight status of bfr's

* control agency support for vehicle subsystems for arm weapon fire control

* vehicle capacitor, for what it's worth; shield and capacitor are influenced by recharge freeze and drain

* initial packet and tests for AvatarAwardMessage; update the fields of FreindsResponse, DetailedCharacterData, and LoadoutType for FavoritesMessage; corrections to intiailization packets in SessionActor; players start as imprinted by default

* support for GOAM and GAM integration into vehicle control agencies using a basic actor superclass; addition of vehicle subsystems; modifications to bfr control agency to allow for weapon handiness and subsystem control; fixed Fit mapping for vehicle override; made mountable seat transcoders independent

* delayed explosions to accompany the delayed death for the bfr; bfr terminal window closes on successful purchase

* the bfr armor siphon works

* clarification for bfr inventory item manipulation; corrections to length of bfr transcoder for flight variants; everything else in in support of the various arm weapons that can be assigned to the bfr, including damage proxy support for causing/interacting with/cleaning up after radiation cloud projectiles

* fixed the apc emp burst; fixed bfr arm weapon manipulation for activated subsystem; armor and ntu siphon support

* battleframe loadouts available upon vehicle spawn (vs and tr only)

* adb values for siphons; subsystem update message; some repairs

* cargo vehicles are subject to radiation damage; damage for battleframes are different depending on shield evasion status; battleframe loadout deleting supported; bfr kill box; automatically wire bfr sheds, includeing the ones in sanctuary

* proper bfr spawn angles; bfr vehicle timers; projectiles are no longer radiation clouds by default; better remote projectile cleanup; resolving incorrect weapon arm enabled states for bfrs

* added tests for FrameVehicleState and GenericObjectActionAtPosition; pass around maximum sector for zone interactions

* changed the triggers for the stamina regeneration timer

* potential fix for issue related to finding arm weapon mounts

* modifications to how vehicle subsystems are automated; jammer field updates; support and passing around custom block map ranges; does include activated dev tests for battleframe PAM, which will need to be stripped out later

* commit while working on subsystems mk2

* subsystems fail when jammed; an unoccupied bfr does not have shields active; pulling a bfr of one variant should block the other variant too

* fix distance check with radiation clouds; blocked bfr weaponry from anywhere but bfr arm mounts and cursor; ammunition depletion of aphelion laser; bfr shields deactivates when unoccupied

* significant modifications to vehicle subsystem operations; disambiguation of weapon subsystems; debuffs to charge rate and use rate for the capacitor and shield of bfr; test for ComponentDamageMessage; somewhat proper jammering operations for bfr
2022-01-27 09:57:51 -05:00

108 lines
3.1 KiB
Scala

// Copyright (c) 2020 PSForever
package net.psforever.objects
import akka.actor.{Actor, ActorRef}
import net.psforever.actors.commands.NtuCommand
import net.psforever.objects.definition.ObjectDefinition
import net.psforever.objects.serverobject.transfer.{TransferBehavior, TransferContainer}
object Ntu {
object Nanites extends TransferContainer.TransferMaterial
/**
* Message for a `sender` announcing it has nanites it can offer the recipient.
*
* @param src the nanite container recognized as the sender
*/
final case class Offer(src: NtuContainer)
/**
* Message for a `sender` asking for nanites from the recipient.
*
* @param min a minimum amount of nanites requested;
* if 0, the `sender` has no expectations
* @param max the amount of nanites required to not make further requests;
* if 0, the `sender` is full and the message is for clean up operations
*/
final case class Request(min: Float, max: Float)
/**
* Message for transferring nanites to a recipient.
*
* @param src the nanite container recognized as the sender
* @param amount the nanites transferred in this package
*/
final case class Grant(src: NtuContainer, amount: Float)
}
trait NtuContainerOwner {
def getNtuContainer: Option[NtuContainer]
}
trait NtuContainer extends TransferContainer {
def NtuCapacitor: Float
def NtuCapacitor_=(value: Float): Float
def NtuCapacitorScaled: Int = {
if (Definition.MaxNtuCapacitor > 0) {
scala.math.ceil((NtuCapacitor / Definition.MaxNtuCapacitor) * 10).toInt
} else {
0
}
}
def MaxNtuCapacitor: Float
def Definition: ObjectDefinition with NtuContainerDefinition
}
trait CommonNtuContainer extends NtuContainer {
private var ntuCapacitor: Float = 0
def NtuCapacitor: Float = ntuCapacitor
def NtuCapacitor_=(value: Float): Float = {
ntuCapacitor = scala.math.max(0, scala.math.min(value, Definition.MaxNtuCapacitor))
NtuCapacitor
}
}
trait NtuContainerDefinition {
private var maxNtuCapacitor: Float = 0
def MaxNtuCapacitor: Float = maxNtuCapacitor
def MaxNtuCapacitor_=(max: Float): Float = {
maxNtuCapacitor = max
MaxNtuCapacitor
}
}
trait NtuStorageBehavior extends Actor {
def NtuStorageObject: NtuContainer = null
def storageBehavior: Receive = {
case Ntu.Offer(src) => HandleNtuOffer(sender(), src)
case Ntu.Grant(_, 0) | Ntu.Request(0, 0) | TransferBehavior.Stopping() => StopNtuBehavior(sender())
case Ntu.Request(min, max) => HandleNtuRequest(sender(), min, max)
case NtuCommand.Request(amount, replyTo) =>
import akka.actor.typed.scaladsl.adapter.TypedActorRefOps
HandleNtuRequest(new TypedActorRefOps(replyTo).toClassic, amount, amount+1)
case Ntu.Grant(src, amount) => HandleNtuGrant(sender(), src, amount)
case NtuCommand.Grant(src, amount) => HandleNtuGrant(sender(), src, amount)
}
def HandleNtuOffer(sender: ActorRef, src: NtuContainer): Unit
def StopNtuBehavior(sender: ActorRef): Unit
def HandleNtuRequest(sender: ActorRef, min: Float, max: Float): Unit
def HandleNtuGrant(sender: ActorRef, src: NtuContainer, amount: Float): Unit
}