mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-04-29 07:45:26 +00:00
Add Hackable trait to all terminals / IFF locks / lockers
This commit is contained in:
parent
fdf05337fd
commit
c6eff22df7
7 changed files with 68 additions and 76 deletions
|
|
@ -0,0 +1,41 @@
|
||||||
|
package net.psforever.objects.serverobject.hackable
|
||||||
|
|
||||||
|
import net.psforever.objects.Player
|
||||||
|
import net.psforever.packet.game.PlanetSideGUID
|
||||||
|
import net.psforever.types.Vector3
|
||||||
|
|
||||||
|
trait Hackable {
|
||||||
|
/** An entry that maintains a reference to the `Player`, and the player's GUID and location when the message was received. */
|
||||||
|
private var hackedBy : Option[(Player, PlanetSideGUID, Vector3)] = None
|
||||||
|
|
||||||
|
def HackedBy : Option[(Player, PlanetSideGUID, Vector3)] = hackedBy
|
||||||
|
|
||||||
|
def HackedBy_=(agent : Player) : Option[(Player, PlanetSideGUID, Vector3)] = HackedBy_=(Some(agent))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the hack state of this object by recording important information about the player that caused it.
|
||||||
|
* Set the hack state if there is no current hack state.
|
||||||
|
* Override the hack state with a new hack state if the new user has different faction affiliation.
|
||||||
|
* @param agent a `Player`, or no player
|
||||||
|
* @return the player hack entry
|
||||||
|
*/
|
||||||
|
def HackedBy_=(agent : Option[Player]) : Option[(Player, PlanetSideGUID, Vector3)] = {
|
||||||
|
hackedBy match {
|
||||||
|
case None =>
|
||||||
|
//set the hack state if there is no current hack state
|
||||||
|
if(agent.isDefined) {
|
||||||
|
hackedBy = Some(agent.get, agent.get.GUID, agent.get.Position)
|
||||||
|
}
|
||||||
|
case Some(_) =>
|
||||||
|
//clear the hack state
|
||||||
|
if(agent.isEmpty) {
|
||||||
|
hackedBy = None
|
||||||
|
}
|
||||||
|
//override the hack state with a new hack state if the new user has different faction affiliation
|
||||||
|
else if(agent.get.Faction != hackedBy.get._1.Faction) {
|
||||||
|
hackedBy = Some(agent.get, agent.get.GUID, agent.get.Position)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HackedBy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
// Copyright (c) 2017 PSForever
|
// Copyright (c) 2017 PSForever
|
||||||
package net.psforever.objects.serverobject.locks
|
package net.psforever.objects.serverobject.locks
|
||||||
|
|
||||||
import net.psforever.objects.Player
|
import net.psforever.objects.serverobject.hackable.Hackable
|
||||||
import net.psforever.objects.serverobject.structures.Amenity
|
import net.psforever.objects.serverobject.structures.Amenity
|
||||||
import net.psforever.packet.game.PlanetSideGUID
|
|
||||||
import net.psforever.types.Vector3
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A structure-owned server object that is a "door lock."<br>
|
* A structure-owned server object that is a "door lock."<br>
|
||||||
|
|
@ -15,43 +13,7 @@ import net.psforever.types.Vector3
|
||||||
* The `IFFLock` is ideally associated with a server map object - a `Door` - to which it acts as a gatekeeper.
|
* The `IFFLock` is ideally associated with a server map object - a `Door` - to which it acts as a gatekeeper.
|
||||||
* @param idef the `ObjectDefinition` that constructs this object and maintains some of its immutable fields
|
* @param idef the `ObjectDefinition` that constructs this object and maintains some of its immutable fields
|
||||||
*/
|
*/
|
||||||
class IFFLock(private val idef : IFFLockDefinition) extends Amenity {
|
class IFFLock(private val idef : IFFLockDefinition) extends Amenity with Hackable {
|
||||||
/**
|
|
||||||
* An entry that maintains a reference to the `Player`, and the player's GUID and location when the message was received.
|
|
||||||
*/
|
|
||||||
private var hackedBy : Option[(Player, PlanetSideGUID, Vector3)] = None
|
|
||||||
|
|
||||||
def HackedBy : Option[(Player, PlanetSideGUID, Vector3)] = hackedBy
|
|
||||||
|
|
||||||
def HackedBy_=(agent : Player) : Option[(Player, PlanetSideGUID, Vector3)] = HackedBy_=(Some(agent))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the hack state of this object by recording important information about the player that caused it.
|
|
||||||
* Set the hack state if there is no current hack state.
|
|
||||||
* Override the hack state with a new hack state if the new user has different faction affiliation.
|
|
||||||
* @param agent a `Player`, or no player
|
|
||||||
* @return the player hack entry
|
|
||||||
*/
|
|
||||||
def HackedBy_=(agent : Option[Player]) : Option[(Player, PlanetSideGUID, Vector3)] = {
|
|
||||||
hackedBy match {
|
|
||||||
case None =>
|
|
||||||
//set the hack state if there is no current hack state
|
|
||||||
if(agent.isDefined) {
|
|
||||||
hackedBy = Some(agent.get, agent.get.GUID, agent.get.Position)
|
|
||||||
}
|
|
||||||
case Some(_) =>
|
|
||||||
//clear the hack state
|
|
||||||
if(agent.isEmpty) {
|
|
||||||
hackedBy = None
|
|
||||||
}
|
|
||||||
//override the hack state with a new hack state if the new user has different faction affiliation
|
|
||||||
else if(agent.get.Faction != hackedBy.get._1.Faction) {
|
|
||||||
hackedBy = Some(agent.get, agent.get.GUID, agent.get.Position)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
HackedBy
|
|
||||||
}
|
|
||||||
|
|
||||||
def Definition : IFFLockDefinition = idef
|
def Definition : IFFLockDefinition = idef
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,10 @@ package net.psforever.objects.serverobject.mblocker
|
||||||
|
|
||||||
import akka.actor.{ActorContext, Props}
|
import akka.actor.{ActorContext, Props}
|
||||||
import net.psforever.objects.GlobalDefinitions
|
import net.psforever.objects.GlobalDefinitions
|
||||||
|
import net.psforever.objects.serverobject.hackable.Hackable
|
||||||
import net.psforever.objects.serverobject.structures.Amenity
|
import net.psforever.objects.serverobject.structures.Amenity
|
||||||
|
|
||||||
class Locker extends Amenity {
|
class Locker extends Amenity with Hackable {
|
||||||
def Definition : LockerDefinition = GlobalDefinitions.mb_locker
|
def Definition : LockerDefinition = GlobalDefinitions.mb_locker
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
package net.psforever.objects.serverobject.mblocker
|
package net.psforever.objects.serverobject.mblocker
|
||||||
|
|
||||||
import akka.actor.Actor
|
import akka.actor.Actor
|
||||||
|
import net.psforever.objects.serverobject.CommonMessages
|
||||||
import net.psforever.objects.serverobject.affinity.{FactionAffinity, FactionAffinityBehavior}
|
import net.psforever.objects.serverobject.affinity.{FactionAffinity, FactionAffinityBehavior}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -12,6 +13,11 @@ class LockerControl(locker : Locker) extends Actor with FactionAffinityBehavior.
|
||||||
def FactionObject : FactionAffinity = locker
|
def FactionObject : FactionAffinity = locker
|
||||||
|
|
||||||
def receive : Receive = checkBehavior.orElse {
|
def receive : Receive = checkBehavior.orElse {
|
||||||
|
case CommonMessages.Hack(player) =>
|
||||||
|
locker.HackedBy = player
|
||||||
|
|
||||||
|
case CommonMessages.ClearHack() =>
|
||||||
|
locker.HackedBy = None
|
||||||
case _ => ;
|
case _ => ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
package net.psforever.objects.serverobject.terminals
|
package net.psforever.objects.serverobject.terminals
|
||||||
|
|
||||||
import akka.actor.Actor
|
import akka.actor.Actor
|
||||||
|
import net.psforever.objects.serverobject.CommonMessages
|
||||||
import net.psforever.objects.serverobject.affinity.{FactionAffinity, FactionAffinityBehavior}
|
import net.psforever.objects.serverobject.affinity.{FactionAffinity, FactionAffinityBehavior}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -18,6 +19,11 @@ class ProximityTerminalControl(term : Terminal with ProximityUnit) extends Actor
|
||||||
def receive : Receive = checkBehavior
|
def receive : Receive = checkBehavior
|
||||||
.orElse(proximityBehavior)
|
.orElse(proximityBehavior)
|
||||||
.orElse {
|
.orElse {
|
||||||
|
case CommonMessages.Hack(player) =>
|
||||||
|
term.HackedBy = player
|
||||||
|
|
||||||
|
case CommonMessages.ClearHack() =>
|
||||||
|
term.HackedBy = None
|
||||||
case _ => ;
|
case _ => ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,48 +3,17 @@ package net.psforever.objects.serverobject.terminals
|
||||||
|
|
||||||
import net.psforever.objects.Player
|
import net.psforever.objects.Player
|
||||||
import net.psforever.objects.definition.VehicleDefinition
|
import net.psforever.objects.definition.VehicleDefinition
|
||||||
|
import net.psforever.objects.serverobject.hackable.Hackable
|
||||||
import net.psforever.objects.serverobject.structures.Amenity
|
import net.psforever.objects.serverobject.structures.Amenity
|
||||||
import net.psforever.packet.game.{ItemTransactionMessage, PlanetSideGUID}
|
import net.psforever.packet.game.{ItemTransactionMessage}
|
||||||
import net.psforever.types.{TransactionType, Vector3}
|
import net.psforever.types.{TransactionType}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A structure-owned server object that is a "terminal" that can be accessed for amenities and services.
|
* A structure-owned server object that is a "terminal" that can be accessed for amenities and services.
|
||||||
* @param tdef the `ObjectDefinition` that constructs this object and maintains some of its immutable fields
|
* @param tdef the `ObjectDefinition` that constructs this object and maintains some of its immutable fields
|
||||||
*/
|
*/
|
||||||
class Terminal(tdef : TerminalDefinition) extends Amenity {
|
class Terminal(tdef : TerminalDefinition) extends Amenity with Hackable {
|
||||||
/** An entry that maintains a reference to the `Player`, and the player's GUID and location when the message was received. */
|
|
||||||
private var hackedBy : Option[(Player, PlanetSideGUID, Vector3)] = None
|
|
||||||
|
|
||||||
def HackedBy : Option[(Player, PlanetSideGUID, Vector3)] = hackedBy
|
|
||||||
|
|
||||||
def HackedBy_=(agent : Player) : Option[(Player, PlanetSideGUID, Vector3)] = HackedBy_=(Some(agent))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the hack state of this object by recording important information about the player that caused it.
|
|
||||||
* Set the hack state if there is no current hack state.
|
|
||||||
* Override the hack state with a new hack state if the new user has different faction affiliation.
|
|
||||||
* @param agent a `Player`, or no player
|
|
||||||
* @return the player hack entry
|
|
||||||
*/
|
|
||||||
def HackedBy_=(agent : Option[Player]) : Option[(Player, PlanetSideGUID, Vector3)] = {
|
|
||||||
hackedBy match {
|
|
||||||
case None =>
|
|
||||||
//set the hack state if there is no current hack state
|
|
||||||
if(agent.isDefined) {
|
|
||||||
hackedBy = Some(agent.get, agent.get.GUID, agent.get.Position)
|
|
||||||
}
|
|
||||||
case Some(_) =>
|
|
||||||
//clear the hack state
|
|
||||||
if(agent.isEmpty) {
|
|
||||||
hackedBy = None
|
|
||||||
}
|
|
||||||
//override the hack state with a new hack state if the new user has different faction affiliation
|
|
||||||
else if(agent.get.Faction != hackedBy.get._1.Faction) {
|
|
||||||
hackedBy = Some(agent.get, agent.get.GUID, agent.get.Position)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
HackedBy
|
|
||||||
}
|
|
||||||
|
|
||||||
//the following fields and related methods are neither finalized nor integrated; GOTO Request
|
//the following fields and related methods are neither finalized nor integrated; GOTO Request
|
||||||
private var health : Int = 100 //TODO not real health value
|
private var health : Int = 100 //TODO not real health value
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
package net.psforever.objects.serverobject.terminals
|
package net.psforever.objects.serverobject.terminals
|
||||||
|
|
||||||
import akka.actor.Actor
|
import akka.actor.Actor
|
||||||
|
import net.psforever.objects.serverobject.CommonMessages
|
||||||
import net.psforever.objects.serverobject.affinity.{FactionAffinity, FactionAffinityBehavior}
|
import net.psforever.objects.serverobject.affinity.{FactionAffinity, FactionAffinityBehavior}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -15,6 +16,12 @@ class TerminalControl(term : Terminal) extends Actor with FactionAffinityBehavio
|
||||||
case Terminal.Request(player, msg) =>
|
case Terminal.Request(player, msg) =>
|
||||||
sender ! Terminal.TerminalMessage(player, msg, term.Request(player, msg))
|
sender ! Terminal.TerminalMessage(player, msg, term.Request(player, msg))
|
||||||
|
|
||||||
|
case CommonMessages.Hack(player) =>
|
||||||
|
term.HackedBy = player
|
||||||
|
|
||||||
|
case CommonMessages.ClearHack() =>
|
||||||
|
term.HackedBy = None
|
||||||
|
|
||||||
case _ => ;
|
case _ => ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue