diff --git a/code/__DEFINES/traits.dm b/code/__DEFINES/traits.dm index 413de14d122..e424326d7bf 100644 --- a/code/__DEFINES/traits.dm +++ b/code/__DEFINES/traits.dm @@ -534,6 +534,9 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai /// Trait applied when an integrated circuit/module becomes undupable #define TRAIT_CIRCUIT_UNDUPABLE "circuit_undupable" +/// Hearing trait that is from the hearing component +#define CIRCUIT_HEAR_TRAIT "circuit_hear" + /// If present on a [/mob/living/carbon], will make them appear to have a medium level disease on health HUDs. #define TRAIT_DISEASELIKE_SEVERITY_MEDIUM "diseaselike_severity_medium" diff --git a/code/datums/components/shell.dm b/code/datums/components/shell.dm index 037aaea617b..b3ce2396949 100644 --- a/code/datums/components/shell.dm +++ b/code/datums/components/shell.dm @@ -95,7 +95,7 @@ /datum/component/shell/proc/on_object_deconstruct() SIGNAL_HANDLER - if(!attached_circuit?.admin_only) + if(!(shell_flags & SHELL_FLAG_CIRCUIT_FIXED) && !attached_circuit?.admin_only) remove_circuit() /datum/component/shell/proc/on_attack_ghost(datum/source, mob/dead/observer/ghost) @@ -265,13 +265,13 @@ return locked = FALSE attached_circuit = circuitboard - RegisterSignal(circuitboard, COMSIG_MOVABLE_MOVED, .proc/on_circuit_moved) + if(!(shell_flags & SHELL_FLAG_CIRCUIT_FIXED) && !circuitboard.admin_only) + RegisterSignal(circuitboard, COMSIG_MOVABLE_MOVED, .proc/on_circuit_moved) RegisterSignal(circuitboard, COMSIG_PARENT_QDELETING, .proc/on_circuit_delete) for(var/obj/item/circuit_component/to_add as anything in unremovable_circuit_components) to_add.forceMove(attached_circuit) attached_circuit.add_component(to_add) RegisterSignal(circuitboard, COMSIG_CIRCUIT_ADD_COMPONENT_MANUALLY, .proc/on_circuit_add_component_manually) - attached_circuit.set_shell(parent_atom) if(attached_circuit.display_name != "") parent_atom.name = "[initial(parent_atom.name)] ([attached_circuit.display_name])" attached_circuit.set_locked(FALSE) @@ -279,8 +279,11 @@ if(shell_flags & SHELL_FLAG_REQUIRE_ANCHOR) attached_circuit.on = parent_atom.anchored - if(circuitboard.loc != parent_atom) + if((shell_flags & SHELL_FLAG_CIRCUIT_FIXED) || circuitboard.admin_only) + circuitboard.moveToNullspace() + else if(circuitboard.loc != parent_atom) circuitboard.forceMove(parent_atom) + attached_circuit.set_shell(parent_atom) /** * Removes the circuit from the component. Doesn't do any checks to see for an existing circuit so that should be done beforehand. @@ -293,7 +296,7 @@ COMSIG_PARENT_QDELETING, COMSIG_CIRCUIT_ADD_COMPONENT_MANUALLY, )) - if(attached_circuit.loc == parent) + if(attached_circuit.loc == parent || (!QDELETED(attached_circuit) && attached_circuit.loc == null)) var/atom/parent_atom = parent attached_circuit.forceMove(parent_atom.drop_location()) diff --git a/code/modules/wiremod/components/action/pathfind.dm b/code/modules/wiremod/components/action/pathfind.dm index eac9633ed24..540e228ee10 100644 --- a/code/modules/wiremod/components/action/pathfind.dm +++ b/code/modules/wiremod/components/action/pathfind.dm @@ -63,7 +63,7 @@ reason_failed.set_output("Object marked is not an ID! Using no ID instead.") // Get both the current turf and the destination's turf - var/turf/current_turf = get_turf(src) + var/turf/current_turf = get_location() var/turf/destination = locate(target_X, target_Y, current_turf?.z) // We're already here! No need to do anything. diff --git a/code/modules/wiremod/components/atom/direction.dm b/code/modules/wiremod/components/atom/direction.dm index 67e9b6ff496..c2bbd5026c8 100644 --- a/code/modules/wiremod/components/atom/direction.dm +++ b/code/modules/wiremod/components/atom/direction.dm @@ -44,7 +44,7 @@ var/atom/object = input_port.value if(!object) return - var/turf/location = get_turf(src) + var/turf/location = get_location() if(object.z != location.z || get_dist(location, object) > max_range) output.set_output(null) diff --git a/code/modules/wiremod/components/atom/gps.dm b/code/modules/wiremod/components/atom/gps.dm index c9ede5ef01f..109309a01af 100644 --- a/code/modules/wiremod/components/atom/gps.dm +++ b/code/modules/wiremod/components/atom/gps.dm @@ -22,7 +22,7 @@ /obj/item/circuit_component/gps/input_received(datum/port/input/port) - var/turf/location = get_turf(src) + var/turf/location = get_location() x_pos.set_output(location?.x) y_pos.set_output(location?.y) diff --git a/code/modules/wiremod/components/atom/health.dm b/code/modules/wiremod/components/atom/health.dm index 637a032815c..ee04030259e 100644 --- a/code/modules/wiremod/components/atom/health.dm +++ b/code/modules/wiremod/components/atom/health.dm @@ -42,7 +42,7 @@ /obj/item/circuit_component/health/input_received(datum/port/input/port) var/mob/living/organism = input_port.value - var/turf/current_turf = get_turf(src) + var/turf/current_turf = get_location() if(!istype(organism) || get_dist(current_turf, organism) > max_range || current_turf.z != organism.z) brute.set_output(null) burn.set_output(null) diff --git a/code/modules/wiremod/components/atom/hear.dm b/code/modules/wiremod/components/atom/hear.dm index 6832ecca291..1c6c0f3eb1a 100644 --- a/code/modules/wiremod/components/atom/hear.dm +++ b/code/modules/wiremod/components/atom/hear.dm @@ -27,6 +27,17 @@ trigger_port = add_output_port("Triggered", PORT_TYPE_SIGNAL) become_hearing_sensitive(ROUNDSTART_TRAIT) +/obj/item/circuit_component/hear/register_shell(atom/movable/shell) + if(parent.loc != shell) + shell.become_hearing_sensitive(CIRCUIT_HEAR_TRAIT) + RegisterSignal(shell, COMSIG_MOVABLE_HEAR, .proc/on_shell_hear) + +/obj/item/circuit_component/hear/unregister_shell(atom/movable/shell) + REMOVE_TRAIT(shell, TRAIT_HEARING_SENSITIVE, CIRCUIT_HEAR_TRAIT) + +/obj/item/circuit_component/hear/proc/on_shell_hear(datum/source, list/arguments) + return Hear(arglist(arguments)) + /obj/item/circuit_component/hear/Hear(message, atom/movable/speaker, datum/language/message_language, raw_message, radio_freq, list/spans, list/message_mods) if(speaker == parent?.shell) return diff --git a/code/modules/wiremod/components/atom/pinpointer.dm b/code/modules/wiremod/components/atom/pinpointer.dm index 0b6e59c5837..0fead69d401 100644 --- a/code/modules/wiremod/components/atom/pinpointer.dm +++ b/code/modules/wiremod/components/atom/pinpointer.dm @@ -38,7 +38,7 @@ var/atom/target_entity = target.value - if(is_in_sight(target_entity, get_turf(src)) && IN_GIVEN_RANGE(get_turf(src), target_entity, max_range)) + if(is_in_sight(target_entity, get_location()) && IN_GIVEN_RANGE(get_location(), target_entity, max_range)) var/turf/location = get_turf(target_entity) x_pos.set_output(location?.x) diff --git a/code/modules/wiremod/components/sensors/pressuresensor.dm b/code/modules/wiremod/components/sensors/pressuresensor.dm index 3914f4460fb..06e45cc688a 100644 --- a/code/modules/wiremod/components/sensors/pressuresensor.dm +++ b/code/modules/wiremod/components/sensors/pressuresensor.dm @@ -18,7 +18,7 @@ /obj/item/circuit_component/pressuresensor/input_received(datum/port/input/port) //Get current turf - var/turf/location = get_turf(src) + var/turf/location = get_location() if(!location) result.set_output(null) return diff --git a/code/modules/wiremod/components/sensors/tempsensor.dm b/code/modules/wiremod/components/sensors/tempsensor.dm index 0c7fd03321b..e88d5dea1c3 100644 --- a/code/modules/wiremod/components/sensors/tempsensor.dm +++ b/code/modules/wiremod/components/sensors/tempsensor.dm @@ -18,7 +18,7 @@ /obj/item/circuit_component/tempsensor/input_received(datum/port/input/port) //Get current turf - var/turf/location = get_turf(src) + var/turf/location = get_location() if(!location) result.set_output(null) return diff --git a/code/modules/wiremod/components/string/tostring.dm b/code/modules/wiremod/components/string/tostring.dm index 9847fca1cf0..37cd445e00a 100644 --- a/code/modules/wiremod/components/string/tostring.dm +++ b/code/modules/wiremod/components/string/tostring.dm @@ -26,7 +26,7 @@ var/value = input_port.value if(isatom(value)) - var/turf/location = get_turf(src) + var/turf/location = get_location() var/turf/target_location = get_turf(value) if(target_location.z != location.z || get_dist(location, target_location) > max_range) output.set_output(PORT_TYPE_ATOM) diff --git a/code/modules/wiremod/core/component.dm b/code/modules/wiremod/core/component.dm index 390c85e50f7..7fdce13021b 100644 --- a/code/modules/wiremod/core/component.dm +++ b/code/modules/wiremod/core/component.dm @@ -101,6 +101,11 @@ QDEL_LIST(input_ports) return ..() +/obj/item/circuit_component/drop_location() + if(parent?.shell) + return parent.shell.drop_location() + return ..() + /obj/item/circuit_component/examine(mob/user) . = ..() if(circuit_flags & CIRCUIT_FLAG_REFUSE_MODULE) @@ -266,6 +271,10 @@ return TRUE +/// Called when trying to get the physical location of this object +/obj/item/circuit_component/proc/get_location() + return get_turf(src) || get_turf(parent?.shell) + /// Called before input_received and should_receive_input. Used to perform behaviour that shouldn't care whether the input should be received or not. /obj/item/circuit_component/proc/pre_input_received(datum/port/input/port) SHOULD_NOT_SLEEP(TRUE) diff --git a/code/modules/wiremod/core/integrated_circuit.dm b/code/modules/wiremod/core/integrated_circuit.dm index 0859c80242b..ebe020c1a0e 100644 --- a/code/modules/wiremod/core/integrated_circuit.dm +++ b/code/modules/wiremod/core/integrated_circuit.dm @@ -106,6 +106,11 @@ GLOBAL_LIST_EMPTY_TYPED(integrated_circuits, /obj/item/integrated_circuit) else . += span_notice("There is no power cell installed.") +/obj/item/integrated_circuit/drop_location() + if(shell) + return shell.drop_location() + return ..() + /** * Sets the cell of the integrated circuit. * @@ -626,6 +631,11 @@ GLOBAL_LIST_EMPTY_TYPED(integrated_circuits, /obj/item/integrated_circuit) #undef WITHIN_RANGE +/obj/item/integrated_circuit/balloon_alert(mob/viewer, text) + if(shell) + return shell.balloon_alert(viewer, text) + return ..() + /obj/item/integrated_circuit/proc/clear_setter_or_getter(datum/source) SIGNAL_HANDLER // This'll also be called in the Destroy() override of /obj/item/circuit_component diff --git a/code/modules/wiremod/shell/bot.dm b/code/modules/wiremod/shell/bot.dm index b07265d4503..ca7cab94d21 100644 --- a/code/modules/wiremod/shell/bot.dm +++ b/code/modules/wiremod/shell/bot.dm @@ -34,11 +34,6 @@ entity = add_output_port("User", PORT_TYPE_ATOM) signal = add_output_port("Signal", PORT_TYPE_SIGNAL) -/obj/item/circuit_component/bot/Destroy() - signal = null - entity = null - return ..() - /obj/item/circuit_component/bot/register_shell(atom/movable/shell) RegisterSignal(shell, COMSIG_ATOM_ATTACK_HAND, .proc/on_attack_hand)