[MIRROR] Improved Smes Map Upgrades (#11742)

Co-authored-by: Will <7099514+Willburd@users.noreply.github.com>
This commit is contained in:
CHOMPStation2StaffMirrorBot
2025-09-26 06:21:51 -07:00
committed by GitHub
parent 7102fd5a46
commit 7f467bf02f
6 changed files with 114 additions and 47 deletions

View File

@@ -357,6 +357,11 @@ Class Procs:
R.play_rped_sound()
return 1
// This is it's own proc so it can be more easily found when looking for machines that can upgrade themselves from mapped parts
// Should be called from LateInitialize()
/obj/machinery/proc/apply_mapped_upgrades()
return
// Default behavior for wrenching down machines. Supports both delay and instant modes.
/obj/machinery/proc/default_unfasten_wrench(var/mob/user, var/obj/item/W, var/time = 0)
if(!W.has_tool_quality(TOOL_WRENCH))

View File

@@ -97,6 +97,46 @@
. = ..()
default_apply_parts()
connect_to_network()
if(mapload)
return INITIALIZE_HINT_LATELOAD
/obj/machinery/power/rtg/LateInitialize()
apply_mapped_upgrades()
/obj/machinery/power/rtg/apply_mapped_upgrades()
// Detect new parts placed by mappers
var/list/parts_found = list()
for(var/i = 1, i <= loc.contents.len, i++)
var/obj/item/W = loc.contents[i]
if(istype(W, /obj/item/stock_parts/capacitor))
parts_found.Add(W)
if(istype(W, /obj/item/stock_parts/micro_laser))
parts_found.Add(W)
// Wipe old parts for new ones!
if(parts_found.len == 0)
return
if(locate(/obj/item/stock_parts/capacitor) in parts_found)
while(TRUE)
var/obj/item/stock_parts/capacitor/C = locate(/obj/item/stock_parts/capacitor) in component_parts
if(isnull(C))
break
component_parts.Remove(C)
qdel(C)
if(locate(/obj/item/stock_parts/micro_laser) in parts_found)
while(TRUE)
var/obj/item/stock_parts/micro_laser/M = locate(/obj/item/stock_parts/micro_laser) in component_parts
if(isnull(M))
break
component_parts.Remove(M)
qdel(M)
// Rebuild from mapper's parts
for(var/i = 1, i <= parts_found.len, i++)
var/obj/item/W = parts_found[i]
component_parts.Add(W)
W.forceMove(src)
RefreshParts()
/obj/machinery/power/rtg/process()
..()

View File

@@ -86,12 +86,15 @@ GLOBAL_LIST_EMPTY(smeses)
connect_to_network()
if(!should_be_mapped)
WARNING("Non-buildable or Non-magical SMES at [src.x]X [src.y]Y [src.z]Z")
if(mapload)
return INITIALIZE_HINT_LATELOAD
/obj/machinery/power/smes/buildable/Initialize(mapload)
. = ..()
return INITIALIZE_HINT_LATELOAD
/obj/machinery/power/smes/LateInitialize()
apply_mapped_upgrades()
apply_mapped_settings()
/obj/machinery/power/smes/buildable/LateInitialize()
// Only the buildable smes type checks for mapped updates
/obj/machinery/power/smes/buildable/apply_mapped_upgrades()
// Detect new coils placed by mappers
var/list/parts_found = list()
for(var/i = 1, i <= loc.contents.len, i++)
@@ -106,7 +109,6 @@ GLOBAL_LIST_EMPTY(smeses)
if(isnull(C))
break
component_parts.Remove(C)
C.forceMove(src.loc)
qdel(C)
cur_coils--
// Rebuild from mapper's coils
@@ -118,6 +120,10 @@ GLOBAL_LIST_EMPTY(smeses)
W.forceMove(src)
RefreshParts()
// Allows subtypes to configue the smes for different input/output rates, and level of starting charge
/obj/machinery/power/smes/proc/apply_mapped_settings()
return
/obj/machinery/power/smes/Destroy()
for(var/obj/machinery/power/terminal/T in terminals)
T.master = null
@@ -578,3 +584,38 @@ GLOBAL_LIST_EMPTY(smeses)
/obj/machinery/power/smes/proc/set_output(var/new_output = 0)
output_level = between(0, new_output, output_level_max)
update_icon()
/obj/machinery/power/smes/buildable/hybrid
name = "hybrid power storage unit"
desc = "A high-capacity superconducting magnetic energy storage (SMES) unit, modified with alien technology to generate small amounts of power from seemingly nowhere."
icon = 'icons/obj/power_vr.dmi'
var/recharge_rate = 10000
var/overlay_icon = 'icons/obj/power_vr.dmi'
/obj/machinery/power/smes/buildable/hybrid/attackby(var/obj/item/W as obj, var/mob/user as mob)
if(W.has_tool_quality(TOOL_SCREWDRIVER) || W.has_tool_quality(TOOL_WIRECUTTER))
to_chat(user,span_warning("\The [src] full of weird alien technology that's best not messed with."))
return 0
/obj/machinery/power/smes/buildable/hybrid/update_icon()
cut_overlays()
if(stat & BROKEN) return
add_overlay("smes-op[outputting]")
if(inputting == 2)
add_overlay("smes-oc2")
else if (inputting == 1)
add_overlay("smes-oc1")
else
if(input_attempt)
add_overlay("smes-oc0")
var/clevel = chargedisplay()
if(clevel>0)
add_overlay("smes-og[clevel]")
return
/obj/machinery/power/smes/buildable/hybrid/process()
charge += min(recharge_rate, capacity - charge)
..()

View File

@@ -0,0 +1,22 @@
// Defaults to maximum charge, no change to input or output levels
/obj/machinery/power/smes/buildable/max_charge/apply_mapped_settings()
// Set charge
charge = capacity
// Defaults to 100% input and output settings, starts with maximum charge
/obj/machinery/power/smes/buildable/engine_default/apply_mapped_settings()
// Set charge
charge = capacity
// Set output to max
inputting(TRUE)
outputting(TRUE)
input_level = input_level_max
output_level = output_level_max
// Poi prop
/obj/machinery/power/smes/buildable/alien_royal
name = "Alien Royal Capacitor"
icon_state = "unit"
icon = 'icons/obj/alien_smes.dmi'
input_level = 950000
output_level = 950000

View File

@@ -1,41 +0,0 @@
/obj/machinery/power/smes/buildable/hybrid
name = "hybrid power storage unit"
desc = "A high-capacity superconducting magnetic energy storage (SMES) unit, modified with alien technology to generate small amounts of power from seemingly nowhere."
icon = 'icons/obj/power_vr.dmi'
var/recharge_rate = 10000
var/overlay_icon = 'icons/obj/power_vr.dmi'
/obj/machinery/power/smes/buildable/hybrid/attackby(var/obj/item/W as obj, var/mob/user as mob)
if(W.has_tool_quality(TOOL_SCREWDRIVER) || W.has_tool_quality(TOOL_WIRECUTTER))
to_chat(user,span_warning("\The [src] full of weird alien technology that's best not messed with."))
return 0
/obj/machinery/power/smes/buildable/hybrid/update_icon()
cut_overlays()
if(stat & BROKEN) return
add_overlay("smes-op[outputting]")
if(inputting == 2)
add_overlay("smes-oc2")
else if (inputting == 1)
add_overlay("smes-oc1")
else
if(input_attempt)
add_overlay("smes-oc0")
var/clevel = chargedisplay()
if(clevel>0)
add_overlay("smes-og[clevel]")
return
/obj/machinery/power/smes/buildable/hybrid/process()
charge += min(recharge_rate, capacity - charge)
..()
/obj/machinery/power/smes/buildable/alien_royal
name = "Alien Royal Capacitor"
icon_state = "unit"
icon = 'icons/obj/alien_smes.dmi'
input_level = 950000
output_level = 950000

View File

@@ -4185,7 +4185,7 @@
#include "code\modules\power\privacy_switch.dm"
#include "code\modules\power\smes.dm"
#include "code\modules\power\smes_construction.dm"
#include "code\modules\power\smes_vr.dm"
#include "code\modules\power\smes_prefabs.dm"
#include "code\modules\power\solar.dm"
#include "code\modules\power\terminal.dm"
#include "code\modules\power\tracker.dm"