This repository has been archived by the owner on Jan 22, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
252d6d7
commit 4da9d4d
Showing
27 changed files
with
738 additions
and
457 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/obj/machinery/computer/fusion | ||
icon_keyboard = "power_key" | ||
icon_screen = "rust_screen" | ||
light_color = 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.