Skip to content
Permalink
Browse files

Backporting RUST updates from Bay. (#830)

  • Loading branch information...
MistakeNot4892 authored and Lohikar committed Feb 14, 2019
1 parent 457e433 commit 6fd66505589b98e84638af3c500f1685f19c966d
Showing with 738 additions and 457 deletions.
  1. +0 −15 code/_helpers/global_access.dm
  2. +50 −0 code/datums/extensions/fusion_plant.dm
  3. +55 −0 code/modules/power/fusion/consoles/_consoles.dm
  4. +59 −0 code/modules/power/fusion/consoles/core_control.dm
  5. +60 −0 code/modules/power/fusion/consoles/gyrotron_control.dm
  6. +36 −0 code/modules/power/fusion/consoles/injector_control.dm
  7. +16 −21 code/modules/power/fusion/core/_core.dm
  8. +0 −174 code/modules/power/fusion/core/core_control.dm
  9. +6 −1 code/modules/power/fusion/fuel_assembly/fuel_assembly.dm
  10. +16 −11 code/modules/power/fusion/fuel_assembly/fuel_compressor.dm
  11. +0 −104 code/modules/power/fusion/fuel_assembly/fuel_control.dm
  12. +14 −17 code/modules/power/fusion/fuel_assembly/fuel_injector.dm
  13. +15 −4 code/modules/power/fusion/fusion_circuits.dm
  14. +48 −0 code/modules/power/fusion/fusion_plant.dm
  15. +1 −1 code/modules/power/fusion/fusion_reactions.dm
  16. +7 −12 code/modules/power/fusion/gyrotron/gyrotron.dm
  17. +0 −92 code/modules/power/fusion/gyrotron/gyrotron_control.dm
  18. +129 −0 code/modules/power/fusion/gyrotron/kinetic_harvester.dm
  19. +27 −0 code/unit_tests/fusion_plants.dm
  20. +8 −3 europa.dme
  21. BIN icons/obj/machines/kinetic_harvester.dmi
  22. BIN icons/obj/machines/power/fusion.dmi
  23. +81 −0 nano/templates/fusion_core_control.tmpl
  24. +41 −0 nano/templates/fusion_gyrotron_control.tmpl
  25. +41 −0 nano/templates/fusion_injector_control.tmpl
  26. +26 −0 nano/templates/kinetic_harvester.tmpl
  27. +1 −1 test/check-paths.sh
  28. +1 −1 test/run-test.sh
@@ -417,10 +417,6 @@
return global.forced_ambiance_list;
if("fruit_icon_cache")
return global.fruit_icon_cache;
if("fuel_injectors")
return global.fuel_injectors;
if("fusion_cores")
return global.fusion_cores;
if("fusion_reactions")
return global.fusion_reactions;
if("game_id")
@@ -451,8 +447,6 @@
return global.global_vars_;
if("gravity_is_on")
return global.gravity_is_on;
if("gyrotrons")
return global.gyrotrons;
if("gzn_check")
return global.gzn_check;
if("hadevent")
@@ -1296,10 +1290,6 @@
global.forced_ambiance_list=newval;
if("fruit_icon_cache")
global.fruit_icon_cache=newval;
if("fuel_injectors")
global.fuel_injectors=newval;
if("fusion_cores")
global.fusion_cores=newval;
if("fusion_reactions")
global.fusion_reactions=newval;
if("game_id")
@@ -1330,8 +1320,6 @@
global.global_vars_=newval;
if("gravity_is_on")
global.gravity_is_on=newval;
if("gyrotrons")
global.gyrotrons=newval;
if("gzn_check")
global.gzn_check=newval;
if("hadevent")
@@ -1966,8 +1954,6 @@
"follow_repository",
"forced_ambiance_list",
"fruit_icon_cache",
"fuel_injectors",
"fusion_cores",
"fusion_reactions",
"game_id",
"game_version",
@@ -1983,7 +1969,6 @@
"global_message_listener",
"global_vars_",
"gravity_is_on",
"gyrotrons",
"gzn_check",
"hadevent",
"hazard_overlays",
@@ -0,0 +1,50 @@
/datum/extension/fusion_plant_member
var/id_tag

/datum/extension/fusion_plant_member/Destroy()
if(holder)
var/datum/fusion_plant/plant = get_fusion_plant()
if(plant)
plant.remove_device(holder)
. = ..()

/datum/extension/fusion_plant_member/proc/set_tag(var/mob/user, var/new_ident)
if(id_tag == new_ident)
to_chat(user, SPAN_WARNING("\The [holder] is already part of the [new_ident] network."))
return FALSE

if(id_tag)
var/datum/fusion_plant/old_plant = GLOB.fusion_plants[id_tag]
if(old_plant)
if(!old_plant.remove_device(holder))
to_chat(user, SPAN_WARNING("You encounter an error when trying to unregister \the [holder] from the [id_tag] network."))
return FALSE
to_chat(user, SPAN_NOTICE("You unregister \the [holder] from the [id_tag] network."))

var/datum/fusion_plant/plant = GLOB.fusion_plants[new_ident]
if(!plant)
plant = new(new_ident)
plant.add_device(holder)
to_chat(user, SPAN_NOTICE("You create a new [new_ident] network and register \the [holder] with it."))
else if(plant.within_radius(holder))
plant.add_device(holder)
to_chat(user, SPAN_NOTICE("You register \the [holder] with the [new_ident] network."))
else
to_chat(user, SPAN_WARNING("\The [holder] is out of range of the [new_ident] network."))
return FALSE
id_tag = new_ident
return TRUE

/datum/extension/fusion_plant_member/proc/get_fusion_plant()
var/datum/fusion_plant/plant = id_tag ? GLOB.fusion_plants[id_tag] : null
if(plant && !plant.within_radius(holder))
plant.remove_device(holder)
id_tag = null
plant = null
return plant

/datum/extension/fusion_plant_member/proc/get_new_tag(var/mob/user)
var/new_ident = input(user, "Enter a new ident tag.", "[holder]", id_tag) as null|text
if(new_ident && user.Adjacent(holder))
return set_tag(user, new_ident)

@@ -0,0 +1,55 @@
/obj/machinery/computer/fusion
icon_keyboard = "power_key"
icon_screen = "rust_screen"
light_color = LIGHT_COLOR_ORANGE
idle_power_usage = 250
active_power_usage = 500
var/ui_template
var/initial_id_tag

/obj/machinery/computer/fusion/Initialize()
. = ..()
set_extension(src, /datum/extension/fusion_plant_member, /datum/extension/fusion_plant_member)
if(initial_id_tag)
var/datum/extension/fusion_plant_member/fusion = get_extension(src, /datum/extension/fusion_plant_member)
fusion.set_tag(null, initial_id_tag)

/obj/machinery/computer/fusion/proc/get_fusion_plant()
var/datum/extension/fusion_plant_member/fusion = get_extension(src, /datum/extension/fusion_plant_member)
return fusion.get_fusion_plant()

/obj/machinery/computer/fusion/attackby(var/obj/item/thing, var/mob/user)
if(isMultitool(thing))
var/datum/extension/fusion_plant_member/fusion = get_extension(src, /datum/extension/fusion_plant_member)
fusion.get_new_tag(user)
return
else
return ..()

/obj/machinery/computer/fusion/attack_ghost(var/mob/user)
ui_interact(user)

/obj/machinery/computer/fusion/attack_ai(var/mob/user)
ui_interact(user)

/obj/machinery/computer/fusion/attack_hand(var/mob/user)
add_fingerprint(user)
ui_interact(user)

/obj/machinery/computer/fusion/proc/build_ui_data()
var/datum/extension/fusion_plant_member/fusion = get_extension(src, /datum/extension/fusion_plant_member)
var/datum/fusion_plant/plant = fusion.get_fusion_plant()
var/list/data = list()
data["id"] = plant ? plant.id_tag : "unset"
data["name"] = name
. = data

/obj/machinery/computer/fusion/ui_interact(var/mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
if(ui_template)
var/list/data = build_ui_data()
ui = SSnano.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, ui_template, name, 400, 600)
ui.set_initial_data(data)
ui.open()
ui.set_auto_update(1)
@@ -0,0 +1,59 @@
/obj/machinery/computer/fusion/core_control
name = "\improper R-UST Mk. 8 core control"
ui_template = "fusion_core_control.tmpl"

/obj/machinery/computer/fusion/core_control/OnTopic(var/mob/user, var/href_list, var/datum/topic_state/state)

if(href_list["toggle_active"] || href_list["str"])
var/obj/machinery/power/fusion_core/C = locate(href_list["machine"])
if(!istype(C))
return TOPIC_NOACTION

var/datum/fusion_plant/plant = get_fusion_plant()
if(!plant || !plant.fusion_cores[C])
return TOPIC_NOACTION

if(!C.check_core_status())
return TOPIC_NOACTION

if(href_list["toggle_active"])
if(!C.Startup()) //Startup() whilst the device is active will return null.
C.Shutdown()
return TOPIC_REFRESH

if(href_list["str"] && C)
var/val = text2num(href_list["str"])
if(!val) //Value is 0, which is manual entering.
C.set_strength(input("Enter the new field power density (W.m^-3)", "Fusion Control", C.field_strength) as num)
else
C.set_strength(C.field_strength + val)
return TOPIC_REFRESH

/obj/machinery/computer/fusion/core_control/build_ui_data()
. = ..()
var/datum/extension/fusion_plant_member/fusion = get_extension(src, /datum/extension/fusion_plant_member)
var/datum/fusion_plant/plant = fusion.get_fusion_plant()
var/list/cores = list()
if(plant)
for(var/i = 1 to LAZYLEN(plant.fusion_cores))
var/list/core = list()
var/obj/machinery/power/fusion_core/C = plant.fusion_cores[i]
core["id"] = "#[i]"
core["ref"] = "\ref[C]"
core["field"] = !isnull(C.owned_field)
core["power"] = "[C.field_strength/10.0] tesla"
core["size"] = C.owned_field ? "[C.owned_field.size] meter\s" : "Field offline."
core["instability"] = C.owned_field ? "[C.owned_field.percent_unstable * 100]%" : "Field offline."
core["temperature"] = C.owned_field ? "[C.owned_field.plasma_temperature + 295]K" : "Field offline."
core["powerstatus"] = "[C.avail()]/[C.active_power_usage] W"
var/fuel_string = "<table width = '100%'>"
if(C.owned_field && LAZYLEN(C.owned_field.reactants))
for(var/reactant in C.owned_field.reactants)
fuel_string += "<tr><td>[reactant]</td><td>[C.owned_field.reactants[reactant]]</td></tr>"
else
fuel_string += "<tr><td colspan = 2>Nothing.</td></tr>"
fuel_string += "</table>"
core["fuel"] = fuel_string

cores += list(core)
.["cores"] = cores
@@ -0,0 +1,60 @@
/obj/machinery/computer/fusion/gyrotron
name = "gyrotron control console"
icon_keyboard = "med_key"
icon_screen = "gyrotron_screen"
light_color = COLOR_BLUE
ui_template = "fusion_gyrotron_control.tmpl"

/obj/machinery/computer/fusion/gyrotron/OnTopic(var/mob/user, var/href_list, var/datum/topic_state/state)

if(href_list["modifypower"] || href_list["modifyrate"] || href_list["toggle"])

var/obj/machinery/power/emitter/gyrotron/G = locate(href_list["machine"])
if(!istype(G))
return TOPIC_NOACTION

var/datum/fusion_plant/plant = get_fusion_plant()
if(!plant || !plant.gyrotrons[G])
return TOPIC_NOACTION

if(href_list["modifypower"])
var/new_val = input("Enter new emission power level (1 - 50)", "Modifying power level", G.mega_energy) as num
if(!istype(G))
return TOPIC_NOACTION
if(!new_val)
to_chat(user, SPAN_WARNING("That's not a valid number."))
return TOPIC_NOACTION
G.mega_energy = Clamp(new_val, 1, 50)
G.change_power_consumption(G.mega_energy * 1500, POWER_USE_ACTIVE)
return TOPIC_REFRESH

if(href_list["modifyrate"])
var/new_val = input("Enter new emission delay between 1 and 10 seconds.", "Modifying emission rate", G.rate) as num
if(!istype(G))
return TOPIC_NOACTION
if(!new_val)
to_chat(user, SPAN_WARNING("That's not a valid number."))
return TOPIC_NOACTION
G.rate = Clamp(new_val, 1, 10)
return TOPIC_REFRESH

if(href_list["toggle"])
G.activate(user)
return TOPIC_REFRESH

/obj/machinery/computer/fusion/gyrotron/build_ui_data()
. = ..()
var/datum/extension/fusion_plant_member/fusion = get_extension(src, /datum/extension/fusion_plant_member)
var/datum/fusion_plant/plant = fusion.get_fusion_plant()
var/list/gyrotrons = list()
if(plant)
for(var/i = 1 to LAZYLEN(plant.gyrotrons))
var/list/gyrotron = list()
var/obj/machinery/power/emitter/gyrotron/G = plant.gyrotrons[i]
gyrotron["id"] = "#[i]"
gyrotron["ref"] = "\ref[G]"
gyrotron["active"] = G.active
gyrotron["firedelay"] = G.rate
gyrotron["energy"] = G.mega_energy
gyrotrons += list(gyrotron)
.["gyrotrons"] = gyrotrons
@@ -0,0 +1,36 @@
/obj/machinery/computer/fusion/fuel_control
name = "fuel injection control computer"
icon_keyboard = "rd_key"
icon_screen = "fuel_screen"
ui_template = "fusion_injector_control.tmpl"

/obj/machinery/computer/fusion/fuel_control/OnTopic(var/mob/user, var/href_list, var/datum/topic_state/state)
if(href_list["toggle_injecting"])
var/obj/machinery/fusion_fuel_injector/I = locate(href_list["toggle_injecting"])
if(!istype(I))
return TOPIC_NOACTION
var/datum/fusion_plant/plant = get_fusion_plant()
if(!plant || !plant.fuel_injectors[I])
return TOPIC_NOACTION
if(I.injecting)
I.StopInjecting()
else
I.BeginInjecting()
return TOPIC_REFRESH

/obj/machinery/computer/fusion/fuel_control/build_ui_data()
. = ..()
var/datum/extension/fusion_plant_member/fusion = get_extension(src, /datum/extension/fusion_plant_member)
var/datum/fusion_plant/plant = fusion.get_fusion_plant()
var/list/injectors = list()
if(plant)
for(var/i = 1 to LAZYLEN(plant.fuel_injectors))
var/list/injector = list()
var/obj/machinery/fusion_fuel_injector/I = plant.fuel_injectors[i]
injector["id"] = "#[i]"
injector["ref"] = "\ref[I]"
injector["injecting"] = I.injecting
injector["fueltype"] = "[I.cur_assembly ? I.cur_assembly.fuel_type : "no fuel inserted"]"
injector["depletion"] = "[I.cur_assembly ? (I.cur_assembly.percent_depleted * 100) : 100]%"
injectors += list(injector)
.["injectors"] = injectors
@@ -1,9 +1,3 @@
/*
TODO README
*/

var/list/fusion_cores = list()

#define MAX_FIELD_STR 10000
#define MIN_FIELD_STR 1

@@ -22,23 +16,18 @@ var/list/fusion_cores = list()

var/obj/effect/fusion_em_field/owned_field
var/field_strength = 1//0.01
var/id_tag
var/initial_id_tag

/obj/machinery/power/fusion_core/mapped
anchored = 1

/obj/machinery/power/fusion_core/Initialize()
. = ..()
connect_to_network()
fusion_cores += src

/obj/machinery/power/fusion_core/Destroy()
for(var/obj/machinery/computer/fusion_core_control/FCC in SSmachines.machinery)
FCC.connected_devices -= src
if(FCC.cur_viewed_device == src)
FCC.cur_viewed_device = null
fusion_cores -= src
return ..()
set_extension(src, /datum/extension/fusion_plant_member, /datum/extension/fusion_plant_member)
if(initial_id_tag)
var/datum/extension/fusion_plant_member/fusion = get_extension(src, /datum/extension/fusion_plant_member)
fusion.set_tag(null, initial_id_tag)

/obj/machinery/power/fusion_core/Process()
if((stat & BROKEN) || !powernet || !owned_field)
@@ -104,11 +93,10 @@ var/list/fusion_cores = list()
return

if(isMultitool(W))
var/new_ident = input("Enter a new ident tag.", "Fusion Core", id_tag) as null|text
if(new_ident && user.Adjacent(src))
id_tag = new_ident
var/datum/extension/fusion_plant_member/fusion = get_extension(src, /datum/extension/fusion_plant_member)
fusion.get_new_tag(user)
return

else if(isWrench(W))
anchored = !anchored
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
@@ -130,4 +118,11 @@ var/list/fusion_cores = list()
if(!owned_field)
return FALSE
owned_field.plasma_temperature = field_temperature
return TRUE
return TRUE

/obj/machinery/power/fusion_core/proc/check_core_status()
if(stat & BROKEN)
return FALSE
if(idle_power_usage > avail())
return FALSE
. = TRUE
Oops, something went wrong.

0 comments on commit 6fd6650

Please sign in to comment.
You can’t perform that action at this time.