mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-07-16 01:25:10 +01:00
Better handling for multiple hose connectors (#17838)
* Better handling for multiple hose connectors * Better distance handling * Delete cell
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/datum/component/hose_connector
|
||||
var/name = ""
|
||||
dupe_mode = COMPONENT_DUPE_ALLOWED
|
||||
VAR_PROTECTED/obj/carrier = null
|
||||
VAR_PROTECTED/flow_direction = HOSE_NEUTRAL
|
||||
VAR_PROTECTED/datum/hose/my_hose = null
|
||||
@@ -43,6 +44,9 @@
|
||||
/datum/component/hose_connector/proc/get_flow_direction()
|
||||
return flow_direction
|
||||
|
||||
/datum/component/hose_connector/proc/get_id()
|
||||
return "[name] #[connector_number]"
|
||||
|
||||
/datum/component/hose_connector/output/process()
|
||||
return
|
||||
|
||||
@@ -138,15 +142,16 @@
|
||||
var/list/available_sockets = list()
|
||||
for(var/datum/component/hose_connector/HC in GetComponents(/datum/component/hose_connector))
|
||||
if(HC.get_hose())
|
||||
available_sockets |= HC
|
||||
available_sockets[HC.get_id()] = HC
|
||||
if(!LAZYLEN(available_sockets))
|
||||
return
|
||||
|
||||
if(available_sockets.len == 1)
|
||||
var/datum/component/hose_connector/AC = available_sockets[1]
|
||||
var/key = available_sockets[1]
|
||||
var/datum/component/hose_connector/AC = available_sockets[key]
|
||||
AC.disconnect_action(usr)
|
||||
else
|
||||
var/choice = tgui_input_list(usr, "Select a target hose connector.", "Socket Disconnect", available_sockets)
|
||||
if(choice)
|
||||
var/datum/component/hose_connector/AC = choice
|
||||
var/datum/component/hose_connector/AC = available_sockets[choice]
|
||||
AC.disconnect_action(usr)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
VAR_PRIVATE/hose_color = "#ffffff"
|
||||
|
||||
VAR_PRIVATE/initial_distance = 7
|
||||
VAR_PRIVATE/initial_distance = HOSE_MAX_DISTANCE
|
||||
VAR_PRIVATE/datum/beam/current_beam = null
|
||||
|
||||
/datum/hose/proc/get_pairing(var/datum/component/hose_connector/target)
|
||||
@@ -104,7 +104,7 @@
|
||||
new_col = reagent_node2.get_color()
|
||||
|
||||
// We are in the beam!
|
||||
qdel_swap(current_beam, A.Beam(B, icon_state = "hose", beam_color = new_col, maxdistance = world.view, beam_type = /obj/effect/ebeam/hose))
|
||||
qdel_swap(current_beam, A.Beam(B, icon_state = "hose", beam_color = new_col, maxdistance = (HOSE_MAX_DISTANCE + 1), beam_type = /obj/effect/ebeam/hose))
|
||||
|
||||
return TRUE
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
icon_state = "hose"
|
||||
origin_tech = list(TECH_MATERIAL = 2, TECH_ENGINEERING = 1)
|
||||
amount = 1
|
||||
max_amount = 10
|
||||
max_amount = HOSE_MAX_DISTANCE
|
||||
w_class = ITEMSIZE_SMALL
|
||||
no_variants = TRUE
|
||||
stacktype = /obj/item/stack/hose
|
||||
@@ -40,20 +40,21 @@
|
||||
if(!HC.get_hose())
|
||||
if(REMB)
|
||||
if(HC.get_flow_direction() == HOSE_NEUTRAL || HC.get_flow_direction() != REMB.get_flow_direction())
|
||||
available_sockets |= HC
|
||||
available_sockets[HC.get_id()] = HC
|
||||
else
|
||||
available_sockets |= HC
|
||||
available_sockets[HC.get_id()] = HC
|
||||
|
||||
if(LAZYLEN(available_sockets))
|
||||
if(available_sockets.len == 1)
|
||||
var/datum/component/hose_connector/AC = available_sockets[1]
|
||||
var/key = available_sockets[1]
|
||||
var/datum/component/hose_connector/AC = available_sockets[key]
|
||||
if(REMB && REMB.get_carrier() == AC.get_carrier())
|
||||
to_chat(user, span_notice("Connecting \the [REMB.get_carrier()] to itself seems like a bad idea. You wind \the [src] back up."))
|
||||
remembered = null // Unintuitive if it does not reset state
|
||||
|
||||
else if(REMB && REMB.valid_connection(AC))
|
||||
var/distancetonode = get_dist(REMB.get_carrier(),AC.get_carrier())
|
||||
if(distancetonode > world.view)
|
||||
if(distancetonode > HOSE_MAX_DISTANCE)
|
||||
to_chat(user, span_notice("\The [src] would probably burst if it were this long. You wind \the [src] back up."))
|
||||
remembered = null // Unintuitive if it does not reset state
|
||||
|
||||
@@ -74,7 +75,7 @@
|
||||
var/choice = tgui_input_list(user, "Select a target hose connector.", "Socket Selection", available_sockets)
|
||||
|
||||
if(choice)
|
||||
var/datum/component/hose_connector/CC = choice
|
||||
var/datum/component/hose_connector/CC = available_sockets[choice]
|
||||
if(REMB)
|
||||
if(REMB.get_carrier() == CC.get_carrier())
|
||||
to_chat(user, span_notice("Connecting \the [REMB.get_carrier()] to itself seems like a bad idea. You wind \the [src] back up."))
|
||||
@@ -82,7 +83,7 @@
|
||||
|
||||
else if(REMB.valid_connection(CC))
|
||||
var/distancetonode = get_dist(REMB.get_carrier(), CC.get_carrier())
|
||||
if(distancetonode > world.view)
|
||||
if(distancetonode > HOSE_MAX_DISTANCE)
|
||||
to_chat(user, span_notice("\The [src] would probably burst if it were this long. You wind \the [src] back up."))
|
||||
remembered = null // Unintuitive if it does not reset state
|
||||
|
||||
|
||||
Reference in New Issue
Block a user