Amenity positions + !hack refactor (#503)

* Add object positions for capture terminals and resource silos

* Small refactoring / renaming for !hack and capture terminals
This commit is contained in:
Mazo 2020-06-27 02:34:05 +01:00 committed by GitHub
parent e91e282d3a
commit d1e7d8f8e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 643 additions and 636 deletions

View file

@ -40,7 +40,7 @@ class ImplantTerminalMechControl(mech : ImplantTerminalMech) extends Actor
case CommonMessages.Use(player, Some(item : SimpleItem)) if item.Definition == GlobalDefinitions.remote_electronics_kit =>
//TODO setup certifications check
mech.Owner match {
case b : Building if (b.Faction != player.Faction || b.CaptureConsoleIsHacked) && mech.HackedBy.isEmpty =>
case b : Building if (b.Faction != player.Faction || b.CaptureTerminalIsHacked) && mech.HackedBy.isEmpty =>
sender ! CommonMessages.Progress(
GenericHackables.GetHackSpeed(player, mech),
GenericHackables.FinishHacking(mech, player, 3212836864L),

View file

@ -5,6 +5,7 @@ import akka.actor.{ActorContext, Props}
import net.psforever.objects.{GlobalDefinitions, Player}
import net.psforever.objects.serverobject.structures.Amenity
import net.psforever.packet.game.UseItemMessage
import net.psforever.types.Vector3
class ResourceSilo extends Amenity {
private var chargeLevel : Int = 0
@ -74,8 +75,9 @@ object ResourceSilo {
* not necessary for this object, but required by signature
* @return the `ResourceSilo` object
*/
def Constructor(id : Int, context : ActorContext) : ResourceSilo = {
def Constructor(pos: Vector3)(id : Int, context : ActorContext) : ResourceSilo = {
val obj = ResourceSilo()
obj.Position = pos
obj.Actor = context.actorOf(Props(classOf[ResourceSiloControl], obj), s"${obj.Definition.Name}_$id")
obj
}

View file

@ -72,14 +72,6 @@ class Building(private val name: String,
Faction
}
def CaptureConsoleIsHacked : Boolean = {
Amenities.find(x => x.isInstanceOf[CaptureTerminal]).asInstanceOf[Option[CaptureTerminal]] match {
case Some(obj: CaptureTerminal) =>
obj.HackedBy.isDefined
case None => false
}
}
def PlayersInSOI : List[Player] = playersInSOI
def PlayersInSOI_=(list : List[Player]) : List[Player] = {
@ -117,6 +109,21 @@ class Building(private val name: String,
}
}
def CaptureTerminal : Option[CaptureTerminal] = {
Amenities.find(_.isInstanceOf[CaptureTerminal]) match {
case Some(term) => Some(term.asInstanceOf[CaptureTerminal])
case _ => None
}
}
def CaptureTerminalIsHacked : Boolean = {
CaptureTerminal match {
case Some(obj: CaptureTerminal) =>
obj.HackedBy.isDefined
case None => false
}
}
def TriggerZoneMapUpdate(): Unit = {
if(Actor != Default.Actor) Actor ! Building.TriggerZoneMapUpdate(Zone.Number)
}
@ -171,7 +178,7 @@ class Building(private val name: String,
) = {
val ntuLevel : Int = NtuLevel
//if we have a capture terminal, get the hack status & time (in milliseconds) from control console if it exists
val (hacking, hackingFaction, hackTime) : (Boolean, PlanetSideEmpire.Value, Long) = Amenities.find(x => x.isInstanceOf[CaptureTerminal]) match {
val (hacking, hackingFaction, hackTime) : (Boolean, PlanetSideEmpire.Value, Long) = CaptureTerminal match {
case Some(obj: CaptureTerminal with Hackable) =>
obj.HackedBy match {
case Some(Hackable.HackInfo(_, _, hfaction, _, start, length)) =>
@ -221,7 +228,7 @@ class Building(private val name: String,
zone.Lattice find this match {
case Some(_) =>
// todo: generator destruction state
val subGraph = Zone.Lattice filter ((b: Building) => b.Faction == this.Faction && !b.CaptureConsoleIsHacked && b.NtuLevel > 0)
val subGraph = Zone.Lattice filter ((b: Building) => b.Faction == this.Faction && !b.CaptureTerminalIsHacked && b.NtuLevel > 0)
var stackedBenefit = 0
if (FindLatticeBenefit(GlobalDefinitions.amp_station, subGraph)) stackedBenefit |= 1

View file

@ -4,6 +4,7 @@ package net.psforever.objects.serverobject.terminals
import net.psforever.objects.serverobject.hackable.Hackable
import net.psforever.objects.serverobject.structures.Amenity
import net.psforever.packet.game.TriggeredSound
import net.psforever.types.Vector3
class CaptureTerminal(private val idef : CaptureTerminalDefinition) extends Amenity with Hackable {
def Definition : CaptureTerminalDefinition = idef
@ -21,9 +22,10 @@ object CaptureTerminal {
}
import akka.actor.ActorContext
def Constructor(tdef: CaptureTerminalDefinition)(id : Int, context : ActorContext) : CaptureTerminal = {
def Constructor(pos: Vector3, tdef: CaptureTerminalDefinition)(id : Int, context : ActorContext) : CaptureTerminal = {
import akka.actor.Props
val obj = CaptureTerminal(tdef)
obj.Position = pos
obj.Actor = context.actorOf(Props(classOf[CaptureTerminalControl], obj), s"${tdef.Name}_$id")
obj
}

View file

@ -42,7 +42,7 @@ class ProximityTerminalControl(term : Terminal with ProximityUnit) extends Actor
case CommonMessages.Use(player, Some(item : SimpleItem)) if item.Definition == GlobalDefinitions.remote_electronics_kit =>
//TODO setup certifications check
term.Owner match {
case b : Building if (b.Faction != player.Faction || b.CaptureConsoleIsHacked) && term.HackedBy.isEmpty =>
case b : Building if (b.Faction != player.Faction || b.CaptureTerminalIsHacked) && term.HackedBy.isEmpty =>
sender ! CommonMessages.Progress(
GenericHackables.GetHackSpeed(player, term),
GenericHackables.FinishHacking(term, player, 3212836864L),

View file

@ -38,7 +38,7 @@ class TerminalControl(term : Terminal) extends Actor
case CommonMessages.Use(player, Some(item : SimpleItem)) if item.Definition == GlobalDefinitions.remote_electronics_kit =>
//TODO setup certifications check
term.Owner match {
case b : Building if (b.Faction != player.Faction || b.CaptureConsoleIsHacked) && term.HackedBy.isEmpty =>
case b : Building if (b.Faction != player.Faction || b.CaptureTerminalIsHacked) && term.HackedBy.isEmpty =>
sender ! CommonMessages.Progress(
GenericHackables.GetHackSpeed(player, term),
GenericHackables.FinishHacking(term, player, 3212836864L),

View file

@ -213,7 +213,7 @@ class ResourceSiloObjectBuilderTest extends ActorTest {
"build" in {
val hub = ServerObjectBuilderTest.NumberPoolHub
val actor = system.actorOf(Props(classOf[ServerObjectBuilderTest.BuilderTestActor], ServerObjectBuilder(1,
ResourceSilo.Constructor), hub), "spawn-tube")
ResourceSilo.Constructor(Vector3(0f, 0f, 0f))), hub), "resource-silo")
actor ! "startup"
val reply = receiveOne(Duration.create(1000, "ms"))