mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-01-20 02:54:46 +00:00
CaptureFlag + CaptureFlagSocket objects/converters/definitions
This commit is contained in:
parent
84a36dc9c8
commit
d0e6c44e58
|
|
@ -30,6 +30,7 @@ import net.psforever.objects.vital.prop.DamageWithPosition
|
|||
import net.psforever.objects.vital.{ComplexDeployableResolutions, MaxResolutions, SimpleResolutions}
|
||||
import net.psforever.types.{ExoSuitType, ImplantType, PlanetSideEmpire, Vector3}
|
||||
import net.psforever.types._
|
||||
import net.psforever.objects.serverobject.llu.{CaptureFlagDefinition, CaptureFlagSocketDefinition}
|
||||
|
||||
import scala.collection.mutable
|
||||
import scala.concurrent.duration._
|
||||
|
|
@ -1060,6 +1061,11 @@ object GlobalDefinitions {
|
|||
|
||||
val vanu_control_console = new CaptureTerminalDefinition(930) // Cavern CC
|
||||
|
||||
val llm_socket = new CaptureFlagSocketDefinition()
|
||||
|
||||
val capture_flag = new CaptureFlagDefinition()
|
||||
capture_flag.Packet = new CaptureFlagConverter
|
||||
|
||||
val lodestar_repair_terminal = new MedicalTerminalDefinition(461)
|
||||
|
||||
val multivehicle_rearm_terminal = new OrderTerminalDefinition(576)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
package net.psforever.objects.definition.converter
|
||||
|
||||
import net.psforever.objects.serverobject.llu.CaptureFlag
|
||||
import net.psforever.objects.serverobject.structures.Building
|
||||
import net.psforever.packet.game.objectcreate.{CaptureFlagData, PlacementData}
|
||||
|
||||
import java.util.concurrent.TimeUnit
|
||||
import scala.util.{Success, Try}
|
||||
|
||||
class CaptureFlagConverter extends ObjectCreateConverter[CaptureFlag]() {
|
||||
override def ConstructorData(obj : CaptureFlag) : Try[CaptureFlagData] = {
|
||||
val hackInfo = obj.Owner.asInstanceOf[Building].CaptureTerminal.get.HackedBy.get
|
||||
val millisecondsRemaining = TimeUnit.MILLISECONDS.convert(math.max(0, hackInfo.hackStartTime + hackInfo.hackDuration - System.nanoTime), TimeUnit.NANOSECONDS)
|
||||
|
||||
Success(
|
||||
CaptureFlagData(
|
||||
new PlacementData(obj.Position, obj.Orientation, obj.Velocity),
|
||||
obj.Faction,
|
||||
obj.Owner.asInstanceOf[Building].GUID.guid,
|
||||
obj.Target.GUID.guid,
|
||||
millisecondsRemaining
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
package net.psforever.objects.serverobject.llu
|
||||
|
||||
import net.psforever.objects.serverobject.structures.{Amenity, AmenityOwner, Building}
|
||||
import net.psforever.objects.{GlobalDefinitions, Player}
|
||||
import net.psforever.types.{PlanetSideEmpire, Vector3}
|
||||
|
||||
/**
|
||||
* This object represents the LLU that gets spawned at a LLU socket when a LLU control console is hacked
|
||||
*/
|
||||
class CaptureFlag(tDef: CaptureFlagDefinition) extends Amenity {
|
||||
def Definition : CaptureFlagDefinition = tDef
|
||||
|
||||
private var target: Building = Building.NoBuilding
|
||||
private var faction: PlanetSideEmpire.Value = PlanetSideEmpire.NEUTRAL
|
||||
private var carrier: Option[Player] = None
|
||||
|
||||
def Target: Building = target
|
||||
def Target_=(new_target: Building): Building = {
|
||||
target = new_target
|
||||
target
|
||||
}
|
||||
|
||||
/**
|
||||
* Since a LLU belongs to a base, but needs to be picked up by the enemy faction we need to be able to override the faction that owns the LLU to the hacker faction
|
||||
*/
|
||||
override def Faction: PlanetSideEmpire.Value = faction
|
||||
override def Faction_=(new_faction: PlanetSideEmpire.Value): PlanetSideEmpire.Value = {
|
||||
faction = new_faction
|
||||
faction
|
||||
}
|
||||
|
||||
def Carrier: Option[Player] = carrier
|
||||
def Carrier_=(new_carrier: Option[Player]) : Option[Player] = {
|
||||
carrier = new_carrier
|
||||
carrier
|
||||
}
|
||||
}
|
||||
|
||||
object CaptureFlag {
|
||||
def apply(tDef: CaptureFlagDefinition): CaptureFlag = {
|
||||
new CaptureFlag(tDef)
|
||||
}
|
||||
|
||||
def Constructor(pos: Vector3, ori: Vector3, target: Building, owner: AmenityOwner, faction: PlanetSideEmpire.Value) : CaptureFlag = {
|
||||
val obj = CaptureFlag(GlobalDefinitions.capture_flag)
|
||||
obj.Position = pos
|
||||
obj.Orientation = ori
|
||||
obj.Target = target
|
||||
obj.Owner = owner
|
||||
obj.Faction = faction
|
||||
|
||||
obj
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package net.psforever.objects.serverobject.llu
|
||||
|
||||
import net.psforever.objects.serverobject.structures.AmenityDefinition
|
||||
|
||||
/**
|
||||
* The definition for any 'CaptureFlag'
|
||||
* Object Id 157
|
||||
*/
|
||||
class CaptureFlagDefinition extends AmenityDefinition(157) {
|
||||
Name = "capture_flag"
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package net.psforever.objects.serverobject.llu
|
||||
|
||||
import akka.actor.ActorContext
|
||||
import net.psforever.objects.GlobalDefinitions
|
||||
import net.psforever.objects.serverobject.structures.Amenity
|
||||
import net.psforever.types.Vector3
|
||||
|
||||
|
||||
/**
|
||||
* Represents the LLU sockets found within bases that require LLU hacks.
|
||||
* It is used as a position reference for spawning the LLU in the correct location when the base is hacked
|
||||
* @param tDef the `ObjectDefinition` that constructs this object and maintains some of its immutable fields
|
||||
*/
|
||||
class CaptureFlagSocket(tDef: CaptureFlagSocketDefinition) extends Amenity {
|
||||
def Definition : CaptureFlagSocketDefinition = tDef
|
||||
}
|
||||
|
||||
object CaptureFlagSocket {
|
||||
def apply(tDef: CaptureFlagSocketDefinition) : CaptureFlagSocket = {
|
||||
new CaptureFlagSocket(tDef)
|
||||
}
|
||||
|
||||
def Constructor(pos: Vector3)(id: Int, context: ActorContext) : CaptureFlagSocket = {
|
||||
Constructor(GlobalDefinitions.llm_socket, pos)(id, context)
|
||||
}
|
||||
|
||||
def Constructor(tdef: CaptureFlagSocketDefinition, pos: Vector3)(id: Int, context: ActorContext) : CaptureFlagSocket = {
|
||||
val obj = CaptureFlagSocket(tdef)
|
||||
obj.Position = pos
|
||||
obj
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package net.psforever.objects.serverobject.llu
|
||||
|
||||
import net.psforever.objects.serverobject.structures.AmenityDefinition
|
||||
|
||||
/**
|
||||
* The definition for any 'CaptureFlagSocket'
|
||||
* Object Id 450
|
||||
*/
|
||||
class CaptureFlagSocketDefinition extends AmenityDefinition(450) {
|
||||
Name = "llm_socket"
|
||||
}
|
||||
Loading…
Reference in a new issue