mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-03-04 12:40:20 +00:00
begun work on repair and rearm silos by dividing up proximity terminal behavior; terminals at Anguta wired
This commit is contained in:
parent
d6325d8dfc
commit
7673c8941b
11 changed files with 186 additions and 53 deletions
|
|
@ -524,6 +524,8 @@ object GlobalDefinitions {
|
|||
|
||||
val medical_terminal = new MedicalTerminalDefinition(529)
|
||||
|
||||
val repair_silo = new RepairRearmSiloDefinition(729)
|
||||
|
||||
val spawn_pad = new VehicleSpawnPadDefinition
|
||||
|
||||
val mb_locker = new LockerDefinition
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.serverobject.terminals
|
||||
|
||||
import net.psforever.packet.game.PlanetSideGUID
|
||||
|
||||
/**
|
||||
* A server object that is a "terminal" that can be accessed for amenities and services,
|
||||
* triggered when a certain distance from the unit itself (proximity-based).<br>
|
||||
|
|
@ -11,21 +9,7 @@ import net.psforever.packet.game.PlanetSideGUID
|
|||
* For example, the cavern crystals are considered owner-neutral elements that are not attached to a `Building` object.
|
||||
* @param tdef the `ObjectDefinition` that constructs this object and maintains some of its immutable fields
|
||||
*/
|
||||
class ProximityTerminal(tdef : MedicalTerminalDefinition) extends Terminal(tdef) {
|
||||
private var users : Set[PlanetSideGUID] = Set.empty
|
||||
|
||||
def NumberUsers : Int = users.size
|
||||
|
||||
def AddUser(player_guid : PlanetSideGUID) : Int = {
|
||||
users += player_guid
|
||||
NumberUsers
|
||||
}
|
||||
|
||||
def RemoveUser(player_guid : PlanetSideGUID) : Int = {
|
||||
users -= player_guid
|
||||
NumberUsers
|
||||
}
|
||||
}
|
||||
class ProximityTerminal(tdef : MedicalTerminalDefinition) extends Terminal(tdef) with ProximityUnit
|
||||
|
||||
object ProximityTerminal {
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,36 +2,24 @@
|
|||
package net.psforever.objects.serverobject.terminals
|
||||
|
||||
import akka.actor.Actor
|
||||
import net.psforever.objects.serverobject.CommonMessages
|
||||
import net.psforever.objects.serverobject.affinity.{FactionAffinity, FactionAffinityBehavior}
|
||||
import net.psforever.objects.serverobject.terminals.Terminal.TerminalMessage
|
||||
|
||||
/**
|
||||
*
|
||||
* An `Actor` that handles messages being dispatched to a specific `ProximityTerminal`.
|
||||
* Although this "terminal" itself does not accept the same messages as a normal `Terminal` object,
|
||||
* it returns the same type of messages - wrapped in a `TerminalMessage` - to the `sender`.
|
||||
* @param term the proximity unit (terminal)
|
||||
*/
|
||||
class ProximityTerminalControl(term : ProximityTerminal) extends Actor with FactionAffinityBehavior.Check {
|
||||
class ProximityTerminalControl(term : Terminal with ProximityUnit) extends Actor with FactionAffinityBehavior.Check with ProximityUnit.Use {
|
||||
def FactionObject : FactionAffinity = term
|
||||
|
||||
def receive : Receive = checkBehavior.orElse {
|
||||
case CommonMessages.Use(player) =>
|
||||
val hadNoUsers = term.NumberUsers == 0
|
||||
if(term.AddUser(player.GUID) == 1 && hadNoUsers) {
|
||||
sender ! TerminalMessage(player, null, Terminal.StartProximityEffect(term))
|
||||
}
|
||||
def TerminalObject : Terminal with ProximityUnit = term
|
||||
|
||||
case CommonMessages.Unuse(player) =>
|
||||
val hadUsers = term.NumberUsers > 0
|
||||
if(term.RemoveUser(player.GUID) == 0 && hadUsers) {
|
||||
sender ! TerminalMessage(player, null, Terminal.StopProximityEffect(term))
|
||||
}
|
||||
|
||||
case _ =>
|
||||
sender ! Terminal.NoDeal()
|
||||
}
|
||||
def receive : Receive = checkBehavior
|
||||
.orElse(proximityBehavior)
|
||||
.orElse {
|
||||
case _ => ;
|
||||
}
|
||||
|
||||
override def toString : String = term.Definition.Name
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.serverobject.terminals
|
||||
|
||||
import net.psforever.objects.serverobject.CommonMessages
|
||||
import net.psforever.objects.serverobject.terminals.Terminal.TerminalMessage
|
||||
import net.psforever.packet.game.PlanetSideGUID
|
||||
|
||||
/**
|
||||
* A server object that is a "terminal" that can be accessed for amenities and services,
|
||||
* triggered when a certain distance from the unit itself (proximity-based).<br>
|
||||
* <br>
|
||||
* Unlike conventional terminals, this structure is not necessarily structure-owned.
|
||||
* For example, the cavern crystals are considered owner-neutral elements that are not attached to a `Building` object.
|
||||
*/
|
||||
trait ProximityUnit {
|
||||
this : Terminal =>
|
||||
|
||||
private var users : Set[PlanetSideGUID] = Set.empty
|
||||
|
||||
def NumberUsers : Int = users.size
|
||||
|
||||
def AddUser(player_guid : PlanetSideGUID) : Int = {
|
||||
users += player_guid
|
||||
NumberUsers
|
||||
}
|
||||
|
||||
def RemoveUser(player_guid : PlanetSideGUID) : Int = {
|
||||
users -= player_guid
|
||||
NumberUsers
|
||||
}
|
||||
}
|
||||
|
||||
object ProximityUnit {
|
||||
import akka.actor.Actor
|
||||
|
||||
trait Use {
|
||||
this : Actor =>
|
||||
|
||||
def TerminalObject : Terminal with ProximityUnit
|
||||
|
||||
val proximityBehavior : Receive = {
|
||||
case CommonMessages.Use(player) =>
|
||||
val hadNoUsers = TerminalObject.NumberUsers == 0
|
||||
if(TerminalObject.AddUser(player.GUID) == 1 && hadNoUsers) {
|
||||
sender ! TerminalMessage(player, null, Terminal.StartProximityEffect(TerminalObject))
|
||||
}
|
||||
|
||||
case CommonMessages.Unuse(player) =>
|
||||
val hadUsers = TerminalObject.NumberUsers > 0
|
||||
if(TerminalObject.RemoveUser(player.GUID) == 0 && hadUsers) {
|
||||
sender ! TerminalMessage(player, null, Terminal.StopProximityEffect(TerminalObject))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.serverobject.terminals
|
||||
|
||||
import akka.actor.Actor
|
||||
import net.psforever.objects.serverobject.affinity.{FactionAffinity, FactionAffinityBehavior}
|
||||
|
||||
class RepairRearmControl(term : RepairRearmSilo) extends Actor with FactionAffinityBehavior.Check with ProximityUnit.Use {
|
||||
def FactionObject : FactionAffinity = term
|
||||
|
||||
def TerminalObject : Terminal with ProximityUnit = term
|
||||
|
||||
def receive : Receive = checkBehavior
|
||||
.orElse(proximityBehavior)
|
||||
.orElse {
|
||||
case Terminal.Request(player, msg) =>
|
||||
sender ! Terminal.TerminalMessage(player, msg, term.Request(player, msg))
|
||||
|
||||
case _ => ;
|
||||
}
|
||||
|
||||
override def toString : String = term.Definition.Name
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.serverobject.terminals
|
||||
|
||||
/**
|
||||
* A server object that is a "terminal" that can be accessed for amenities and services,
|
||||
* triggered when a certain distance from the unit itself (proximity-based).<br>
|
||||
* <br>
|
||||
* Unlike conventional terminals, this structure is not necessarily structure-owned.
|
||||
* For example, the cavern crystals are considered owner-neutral elements that are not attached to a `Building` object.
|
||||
* @param tdef the `ObjectDefinition` that constructs this object and maintains some of its immutable fields
|
||||
*/
|
||||
class RepairRearmSilo(tdef : RepairRearmSiloDefinition) extends Terminal(tdef) with ProximityUnit
|
||||
|
||||
object RepairRearmSilo {
|
||||
/**
|
||||
* Overloaded constructor.
|
||||
* @param tdef the `ObjectDefinition` that constructs this object and maintains some of its immutable fields
|
||||
*/
|
||||
def apply(tdef : RepairRearmSiloDefinition) : RepairRearmSilo = {
|
||||
new RepairRearmSilo(tdef)
|
||||
}
|
||||
|
||||
import akka.actor.ActorContext
|
||||
|
||||
/**
|
||||
* Instantiate an configure a `Terminal` object
|
||||
* @param tdef the `ObjectDefinition` that constructs this object and maintains some of its immutable fields
|
||||
* @param id the unique id that will be assigned to this entity
|
||||
* @param context a context to allow the object to properly set up `ActorSystem` functionality
|
||||
* @return the `Terminal` object
|
||||
*/
|
||||
def Constructor(tdef : RepairRearmSiloDefinition)(id : Int, context : ActorContext) : RepairRearmSilo = {
|
||||
import akka.actor.Props
|
||||
val obj = RepairRearmSilo(tdef)
|
||||
obj.Actor = context.actorOf(Props(classOf[RepairRearmControl], obj), s"${tdef.Name}_$id")
|
||||
obj
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.serverobject.terminals
|
||||
|
||||
import net.psforever.objects.Player
|
||||
import net.psforever.packet.game.ItemTransactionMessage
|
||||
|
||||
class RepairRearmSiloDefinition(objectId : Int) extends EquipmentTerminalDefinition(objectId) {
|
||||
Name = "repair_silo"
|
||||
|
||||
private val buyFunc : (Player, ItemTransactionMessage)=>Terminal.Exchange = EquipmentTerminalDefinition.Buy(Map.empty, Map.empty, Map.empty)
|
||||
|
||||
override def Buy(player: Player, msg : ItemTransactionMessage) : Terminal.Exchange = buyFunc(player, msg)
|
||||
|
||||
override def Loadout(player : Player, msg : ItemTransactionMessage) : Terminal.Exchange = {
|
||||
if(msg.item_page == 4) { //Favorites tab
|
||||
player.LoadLoadout(msg.unk1) match {
|
||||
case Some(loadout) =>
|
||||
Terminal.VehicleLoadout(Nil, Nil)
|
||||
case None =>
|
||||
Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
else {
|
||||
Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -190,17 +190,19 @@ object Terminal {
|
|||
*/
|
||||
final case class InfantryLoadout(exosuit : ExoSuitType.Value, subtype : Int = 0, holsters : List[InventoryItem], inventory : List[InventoryItem]) extends Exchange
|
||||
|
||||
final case class VehicleLoadout(weapons : List[InventoryItem], inventory : List[InventoryItem]) extends Exchange
|
||||
|
||||
/**
|
||||
* Start the special effects caused by a proximity-base service.
|
||||
* @param terminal the proximity-based unit
|
||||
*/
|
||||
final case class StartProximityEffect(terminal : ProximityTerminal) extends Exchange
|
||||
final case class StartProximityEffect(terminal : Terminal with ProximityUnit) extends Exchange
|
||||
|
||||
/**
|
||||
* Stop the special effects caused by a proximity-base service.
|
||||
* @param terminal the proximity-based unit
|
||||
*/
|
||||
final case class StopProximityEffect(terminal : ProximityTerminal) extends Exchange
|
||||
final case class StopProximityEffect(terminal : Terminal with ProximityUnit) extends Exchange
|
||||
|
||||
/**
|
||||
* Overloaded constructor.
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ class TerminalControl(term : Terminal) extends Actor with FactionAffinityBehavio
|
|||
case Terminal.Request(player, msg) =>
|
||||
sender ! Terminal.TerminalMessage(player, msg, term.Request(player, msg))
|
||||
|
||||
case _ =>
|
||||
sender ! Terminal.NoDeal()
|
||||
case _ => ;
|
||||
}
|
||||
|
||||
override def toString : String = term.Definition.Name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue