[MIRROR] Material holding machines can't connect to ore silos on different z levels [MDB IGNORE] (#14167)

* Material holding machines can't connect to ore silos on different z levels (#66953)

The station's ore silo can't connect to machines that are off the station z-level anymore. This doesn't affect multi-z stations.
Also includes ore silo code improvement because I was unhappy with it.

* Material holding machines can't connect to ore silos on different z levels

Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
This commit is contained in:
SkyratBot
2022-06-07 22:11:42 +02:00
committed by GitHub
parent f0ea5eec7b
commit 64b71f7585
2 changed files with 33 additions and 14 deletions
+22 -4
View File
@@ -28,6 +28,7 @@ handles linking back and forth.
RegisterSignal(parent, COMSIG_PARENT_ATTACKBY, .proc/OnAttackBy)
RegisterSignal(parent, COMSIG_ATOM_TOOL_ACT(TOOL_MULTITOOL), .proc/OnMultitool)
RegisterSignal(parent, COMSIG_MOVABLE_Z_CHANGED, .proc/check_z_level)
var/turf/T = get_turf(parent)
if (force_connect || (mapload && is_station_level(T.z)))
@@ -38,14 +39,14 @@ handles linking back and forth.
/datum/component/remote_materials/proc/LateInitialize()
silo = GLOB.ore_silo_default
if (silo)
silo.connected += src
silo.ore_connected_machines += src
mat_container = silo.GetComponent(/datum/component/material_container)
else
_MakeLocal()
/datum/component/remote_materials/Destroy()
if (silo)
silo.connected -= src
silo.ore_connected_machines -= src
silo.updateUsrDialog()
silo = null
mat_container = null
@@ -105,19 +106,36 @@ handles linking back and forth.
if (silo == M.buffer)
to_chat(user, span_warning("[parent] is already connected to [silo]!"))
return COMPONENT_BLOCK_TOOL_ATTACK
var/turf/silo_turf = get_turf(M.buffer)
var/turf/user_loc = get_turf(user)
if(user_loc.z != silo_turf.z)
to_chat(user, span_warning("[parent] is too far away to get a connection signal!"))
return COMPONENT_BLOCK_TOOL_ATTACK
if (silo)
silo.connected -= src
silo.ore_connected_machines -= src
silo.updateUsrDialog()
else if (mat_container)
mat_container.retrieve_all()
qdel(mat_container)
silo = M.buffer
silo.connected += src
silo.ore_connected_machines += src
silo.updateUsrDialog()
mat_container = silo.GetComponent(/datum/component/material_container)
to_chat(user, span_notice("You connect [parent] to [silo] from the multitool's buffer."))
return COMPONENT_BLOCK_TOOL_ATTACK
/datum/component/remote_materials/proc/check_z_level(datum/source, turf/old_turf, turf/new_turf)
SIGNAL_HANDLER
if(!silo)
return
var/turf/silo_turf = get_turf(silo)
if(is_station_level(silo_turf.z) && is_station_level(new_turf.z)) // if we're both on "station", regardless of multi-z, we'll pass by.
return
if(silo_turf.z == new_turf.z)
return
disconnect_from(silo)
/datum/component/remote_materials/proc/on_hold()
return silo?.holds["[get_area(parent)]/[category]"]
+11 -10
View File
@@ -9,9 +9,12 @@ GLOBAL_LIST_EMPTY(silo_access_logs)
density = TRUE
circuit = /obj/item/circuitboard/machine/ore_silo
var/list/holds = list()
var/list/datum/component/remote_materials/connected = list()
/// The machine UI's page of logs showing ore history.
var/log_page = 1
/// List of all connected components that are on hold from accessing materials.
var/list/holds = list()
/// List of all components that are sharing ores with this silo.
var/list/datum/component/remote_materials/ore_connected_machines = list()
/obj/machinery/ore_silo/Initialize(mapload)
. = ..()
@@ -36,11 +39,10 @@ GLOBAL_LIST_EMPTY(silo_access_logs)
if (GLOB.ore_silo_default == src)
GLOB.ore_silo_default = null
for(var/C in connected)
var/datum/component/remote_materials/mats = C
for(var/datum/component/remote_materials/mats as anything in ore_connected_machines)
mats.disconnect_from(src)
connected = null
ore_connected_machines = null
var/datum/component/material_container/materials = GetComponent(/datum/component/material_container)
materials.retrieve_all()
@@ -112,14 +114,13 @@ GLOBAL_LIST_EMPTY(silo_access_logs)
ui += "Nothing!"
ui += "</div><div class='statusDisplay'><h2>Connected Machines:</h2>"
for(var/C in connected)
var/datum/component/remote_materials/mats = C
for(var/datum/component/remote_materials/mats as anything in ore_connected_machines)
var/atom/parent = mats.parent
var/hold_key = "[get_area(parent)]/[mats.category]"
ui += "<a href='?src=[REF(src)];remove=[REF(mats)]'>Remove</a>"
ui += "<a href='?src=[REF(src)];hold[!holds[hold_key]]=[url_encode(hold_key)]'>[holds[hold_key] ? "Allow" : "Hold"]</a>"
ui += " <b>[parent.name]</b> in [get_area_name(parent, TRUE)]<br>"
if(!connected.len)
if(!ore_connected_machines.len)
ui += "Nothing!"
ui += "</div><div class='statusDisplay'><h2>Access Logs:</h2>"
@@ -153,10 +154,10 @@ GLOBAL_LIST_EMPTY(silo_access_logs)
usr.set_machine(src)
if(href_list["remove"])
var/datum/component/remote_materials/mats = locate(href_list["remove"]) in connected
var/datum/component/remote_materials/mats = locate(href_list["remove"]) in ore_connected_machines
if (mats)
mats.disconnect_from(src)
connected -= mats
ore_connected_machines -= mats
updateUsrDialog()
return TRUE
else if(href_list["hold1"])