mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-03-12 00:40:35 +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()
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import net.psforever.objects.GlobalDefinitions._
|
|||
import net.psforever.objects.LocalProjectile
|
||||
import net.psforever.objects.ballistics.Projectile
|
||||
import net.psforever.objects.serverobject.doors.Door
|
||||
import net.psforever.objects.serverobject.generator.Generator
|
||||
import net.psforever.objects.serverobject.implantmech.ImplantTerminalMech
|
||||
import net.psforever.objects.serverobject.locks.IFFLock
|
||||
import net.psforever.objects.serverobject.mblocker.Locker
|
||||
|
|
@ -366,6 +367,8 @@ object Map06 {
|
|||
LocalBuilding("Anguta", 20, 2, FoundationBuilder(Building.Structure(StructureType.Facility, Vector3(3944f, 4240f, 266.4438f), comm_station_dsp)))
|
||||
LocalObject(180, CaptureTerminal.Constructor(capture_terminal), owning_building_guid = 20)
|
||||
LocalObject(222, Door.Constructor(Vector3(4012.339f, 4310.464f, 269.8218f)), owning_building_guid = 20)
|
||||
LocalObject(232, Terminal.Constructor(Vector3.Zero, gen_control), owning_building_guid = 20) //TODO placeholder
|
||||
LocalObject(241, Generator.Constructor, owning_building_guid = 20)
|
||||
LocalObject(370, Door.Constructor(Vector3(3884.196f, 4196.501f, 268.0948f)), owning_building_guid = 20)
|
||||
LocalObject(371, Door.Constructor(Vector3(3884.196f, 4214.693f, 276.0588f)), owning_building_guid = 20)
|
||||
LocalObject(372, Door.Constructor(Vector3(3901.307f, 4172.197f, 276.0588f)), owning_building_guid = 20)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue