mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-27 07:08:00 +01:00
[MIRROR] More circuit components. Restructures the circuit components folder to be more organised. (#6142)
* More circuit components. Restructures the circuit components folder to be more organised. * Mirror! Co-authored-by: Watermelon914 <37270891+Watermelon914@users.noreply.github.com> Co-authored-by: Funce <funce.973@gmail.com>
This commit is contained in:
co-authored by
Watermelon914
Funce
parent
6e52d05e2e
commit
cc5cf407b0
@@ -14,6 +14,8 @@
|
||||
/// A list of components that cannot be removed
|
||||
var/list/obj/item/circuit_component/unremovable_circuit_components
|
||||
|
||||
var/locked = FALSE
|
||||
|
||||
/datum/component/shell/Initialize(unremovable_circuit_components, capacity, shell_flags)
|
||||
. = ..()
|
||||
if(!ismovable(parent))
|
||||
@@ -33,14 +35,17 @@
|
||||
if(!(shell_flags & SHELL_FLAG_CIRCUIT_FIXED))
|
||||
RegisterSignal(parent, COMSIG_ATOM_TOOL_ACT(TOOL_SCREWDRIVER), .proc/on_screwdriver_act)
|
||||
RegisterSignal(parent, COMSIG_ATOM_TOOL_ACT(TOOL_MULTITOOL), .proc/on_multitool_act)
|
||||
RegisterSignal(parent, COMSIG_OBJ_DECONSTRUCT, .proc/on_object_deconstruct)
|
||||
if(shell_flags & SHELL_FLAG_REQUIRE_ANCHOR)
|
||||
RegisterSignal(parent, COMSIG_OBJ_DEFAULT_UNFASTEN_WRENCH, .proc/on_unfasten)
|
||||
|
||||
|
||||
/datum/component/shell/UnregisterFromParent()
|
||||
UnregisterSignal(parent, list(
|
||||
COMSIG_PARENT_ATTACKBY,
|
||||
COMSIG_ATOM_TOOL_ACT(TOOL_SCREWDRIVER),
|
||||
COMSIG_ATOM_TOOL_ACT(TOOL_MULTITOOL),
|
||||
COMSIG_OBJ_DECONSTRUCT,
|
||||
COMSIG_OBJ_DEFAULT_UNFASTEN_WRENCH,
|
||||
COMSIG_PARENT_EXAMINE,
|
||||
COMSIG_ATOM_ATTACK_GHOST
|
||||
@@ -52,6 +57,10 @@
|
||||
QDEL_LIST(unremovable_circuit_components)
|
||||
return ..()
|
||||
|
||||
/datum/component/shell/proc/on_object_deconstruct()
|
||||
SIGNAL_HANDLER
|
||||
remove_circuit()
|
||||
|
||||
/datum/component/shell/proc/on_attack_ghost(datum/source, mob/dead/observer/ghost)
|
||||
SIGNAL_HANDLER
|
||||
if(attached_circuit)
|
||||
@@ -60,9 +69,11 @@
|
||||
/datum/component/shell/proc/on_examine(datum/source, mob/user, list/examine_text)
|
||||
SIGNAL_HANDLER
|
||||
if(!attached_circuit)
|
||||
examine_text += "<span class='notice'>There is no integrated circuit attached.</span>"
|
||||
return
|
||||
|
||||
examine_text += "<span class='notice'>There is an integrated circuit attached. Use a multitool to access the wiring. Use a screwdriver to remove it from [source].</span>"
|
||||
examine_text += "<span class='notice'>The cover panel to the integrated circuit is [locked? "locked" : "unlocked"].</span>"
|
||||
var/obj/item/stock_parts/cell/cell = attached_circuit.cell
|
||||
examine_text += "<span class='notice'>The charge meter reads [cell ? round(cell.percent(), 1) : 0]%.</span>"
|
||||
|
||||
@@ -85,6 +96,11 @@
|
||||
source.balloon_alert(attacker, "can't pull cell in directly!")
|
||||
return
|
||||
|
||||
if(attached_circuit?.owner_id && item == attached_circuit.owner_id.resolve())
|
||||
locked = !locked
|
||||
source.balloon_alert(attacker, "[locked? "locked" : "unlocked"] [source]")
|
||||
return COMPONENT_NO_AFTERATTACK
|
||||
|
||||
if(!istype(item, /obj/item/integrated_circuit))
|
||||
return
|
||||
var/obj/item/integrated_circuit/logic_board = item
|
||||
@@ -108,6 +124,10 @@
|
||||
if(!attached_circuit)
|
||||
return
|
||||
|
||||
if(locked)
|
||||
source.balloon_alert(user, "it's locked!")
|
||||
return COMPONENT_BLOCK_TOOL_ATTACK
|
||||
|
||||
attached_circuit.interact(user)
|
||||
return COMPONENT_BLOCK_TOOL_ATTACK
|
||||
|
||||
@@ -119,8 +139,12 @@
|
||||
if(!attached_circuit)
|
||||
return
|
||||
|
||||
if(locked)
|
||||
source.balloon_alert(user, "it's locked!")
|
||||
return COMPONENT_BLOCK_TOOL_ATTACK
|
||||
|
||||
tool.play_tool_sound(parent)
|
||||
source.balloon_alert(user, "You unscrew [attached_circuit] from [parent].")
|
||||
source.balloon_alert(user, "you unscrew [attached_circuit] from [parent].")
|
||||
remove_circuit()
|
||||
return COMPONENT_BLOCK_TOOL_ATTACK
|
||||
|
||||
@@ -149,6 +173,7 @@
|
||||
/datum/component/shell/proc/attach_circuit(obj/item/integrated_circuit/circuitboard, mob/living/user)
|
||||
if(!user.transferItemToLoc(circuitboard, parent))
|
||||
return
|
||||
locked = FALSE
|
||||
attached_circuit = circuitboard
|
||||
RegisterSignal(circuitboard, COMSIG_MOVABLE_MOVED, .proc/on_circuit_moved)
|
||||
RegisterSignal(circuitboard, COMSIG_PARENT_QDELETING, .proc/on_circuit_delete)
|
||||
|
||||
Reference in New Issue
Block a user