mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-01-20 02:24:45 +00:00
moved terminals, doors, and locks, into their own package; iff panels hack and doors open
This commit is contained in:
parent
3dd2d72117
commit
1c41972d69
|
|
@ -3,11 +3,12 @@ package net.psforever.objects
|
|||
|
||||
import net.psforever.objects.definition._
|
||||
import net.psforever.objects.definition.converter.{CommandDetonaterConverter, LockerContainerConverter, REKConverter}
|
||||
import net.psforever.objects.doors.{DoorDefinition, IFFLockDefinition}
|
||||
import net.psforever.objects.serverobject.doors.DoorDefinition
|
||||
import net.psforever.objects.equipment.CItem.DeployedItem
|
||||
import net.psforever.objects.equipment._
|
||||
import net.psforever.objects.inventory.InventoryTile
|
||||
import net.psforever.objects.terminals.{CertTerminalDefinition, OrderTerminalDefinition}
|
||||
import net.psforever.objects.serverobject.locks.IFFLockDefinition
|
||||
import net.psforever.objects.serverobject.terminals.{CertTerminalDefinition, OrderTerminalDefinition}
|
||||
import net.psforever.types.PlanetSideEmpire
|
||||
|
||||
object GlobalDefinitions {
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.doors
|
||||
|
||||
import net.psforever.objects.{GlobalDefinitions, PlanetSideGameObject}
|
||||
import net.psforever.types.PlanetSideEmpire
|
||||
|
||||
class IFFLock extends PlanetSideGameObject {
|
||||
private var hackedBy : Option[PlanetSideEmpire.Value] = None
|
||||
|
||||
def Hacker : Option[PlanetSideEmpire.Value] = hackedBy
|
||||
|
||||
def Hacker_=(hacker : PlanetSideEmpire.Value) : Option[PlanetSideEmpire.Value] = {
|
||||
Hacker = Some(hacker)
|
||||
}
|
||||
|
||||
def Hacker_=(hacker : Option[PlanetSideEmpire.Value]) : Option[PlanetSideEmpire.Value] = {
|
||||
hackedBy = hacker
|
||||
Hacker
|
||||
}
|
||||
|
||||
def Definition : IFFLockDefinition = GlobalDefinitions.external_lock
|
||||
}
|
||||
|
||||
object IFFLock {
|
||||
def apply() : IFFLock = {
|
||||
new IFFLock
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.serverobject
|
||||
|
||||
import net.psforever.objects.Player
|
||||
import net.psforever.types.PlanetSideEmpire
|
||||
|
||||
//temporary location for these temporary messages
|
||||
object CommonMessages {
|
||||
final case class Hack(player : Player)
|
||||
final case class ClearHack()
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.serverobject
|
||||
|
||||
import akka.actor.ActorRef
|
||||
import net.psforever.objects.PlanetSideGameObject
|
||||
|
||||
abstract class PlanetSideServerObject extends PlanetSideGameObject {
|
||||
private var actor = ActorRef.noSender
|
||||
|
||||
def Actor : ActorRef = actor
|
||||
|
||||
def Actor_=(control : ActorRef) : ActorRef = {
|
||||
if(actor == ActorRef.noSender) {
|
||||
actor = control
|
||||
}
|
||||
actor
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.zones
|
||||
package net.psforever.objects.serverobject.builders
|
||||
|
||||
import net.psforever.objects.doors.{Door, DoorDefinition}
|
||||
import akka.actor.Props
|
||||
import net.psforever.objects.serverobject.doors.{Door, DoorControl, DoorDefinition}
|
||||
|
||||
/**
|
||||
* Wrapper `Class` designed to instantiate a `Door` server object.
|
||||
|
|
@ -15,7 +16,7 @@ class DoorObjectBuilder(private val ddef : DoorDefinition, private val id : Int)
|
|||
def Build(implicit context : ActorContext, guid : NumberPoolHub) : Door = {
|
||||
val obj = Door(ddef)
|
||||
guid.register(obj, id) //non-Actor GUID registration
|
||||
obj.Actor //it's necessary to register beforehand because the Actor name utilizes the GUID
|
||||
obj.Actor = context.actorOf(Props(classOf[DoorControl], obj), s"${ddef.Name}_${obj.GUID.guid}")
|
||||
obj
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.zones
|
||||
package net.psforever.objects.serverobject.builders
|
||||
|
||||
import net.psforever.objects.doors.{IFFLock, IFFLockDefinition}
|
||||
import akka.actor.Props
|
||||
import net.psforever.objects.serverobject.locks.{IFFLock, IFFLockControl, IFFLockDefinition}
|
||||
|
||||
/**
|
||||
* Wrapper `Class` designed to instantiate a `Door` server object.
|
||||
|
|
@ -15,6 +16,7 @@ class IFFLockObjectBuilder(private val idef : IFFLockDefinition, private val id
|
|||
def Build(implicit context : ActorContext, guid : NumberPoolHub) : IFFLock = {
|
||||
val obj = IFFLock()
|
||||
guid.register(obj, id) //non-Actor GUID registration
|
||||
obj.Actor = context.actorOf(Props(classOf[IFFLockControl], obj), s"${idef.Name}_${obj.GUID.guid}")
|
||||
obj
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.zones
|
||||
package net.psforever.objects.serverobject.builders
|
||||
|
||||
import akka.actor.ActorContext
|
||||
import net.psforever.objects.PlanetSideGameObject
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.zones
|
||||
package net.psforever.objects.serverobject.builders
|
||||
|
||||
import net.psforever.objects.terminals.{Terminal, TerminalDefinition}
|
||||
import akka.actor.Props
|
||||
import net.psforever.objects.serverobject.terminals.{Terminal, TerminalControl, TerminalDefinition}
|
||||
|
||||
/**
|
||||
* Wrapper `Class` designed to instantiate a `Terminal` server object.
|
||||
|
|
@ -15,7 +16,7 @@ class TerminalObjectBuilder(private val tdef : TerminalDefinition, private val i
|
|||
def Build(implicit context : ActorContext, guid : NumberPoolHub) : Terminal = {
|
||||
val obj = Terminal(tdef)
|
||||
guid.register(obj, id) //non-Actor GUID registration
|
||||
obj.Actor //it's necessary to register beforehand because the Actor name utilizes the GUID
|
||||
obj.Actor = context.actorOf(Props(classOf[TerminalControl], obj), s"${tdef.Name}_${obj.GUID.guid}")
|
||||
obj
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.doors
|
||||
package net.psforever.objects.serverobject.doors
|
||||
|
||||
import net.psforever.types.PlanetSideEmpire
|
||||
|
||||
|
|
@ -1,25 +1,15 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.doors
|
||||
package net.psforever.objects.serverobject.doors
|
||||
|
||||
import akka.actor.{ActorContext, ActorRef, Props}
|
||||
import net.psforever.objects.{PlanetSideGameObject, Player}
|
||||
import net.psforever.objects.serverobject.PlanetSideServerObject
|
||||
import net.psforever.objects.Player
|
||||
import net.psforever.packet.game.UseItemMessage
|
||||
|
||||
/**
|
||||
* na
|
||||
* @param ddef the `ObjectDefinition` that constructs this object and maintains some of its immutable fields
|
||||
*/
|
||||
class Door(ddef : DoorDefinition) extends PlanetSideGameObject {
|
||||
/** Internal reference to the `Actor` for this `Door`, sets up by this `Door`. */
|
||||
private var actor = ActorRef.noSender
|
||||
|
||||
def Actor(implicit context : ActorContext) : ActorRef = {
|
||||
if(actor == ActorRef.noSender) {
|
||||
actor = context.actorOf(Props(classOf[DoorControl], this), s"${ddef.Name}_${GUID.guid}")
|
||||
}
|
||||
actor
|
||||
}
|
||||
|
||||
class Door(ddef : DoorDefinition) extends PlanetSideServerObject {
|
||||
private var openState : Boolean = false
|
||||
private var lockState : Boolean = false
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.doors
|
||||
package net.psforever.objects.serverobject.doors
|
||||
|
||||
import akka.actor.{Actor, Cancellable}
|
||||
|
||||
|
|
@ -8,12 +8,9 @@ import akka.actor.{Actor, Cancellable}
|
|||
* @param door the `Door` object being governed
|
||||
*/
|
||||
class DoorControl(door : Door) extends Actor {
|
||||
private var doorCloser : Cancellable = DoorControl.DefaultCloser
|
||||
|
||||
def receive : Receive = {
|
||||
case Door.Use(player, msg) =>
|
||||
sender ! Door.DoorMessage(player, msg, door.Use(player, msg))
|
||||
//doorCloser = context.system.scheduler.scheduleOnce(5000L, sender, Door.DoorMessage())
|
||||
case _ =>
|
||||
sender ! Door.NoEvent()
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.doors
|
||||
package net.psforever.objects.serverobject.doors
|
||||
|
||||
import net.psforever.objects.definition.ObjectDefinition
|
||||
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.serverobject.locks
|
||||
|
||||
import net.psforever.objects.{GlobalDefinitions, Player}
|
||||
import net.psforever.objects.serverobject.PlanetSideServerObject
|
||||
import net.psforever.types.{PlanetSideEmpire, Vector3}
|
||||
|
||||
class IFFLock extends PlanetSideServerObject {
|
||||
private var hackedBy : Option[(Player, Vector3)] = None
|
||||
|
||||
def HackedBy : Option[(Player, Vector3)] = hackedBy
|
||||
|
||||
def HackedBy_=(agent : Player) : Option[(Player, Vector3)] = HackedBy_=(Some(agent))
|
||||
|
||||
def HackedBy_=(agent : Option[Player]) : Option[(Player, Vector3)] = {
|
||||
hackedBy match {
|
||||
case None =>
|
||||
if(agent.isDefined) {
|
||||
hackedBy = Some(agent.get, agent.get.Position)
|
||||
}
|
||||
case Some(_) =>
|
||||
if(agent.isEmpty) {
|
||||
hackedBy = None
|
||||
}
|
||||
else if(agent.get.Faction != hackedBy.get._1.Faction) {
|
||||
hackedBy = Some(agent.get, agent.get.Position) //overwrite
|
||||
}
|
||||
}
|
||||
HackedBy
|
||||
}
|
||||
|
||||
def Definition : IFFLockDefinition = GlobalDefinitions.external_lock
|
||||
}
|
||||
|
||||
object IFFLock {
|
||||
def apply() : IFFLock = {
|
||||
new IFFLock
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.serverobject.locks
|
||||
|
||||
import akka.actor.{Actor, Cancellable}
|
||||
import net.psforever.objects.serverobject.CommonMessages
|
||||
import net.psforever.objects.serverobject.doors.Door
|
||||
|
||||
class IFFLockControl(lock : IFFLock) extends Actor {
|
||||
def receive : Receive = {
|
||||
case CommonMessages.Hack(player) =>
|
||||
lock.HackedBy = player
|
||||
case CommonMessages.ClearHack() =>
|
||||
lock.HackedBy = None
|
||||
case _ =>
|
||||
sender ! Door.NoEvent()
|
||||
}
|
||||
}
|
||||
|
||||
object IFFLockControl {
|
||||
final val DefaultCloser : Cancellable = new Cancellable() {
|
||||
override def cancel : Boolean = true
|
||||
override def isCancelled : Boolean = true
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.doors
|
||||
package net.psforever.objects.serverobject.locks
|
||||
|
||||
import net.psforever.objects.definition.ObjectDefinition
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.terminals
|
||||
package net.psforever.objects.serverobject.terminals
|
||||
|
||||
import net.psforever.objects.Player
|
||||
import net.psforever.packet.game.ItemTransactionMessage
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.terminals
|
||||
package net.psforever.objects.serverobject.terminals
|
||||
|
||||
import net.psforever.objects.InfantryLoadout.Simplification
|
||||
import net.psforever.objects.{Player, Tool}
|
||||
|
|
@ -1,13 +1,16 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.terminals
|
||||
package net.psforever.objects.serverobject.terminals
|
||||
|
||||
import net.psforever.objects.Player
|
||||
import net.psforever.types.PlanetSideEmpire
|
||||
|
||||
//temporary location for these temporary messages
|
||||
object TemporaryTerminalMessages {
|
||||
//TODO send original packets along with these messages
|
||||
final case class UseItem(player : Player)
|
||||
final case class Convert(faction : PlanetSideEmpire.Value)
|
||||
final case class Hacked(faction : Option[PlanetSideEmpire.Value])
|
||||
final case class Hack(player : Player)
|
||||
final case class ClearHack()
|
||||
final case class Damaged(dm : Int)
|
||||
final case class Repaired(rep : Int)
|
||||
}
|
||||
|
|
@ -1,43 +1,45 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.terminals
|
||||
package net.psforever.objects.serverobject.terminals
|
||||
|
||||
import akka.actor.{ActorContext, ActorRef, Props}
|
||||
import net.psforever.objects.{PlanetSideGameObject, Player}
|
||||
import net.psforever.objects.Player
|
||||
import net.psforever.objects.equipment.Equipment
|
||||
import net.psforever.objects.inventory.InventoryItem
|
||||
import net.psforever.objects.serverobject.PlanetSideServerObject
|
||||
import net.psforever.packet.game.ItemTransactionMessage
|
||||
import net.psforever.types.{ExoSuitType, PlanetSideEmpire, TransactionType}
|
||||
import net.psforever.types.{ExoSuitType, PlanetSideEmpire, TransactionType, Vector3}
|
||||
|
||||
/**
|
||||
* na
|
||||
* @param tdef the `ObjectDefinition` that constructs this object and maintains some of its immutable fields
|
||||
*/
|
||||
class Terminal(tdef : TerminalDefinition) extends PlanetSideGameObject {
|
||||
/** Internal reference to the `Actor` for this `Terminal`, sets up by this `Terminal`. */
|
||||
private var actor = ActorRef.noSender
|
||||
|
||||
/**
|
||||
* Get access to the internal `TerminalControl` `Actor` for this `Terminal`.
|
||||
* If called for the first time, create the said `Actor`.
|
||||
* Must be called only after the globally unique identifier has been set.
|
||||
* @param context the `ActorContext` under which this `Terminal`'s `Actor` will be created
|
||||
* @return the `Terminal`'s `Actor`
|
||||
*/
|
||||
def Actor(implicit context : ActorContext) : ActorRef = {
|
||||
if(actor == ActorRef.noSender) {
|
||||
actor = context.actorOf(Props(classOf[TerminalControl], this), s"${tdef.Name}_${GUID.guid}")
|
||||
}
|
||||
actor
|
||||
}
|
||||
|
||||
class Terminal(tdef : TerminalDefinition) extends PlanetSideServerObject {
|
||||
//the following fields and related methods are neither finalized no integrated; GOTO Request
|
||||
private var faction : PlanetSideEmpire.Value = PlanetSideEmpire.NEUTRAL
|
||||
private var hackedBy : Option[PlanetSideEmpire.Value] = None
|
||||
private var hackedBy : Option[(Player, Vector3)] = None
|
||||
private var health : Int = 100 //TODO not real health value
|
||||
|
||||
def Faction : PlanetSideEmpire.Value = faction
|
||||
|
||||
def HackedBy : Option[PlanetSideEmpire.Value] = hackedBy
|
||||
def HackedBy : Option[(Player, Vector3)] = hackedBy
|
||||
|
||||
def HackedBy_=(agent : Player) : Option[(Player, Vector3)] = HackedBy_=(Some(agent))
|
||||
|
||||
def HackedBy_=(agent : Option[Player]) : Option[(Player, Vector3)] = {
|
||||
hackedBy match {
|
||||
case None =>
|
||||
if(agent.isDefined) {
|
||||
hackedBy = Some(agent.get, agent.get.Position)
|
||||
}
|
||||
case Some(_) =>
|
||||
if(agent.isEmpty) {
|
||||
hackedBy = None
|
||||
}
|
||||
else if(agent.get.Faction != hackedBy.get._1.Faction) {
|
||||
hackedBy = Some(agent.get, agent.get.Position) //overwrite
|
||||
}
|
||||
}
|
||||
HackedBy
|
||||
}
|
||||
|
||||
def Health : Int = health
|
||||
|
||||
|
|
@ -46,10 +48,6 @@ class Terminal(tdef : TerminalDefinition) extends PlanetSideGameObject {
|
|||
faction = toFaction
|
||||
}
|
||||
|
||||
def HackedBy(toFaction : Option[PlanetSideEmpire.Value]) : Unit = {
|
||||
hackedBy = if(toFaction.contains(faction)) { None } else { toFaction }
|
||||
}
|
||||
|
||||
def Damaged(dam : Int) : Unit = {
|
||||
health = Math.max(0, Health - dam)
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.terminals
|
||||
package net.psforever.objects.serverobject.terminals
|
||||
|
||||
import akka.actor.Actor
|
||||
|
||||
|
|
@ -14,17 +14,11 @@ class TerminalControl(term : Terminal) extends Actor {
|
|||
case Terminal.Request(player, msg) =>
|
||||
sender ! Terminal.TerminalMessage(player, msg, term.Request(player, msg))
|
||||
|
||||
case TemporaryTerminalMessages.Convert(fact) =>
|
||||
term.Convert(fact)
|
||||
case TemporaryTerminalMessages.Hack(player) =>
|
||||
term.HackedBy = player
|
||||
|
||||
case TemporaryTerminalMessages.Hacked(fact) =>
|
||||
term.HackedBy(fact)
|
||||
|
||||
case TemporaryTerminalMessages.Damaged(dam) =>
|
||||
term.Damaged(dam)
|
||||
|
||||
case TemporaryTerminalMessages.Repaired(rep) =>
|
||||
term.Repair(rep)
|
||||
case TemporaryTerminalMessages.ClearHack() =>
|
||||
term.HackedBy = None
|
||||
|
||||
case _ =>
|
||||
sender ! Terminal.NoDeal()
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.terminals
|
||||
package net.psforever.objects.serverobject.terminals
|
||||
|
||||
import net.psforever.objects._
|
||||
import net.psforever.objects.definition._
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
package net.psforever.objects.zones
|
||||
|
||||
import akka.actor.{ActorContext, ActorRef, Props}
|
||||
import net.psforever.objects.doors.Base
|
||||
import net.psforever.objects.serverobject.doors.Base
|
||||
import net.psforever.objects.{PlanetSideGameObject, Player}
|
||||
import net.psforever.objects.equipment.Equipment
|
||||
import net.psforever.objects.guid.NumberPoolHub
|
||||
|
|
@ -48,6 +48,10 @@ class Zone(private val zoneId : String, zoneMap : ZoneMap, zoneNumber : Int) {
|
|||
private val equipmentOnGround : ListBuffer[Equipment] = ListBuffer[Equipment]()
|
||||
/** Used by the `Zone` to coordinate `Equipment` dropping and collection requests. */
|
||||
private var ground : ActorRef = ActorRef.noSender
|
||||
/** */
|
||||
private var doors : ActorRef = ActorRef.noSender
|
||||
/** */
|
||||
private var events : ActorRef = ActorRef.noSender
|
||||
|
||||
private var bases : List[Base] = List()
|
||||
|
||||
|
|
@ -68,6 +72,7 @@ class Zone(private val zoneId : String, zoneMap : ZoneMap, zoneNumber : Int) {
|
|||
implicit val guid : NumberPoolHub = this.guid //passed into builderObject.Build implicitly
|
||||
accessor = context.actorOf(Props(classOf[UniqueNumberSystem], guid, UniqueNumberSystem.AllocateNumberPoolActors(guid)), s"$Id-uns")
|
||||
ground = context.actorOf(Props(classOf[ZoneGroundActor], equipmentOnGround), s"$Id-ground")
|
||||
doors = context.actorOf(Props(classOf[ZoneDoorActor], this), s"$Id-doors")
|
||||
|
||||
Map.LocalObjects.foreach({ builderObject =>
|
||||
builderObject.Build
|
||||
|
|
@ -174,6 +179,17 @@ class Zone(private val zoneId : String, zoneMap : ZoneMap, zoneNumber : Int) {
|
|||
*/
|
||||
def Ground : ActorRef = ground
|
||||
|
||||
def Doors : ActorRef = doors
|
||||
|
||||
def Events : ActorRef = events
|
||||
|
||||
def Events_=(zoneActor : ActorRef) : ActorRef = {
|
||||
if(events == ActorRef.noSender) {
|
||||
events = zoneActor
|
||||
}
|
||||
Events
|
||||
}
|
||||
|
||||
def MakeBases(num : Int) : List[Base] = {
|
||||
bases = (0 to num).map(id => new Base(id)).toList
|
||||
bases
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
package net.psforever.objects.zones
|
||||
|
||||
import akka.actor.Actor
|
||||
import net.psforever.objects.serverobject.locks.IFFLock
|
||||
|
||||
/**
|
||||
* na
|
||||
|
|
@ -34,8 +35,8 @@ class ZoneActor(zone : Zone) extends Actor {
|
|||
}
|
||||
})
|
||||
|
||||
//check door to lock association
|
||||
import net.psforever.objects.doors.{Door, IFFLock}
|
||||
//check door to locks association
|
||||
import net.psforever.objects.serverobject.doors.Door
|
||||
map.DoorToLock.foreach({ case((door_guid, lock_guid)) =>
|
||||
try {
|
||||
if(!guid(door_guid).get.isInstanceOf[Door]) {
|
||||
|
|
@ -48,12 +49,12 @@ class ZoneActor(zone : Zone) extends Actor {
|
|||
}
|
||||
try {
|
||||
if(!guid(lock_guid).get.isInstanceOf[IFFLock]) {
|
||||
slog.error(s"expected id $lock_guid to be an IFF lock, but it was not")
|
||||
slog.error(s"expected id $lock_guid to be an IFF locks, but it was not")
|
||||
}
|
||||
}
|
||||
catch {
|
||||
case _ : Exception =>
|
||||
slog.error(s"expected an IFF lock, but looking for uninitialized object $lock_guid")
|
||||
slog.error(s"expected an IFF locks, but looking for uninitialized object $lock_guid")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.doors
|
||||
package net.psforever.objects.zones
|
||||
|
||||
import akka.actor.{Actor, ActorRef, Cancellable}
|
||||
import akka.actor.{Actor, Cancellable}
|
||||
import net.psforever.packet.game.PlanetSideGUID
|
||||
import scala.concurrent.duration._
|
||||
|
||||
import scala.annotation.tailrec
|
||||
import scala.concurrent.duration._
|
||||
|
||||
class DoorCloseControl(implicit val environment : ActorRef) extends Actor {
|
||||
import DoorCloseControl._
|
||||
class ZoneDoorActor(implicit val zone : Zone) extends Actor {
|
||||
import ZoneDoorActor._
|
||||
private var doorCloserTrigger : Cancellable = DefaultCloser
|
||||
private var openDoors : List[DoorEntry] = Nil
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ class DoorCloseControl(implicit val environment : ActorRef) extends Actor {
|
|||
openDoors = openDoors :+ DoorEntry(guid, time)
|
||||
if(doorCloserTrigger.isCancelled) {
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
doorCloserTrigger = context.system.scheduler.scheduleOnce(timeout, self, DoorCloseControl.CloseTheDoor())
|
||||
doorCloserTrigger = context.system.scheduler.scheduleOnce(timeout, self, ZoneDoorActor.CloseTheDoor())
|
||||
}
|
||||
|
||||
case CloseTheDoor() =>
|
||||
|
|
@ -25,9 +25,9 @@ class DoorCloseControl(implicit val environment : ActorRef) extends Actor {
|
|||
val now : Long = System.nanoTime
|
||||
recursiveCloseDoors(openDoors.iterator, now) match {
|
||||
case entry :: rest =>
|
||||
openDoors = entry :: rest
|
||||
openDoors = rest
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
doorCloserTrigger = context.system.scheduler.scheduleOnce((now - entry.opened_at_time + timeout_time)*1000 milliseconds, self, DoorCloseControl.CloseTheDoor())
|
||||
doorCloserTrigger = context.system.scheduler.scheduleOnce((now - entry.opened_at_time + timeout_time)*1000 milliseconds, self, ZoneDoorActor.CloseTheDoor())
|
||||
case Nil =>
|
||||
openDoors = Nil
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ class DoorCloseControl(implicit val environment : ActorRef) extends Actor {
|
|||
}
|
||||
}
|
||||
|
||||
object DoorCloseControl {
|
||||
object ZoneDoorActor {
|
||||
private final val timeout_time = 5000
|
||||
private final val timeout : FiniteDuration = timeout_time milliseconds
|
||||
|
||||
|
|
@ -61,9 +61,9 @@ object DoorCloseControl {
|
|||
override def isCancelled : Boolean = true
|
||||
}
|
||||
|
||||
private final case class DoorEntry(door_guid : PlanetSideGUID, opened_at_time : Long)
|
||||
|
||||
final case class DoorIsOpen(door_guid : PlanetSideGUID, opened_at_time : Long = System.nanoTime())
|
||||
|
||||
private final case class DoorEntry(door_guid : PlanetSideGUID, opened_at_time : Long)
|
||||
|
||||
private final case class CloseTheDoor()
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.zones
|
||||
|
||||
import net.psforever.objects.serverobject.builders.ServerObjectBuilder
|
||||
|
||||
/**
|
||||
* The fixed instantiation and relation of a series of server objects.<br>
|
||||
* <br>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
import akka.actor.Actor
|
||||
import net.psforever.objects.equipment.Equipment
|
||||
import net.psforever.objects.serverobject.PlanetSideServerObject
|
||||
import net.psforever.packet.game.objectcreate.ConstructorData
|
||||
import net.psforever.types.ExoSuitType
|
||||
import net.psforever.packet.game.{PlanetSideGUID, PlayerStateMessageUpstream}
|
||||
|
|
@ -13,6 +14,7 @@ object AvatarAction {
|
|||
//final case class DropItem(pos : Vector3, orient : Vector3, item : PlanetSideGUID) extends Action
|
||||
final case class EquipmentInHand(player_guid : PlanetSideGUID, slot : Int, item : Equipment) extends Action
|
||||
final case class EquipmentOnGround(player_guid : PlanetSideGUID, pos : Vector3, orient : Vector3, item : Equipment) extends Action
|
||||
final case class Hack(player_guid : PlanetSideGUID, target : PlanetSideServerObject, unk1 : Long, unk2 : Long = 8L) extends Action
|
||||
final case class LoadPlayer(player_guid : PlanetSideGUID, pdata : ConstructorData) extends Action
|
||||
// final case class LoadMap(msg : PlanetSideGUID) extends Action
|
||||
// final case class unLoadMap(msg : PlanetSideGUID) extends Action
|
||||
|
|
@ -34,6 +36,7 @@ object AvatarServiceResponse {
|
|||
//final case class DropItem(pos : Vector3, orient : Vector3, item : PlanetSideGUID) extends Response
|
||||
final case class EquipmentInHand(slot : Int, item : Equipment) extends Response
|
||||
final case class EquipmentOnGround(pos : Vector3, orient : Vector3, item : Equipment) extends Response
|
||||
final case class Hack(target_guid : PlanetSideGUID, unk1 : Long, unk2 : Long = 8L) extends Response
|
||||
final case class LoadPlayer(pdata : ConstructorData) extends Response
|
||||
// final case class unLoadMap() extends Response
|
||||
// final case class LoadMap() extends Response
|
||||
|
|
@ -93,6 +96,10 @@ class AvatarService extends Actor {
|
|||
AvatarEvents.publish(
|
||||
AvatarServiceResponse(s"/$forChannel/Avatar", player_guid, AvatarServiceResponse.EquipmentOnGround(pos, orient, obj))
|
||||
)
|
||||
case AvatarAction.Hack(player_guid, target, unk1, unk2) =>
|
||||
AvatarEvents.publish(
|
||||
AvatarServiceResponse(s"/$forChannel/Avatar", player_guid, AvatarServiceResponse.Hack(target.GUID, unk1, unk2))
|
||||
)
|
||||
case AvatarAction.LoadPlayer(player_guid, pdata) =>
|
||||
AvatarEvents.publish(
|
||||
AvatarServiceResponse(s"/$forChannel/Avatar", player_guid, AvatarServiceResponse.LoadPlayer(pdata))
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import com.typesafe.config.ConfigFactory
|
|||
import net.psforever.crypto.CryptoInterface
|
||||
import net.psforever.objects.zones._
|
||||
import net.psforever.objects.guid.TaskResolver
|
||||
import net.psforever.objects.serverobject.builders.{DoorObjectBuilder, IFFLockObjectBuilder, TerminalObjectBuilder}
|
||||
import org.slf4j
|
||||
import org.fusesource.jansi.Ansi._
|
||||
import org.fusesource.jansi.Ansi.Color._
|
||||
|
|
|
|||
|
|
@ -11,14 +11,16 @@ import org.log4s.MDC
|
|||
import MDCContextAware.Implicits._
|
||||
import ServiceManager.Lookup
|
||||
import net.psforever.objects._
|
||||
import net.psforever.objects.doors.{Door, IFFLock}
|
||||
import net.psforever.objects.serverobject.doors.Door
|
||||
import net.psforever.objects.zones.{InterstellarCluster, Zone}
|
||||
import net.psforever.objects.entity.IdentifiableEntity
|
||||
import net.psforever.objects.equipment._
|
||||
import net.psforever.objects.guid.{Task, TaskResolver}
|
||||
import net.psforever.objects.guid.actor.{Register, Unregister}
|
||||
import net.psforever.objects.inventory.{GridInventory, InventoryItem}
|
||||
import net.psforever.objects.terminals.Terminal
|
||||
import net.psforever.objects.serverobject.{CommonMessages, PlanetSideServerObject}
|
||||
import net.psforever.objects.serverobject.locks.IFFLock
|
||||
import net.psforever.objects.serverobject.terminals.Terminal
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import net.psforever.types._
|
||||
|
||||
|
|
@ -140,6 +142,11 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
)
|
||||
}
|
||||
|
||||
case AvatarServiceResponse.Hack(target_guid, unk1, unk2) =>
|
||||
if(player.GUID != guid) {
|
||||
sendResponse(PacketCoding.CreateGamePacket(0, HackMessage(0, target_guid.guid, guid.guid, 100, unk1, 6, unk2)))
|
||||
}
|
||||
|
||||
case AvatarServiceResponse.LoadPlayer(pdata) =>
|
||||
if(player.GUID != guid) {
|
||||
sendResponse(
|
||||
|
|
@ -566,6 +573,9 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
if(progressBarVal > 100) {
|
||||
progressBarValue = None
|
||||
log.info(s"We've hacked the item $target! Now what?")
|
||||
sendResponse(PacketCoding.CreateGamePacket(0, HackMessage(0, target.GUID.guid, player.GUID.guid, 100, 1114636288, 6, 8L)))
|
||||
target.Actor ! CommonMessages.Hack(tplayer)
|
||||
avatarService ! AvatarServiceMessage(tplayer.Continent, AvatarAction.Hack(tplayer.GUID, target, 1114636288))
|
||||
//TODO now what?
|
||||
}
|
||||
else {
|
||||
|
|
@ -994,14 +1004,19 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
case Some(door : Door) =>
|
||||
continent.Map.DoorToLock.get(object_guid.guid) match { //check for IFFLock
|
||||
case Some(lock_guid) =>
|
||||
val lock_hacked = continent.GUID(lock_guid).get.asInstanceOf[IFFLock].Hacker.contains(player.Faction)
|
||||
val lock_hacked = continent.GUID(lock_guid).get.asInstanceOf[IFFLock].HackedBy match {
|
||||
case Some((tplayer, _)) =>
|
||||
tplayer.Faction == player.Faction
|
||||
case None =>
|
||||
false
|
||||
}
|
||||
continent.Map.ObjectToBase.get(lock_guid) match { //check for associated base
|
||||
case Some(base_id) =>
|
||||
if(continent.Base(base_id).get.Faction == player.Faction || lock_hacked) { //either base allegiance aligns or lock is hacked
|
||||
if(continent.Base(base_id).get.Faction == player.Faction || lock_hacked) { //either base allegiance aligns or locks is hacked
|
||||
door.Actor ! Door.Use(player, msg)
|
||||
}
|
||||
case None =>
|
||||
if(lock_hacked) { //is lock hacked?
|
||||
if(lock_hacked) { //is locks hacked?
|
||||
door.Actor ! Door.Use(player, msg)
|
||||
}
|
||||
}
|
||||
|
|
@ -1614,7 +1629,7 @@ object WorldSessionActor {
|
|||
private final case class PlayerFailedToLoad(tplayer : Player)
|
||||
private final case class ListAccountCharacters()
|
||||
private final case class SetCurrentAvatar(tplayer : Player)
|
||||
private final case class ItemHacking(tplayer : Player, target : PlanetSideGameObject, tool_guid : PlanetSideGUID, delta : Float)
|
||||
private final case class ItemHacking(tplayer : Player, target : PlanetSideServerObject, tool_guid : PlanetSideGUID, delta : Float)
|
||||
|
||||
/**
|
||||
* A placeholder `Cancellable` object.
|
||||
|
|
|
|||
Loading…
Reference in a new issue