From dcee556d33ce78e257e29848265d561d6db2086e Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Wed, 4 Aug 2021 16:08:29 +0200 Subject: [PATCH] [MIRROR] Adds conveyor switch and quantum pad USBs (#7379) * Adds conveyor switch and quantum pad USBs (#60532) * Adds conveyor switch and quantum pad USBs Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com> --- code/game/machinery/quantum_pad.dm | 72 +++++++++++++++++++++++++++-- code/modules/recycling/conveyor2.dm | 39 ++++++++++++++++ 2 files changed, 108 insertions(+), 3 deletions(-) diff --git a/code/game/machinery/quantum_pad.dm b/code/game/machinery/quantum_pad.dm index 4a978a018c8..0ec9171d298 100644 --- a/code/game/machinery/quantum_pad.dm +++ b/code/game/machinery/quantum_pad.dm @@ -25,6 +25,10 @@ if(map_pad_id) mapped_quantum_pads[map_pad_id] = src + AddComponent(/datum/component/usb_port, list( + /obj/item/circuit_component/quantumpad, + )) + /obj/machinery/quantumpad/Destroy() mapped_quantum_pads -= map_pad_id return ..() @@ -138,7 +142,7 @@ if(linked_pad) ghost.forceMove(get_turf(linked_pad)) -/obj/machinery/quantumpad/proc/doteleport(mob/user, obj/machinery/quantumpad/target_pad = linked_pad) +/obj/machinery/quantumpad/proc/doteleport(mob/user = null, obj/machinery/quantumpad/target_pad = linked_pad) if(target_pad) playsound(get_turf(src), 'sound/weapons/flash.ogg', 25, TRUE) teleporting = TRUE @@ -148,11 +152,13 @@ teleporting = FALSE return if(machine_stat & NOPOWER) - to_chat(user, span_warning("[src] is unpowered!")) + if(user) + to_chat(user, span_warning("[src] is unpowered!")) teleporting = FALSE return if(!target_pad || QDELETED(target_pad) || target_pad.machine_stat & NOPOWER) - to_chat(user, span_warning("Linked pad is not responding to ping. Teleport aborted.")) + if(user) + to_chat(user, span_warning("Linked pad is not responding to ping. Teleport aborted.")) teleporting = FALSE return @@ -196,3 +202,63 @@ /obj/item/paper/guides/quantumpad name = "Quantum Pad For Dummies" info = "
Dummies Guide To Quantum Pads


Do you hate the concept of having to use your legs, let alone walk to places? Well, with the Quantum Pad (tm), never again will the fear of cardio keep you from going places!

How to set up your Quantum Pad(tm)


1.Unscrew the Quantum Pad(tm) you wish to link.
2. Use your multi-tool to cache the buffer of the Quantum Pad(tm) you wish to link.
3. Apply the multi-tool to the secondary Quantum Pad(tm) you wish to link to the first Quantum Pad(tm)

If you followed these instructions carefully, your Quantum Pad(tm) should now be properly linked together for near-instant movement across the station! Bear in mind that this is technically a one-way teleport, so you'll need to do the same process with the secondary pad to the first one if you wish to travel between both.
" + +/obj/item/circuit_component/quantumpad + display_name = "Quantum Pad" + desc = "A bluespace quantum-linked telepad used for teleporting objects to other quantum pads." + circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL + + var/datum/port/input/target_pad + var/datum/port/output/failed + + var/obj/machinery/quantumpad/attached_pad + +/obj/item/circuit_component/quantumpad/Initialize() + . = ..() + target_pad = add_input_port("Target Pad", PORT_TYPE_ATOM) + failed = add_output_port("On Fail", PORT_TYPE_SIGNAL) + +/obj/item/circuit_component/quantumpad/register_usb_parent(atom/movable/parent) + . = ..() + if(istype(parent, /obj/machinery/quantumpad)) + attached_pad = parent + +/obj/item/circuit_component/quantumpad/unregister_usb_parent(atom/movable/parent) + attached_pad = null + return ..() + +/obj/item/circuit_component/quantumpad/input_received(datum/port/input/port) + . = ..() + if(. || !attached_pad) + return + + var/obj/machinery/quantumpad/targeted_pad = target_pad.input_value + + if((!attached_pad.linked_pad || QDELETED(attached_pad.linked_pad)) && !(targeted_pad && istype(targeted_pad))) + failed.set_output(COMPONENT_SIGNAL) + return + + if(world.time < attached_pad.last_teleport + attached_pad.teleport_cooldown) + failed.set_output(COMPONENT_SIGNAL) + return + + if(targeted_pad && istype(targeted_pad)) + if(attached_pad.teleporting || targeted_pad.teleporting) + failed.set_output(COMPONENT_SIGNAL) + return + + if(targeted_pad.machine_stat & NOPOWER) + failed.set_output(COMPONENT_SIGNAL) + return + attached_pad.doteleport(target_pad = targeted_pad) + else + if(attached_pad.teleporting || attached_pad.linked_pad.teleporting) + failed.set_output(COMPONENT_SIGNAL) + return + + if(attached_pad.linked_pad.machine_stat & NOPOWER) + failed.set_output(COMPONENT_SIGNAL) + return + attached_pad.doteleport(target_pad = attached_pad.linked_pad) + + diff --git a/code/modules/recycling/conveyor2.dm b/code/modules/recycling/conveyor2.dm index 29019a25a97..fe555a342b6 100644 --- a/code/modules/recycling/conveyor2.dm +++ b/code/modules/recycling/conveyor2.dm @@ -262,6 +262,9 @@ GLOBAL_LIST_EMPTY(conveyors_by_id) update_appearance() LAZYADD(GLOB.conveyors_by_id[id], src) wires = new /datum/wires/conveyor(src) + AddComponent(/datum/component/usb_port, list( + /obj/item/circuit_component/conveyor_switch, + )) /obj/machinery/conveyor_switch/Destroy() LAZYREMOVE(GLOB.conveyors_by_id[id], src) @@ -455,3 +458,39 @@ GLOBAL_LIST_EMPTY(conveyors_by_id) info = "

Congratulations!

You are now the proud owner of the best conveyor set available for space mail order! We at Nano-it-up know you love to prepare your own structures without wasting time, so we have devised a special streamlined assembly procedure that puts all other mail-order products to shame!

Firstly, you need to link the conveyor switch assembly to each of the conveyor belt assemblies. After doing so, you simply need to install the belt assemblies onto the floor, et voila, belt built. Our special Nano-it-up smart switch will detected any linked assemblies as far as the eye can see! This convenience, you can only have it when you Nano-it-up. Stay nano!

" #undef MAX_CONVEYOR_ITEMS_MOVE + +/obj/item/circuit_component/conveyor_switch + display_name = "Conveyor Switch" + desc = "Allows to control connected conveyor belts." + circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL + + var/datum/port/output/direction + var/obj/machinery/conveyor_switch/attached_switch + +/obj/item/circuit_component/conveyor_switch/Initialize() + . = ..() + direction = add_output_port("Conveyor Direction", PORT_TYPE_NUMBER) + +/obj/item/circuit_component/conveyor_switch/get_ui_notices() + . = ..() + . += create_ui_notice("Conveyor direction 0 means that it is stopped, 1 means that it is active and -1 means that it is working in reverse mode", "orange", "info") + +/obj/item/circuit_component/conveyor_switch/register_usb_parent(atom/movable/parent) + . = ..() + if(istype(parent, /obj/machinery/conveyor_switch)) + attached_switch = parent + +/obj/item/circuit_component/conveyor_switch/unregister_usb_parent(atom/movable/parent) + attached_switch = null + return ..() + +/obj/item/circuit_component/conveyor_switch/input_received(datum/port/input/port) + . = ..() + if(. || !attached_switch) + return + + attached_switch.update_position() + attached_switch.update_appearance() + attached_switch.update_linked_conveyors() + attached_switch.update_linked_switches() + direction.set_output(attached_switch.position)