mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-03-17 02:50:36 +00:00
Generator (#328)
* established foundations for generator object * established foundations for generator terminal * sparse comments added
This commit is contained in:
parent
b1be0ffdb3
commit
db82b9f01f
6 changed files with 100 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ import net.psforever.objects.definition.converter._
|
|||
import net.psforever.objects.equipment._
|
||||
import net.psforever.objects.inventory.InventoryTile
|
||||
import net.psforever.objects.serverobject.doors.DoorDefinition
|
||||
import net.psforever.objects.serverobject.generator.GeneratorDefinition
|
||||
import net.psforever.objects.serverobject.implantmech.ImplantTerminalMechDefinition
|
||||
import net.psforever.objects.serverobject.locks.IFFLockDefinition
|
||||
import net.psforever.objects.serverobject.mblocker.LockerDefinition
|
||||
|
|
@ -992,12 +993,20 @@ object GlobalDefinitions {
|
|||
val manned_turret = new FacilityTurretDefinition(480)
|
||||
|
||||
val painbox = new PainboxDefinition(622)
|
||||
|
||||
val painbox_continuous = new PainboxDefinition(623)
|
||||
|
||||
val painbox_door_radius = new PainboxDefinition(624)
|
||||
|
||||
val painbox_door_radius_continuous = new PainboxDefinition(625)
|
||||
|
||||
val painbox_radius = new PainboxDefinition(626)
|
||||
|
||||
val painbox_radius_continuous = new PainboxDefinition(627)
|
||||
|
||||
val gen_control = new GeneratorTerminalDefinition(349)
|
||||
|
||||
val generator = new GeneratorDefinition(351)
|
||||
initMiscellaneous()
|
||||
|
||||
/*
|
||||
|
|
@ -6206,5 +6215,9 @@ object GlobalDefinitions {
|
|||
manned_turret.MountPoints += 1 -> 0
|
||||
manned_turret.FactionLocked = true
|
||||
manned_turret.ReserveAmmunition = false
|
||||
|
||||
gen_control.Name = "gen_control"
|
||||
|
||||
generator.Name = "generator"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
// Copyright (c) 2020 PSForever
|
||||
package net.psforever.objects.serverobject.generator
|
||||
|
||||
import net.psforever.objects.serverobject.structures.Amenity
|
||||
|
||||
/**
|
||||
* The generator is a big feature of all major facilities.
|
||||
* It takes nanites from the NTU Silo and transforms it into power for the other amenities in the facility
|
||||
* as well as distributing nanites for self-repair mechanisms.
|
||||
* The only exception
|
||||
* (in that the "exception" is something that does not require the generator to power it)
|
||||
* is the capture console / control console.
|
||||
* The generator is capable of self-repair from a completely destroyed state, as long as it has an supply of nanites.
|
||||
* @param gdef the `ObjectDefinition` that constructs this object and maintains some of its immutable fields
|
||||
*/
|
||||
class Generator(private val gdef : GeneratorDefinition) extends Amenity {
|
||||
//TODO should have Vitality, to indicate damaged/destroyed property
|
||||
def Definition : GeneratorDefinition = gdef
|
||||
}
|
||||
|
||||
object Generator {
|
||||
def apply(gdef : GeneratorDefinition) : Generator = {
|
||||
new Generator(gdef)
|
||||
}
|
||||
|
||||
import akka.actor.ActorContext
|
||||
def Constructor(id : Int, context : ActorContext) : Generator = {
|
||||
import akka.actor.Props
|
||||
import net.psforever.objects.GlobalDefinitions
|
||||
|
||||
val obj = Generator(GlobalDefinitions.generator)
|
||||
obj.Actor = context.actorOf(Props(classOf[GeneratorControl], obj), s"${obj.Definition.Name}_$id")
|
||||
obj
|
||||
}
|
||||
|
||||
import net.psforever.types.Vector3
|
||||
def Constructor(pos : Vector3)(id : Int, context : ActorContext) : Generator = {
|
||||
import akka.actor.Props
|
||||
import net.psforever.objects.GlobalDefinitions
|
||||
|
||||
val obj = Generator(GlobalDefinitions.generator)
|
||||
obj.Position = pos
|
||||
obj.Actor = context.actorOf(Props(classOf[GeneratorControl], obj), s"${obj.Definition.Name}_$id")
|
||||
obj
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright (c) 2020 PSForever
|
||||
package net.psforever.objects.serverobject.generator
|
||||
|
||||
import akka.actor.Actor
|
||||
import net.psforever.objects.serverobject.affinity.{FactionAffinity, FactionAffinityBehavior}
|
||||
|
||||
/**
|
||||
* An `Actor` that handles messages being dispatched to a specific `Generator`.
|
||||
* @param gen the `Generator` object being governed
|
||||
*/
|
||||
class GeneratorControl(gen : Generator) extends Actor
|
||||
with FactionAffinityBehavior.Check {
|
||||
def FactionObject : FactionAffinity = gen
|
||||
|
||||
def receive : Receive = checkBehavior.orElse {
|
||||
case _ => ;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) 2020 PSForever
|
||||
package net.psforever.objects.serverobject.generator
|
||||
|
||||
import net.psforever.objects.definition.ObjectDefinition
|
||||
|
||||
/**
|
||||
* The definition for a `Generator` object.
|
||||
*/
|
||||
class GeneratorDefinition(objectId : Int) extends ObjectDefinition(objectId) {
|
||||
Name = "generator"
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) 2020 PSForever
|
||||
package net.psforever.objects.serverobject.terminals
|
||||
|
||||
import net.psforever.objects.Player
|
||||
|
||||
class GeneratorTerminalDefinition(objId : Int) extends TerminalDefinition(objId) {
|
||||
Name = "generator_terminal"
|
||||
def Request(player : Player, msg : Any) : Terminal.Exchange = Terminal.NoDeal()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue