Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] General maintenance for frames #2147

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/__DEFINES/construction/structures.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#define GEAR_SECURE 1
#define GEAR_LOOSE 2

// Stationary gas tanks
//Stationary gas tanks
#define TANK_FRAME 0
#define TANK_PLATING_UNSECURED 1

Expand Down
233 changes: 166 additions & 67 deletions code/game/machinery/computer/buildandrepair.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,92 @@
/obj/structure/frame/computer/Initialize(mapload)
. = ..()
AddComponent(/datum/component/simple_rotation)
register_context()
update_appearance(UPDATE_ICON_STATE)

/obj/structure/frame/computer/deconstruct(disassembled = TRUE)
if(!(obj_flags & NO_DECONSTRUCTION))
var/atom/drop_loc = drop_location()
if(state == FRAME_COMPUTER_STATE_GLASSED)
if(disassembled)
new /obj/item/stack/sheet/glass(drop_loc, 2)
else
new /obj/item/shard(drop_loc)
new /obj/item/shard(drop_loc)
if(state >= FRAME_COMPUTER_STATE_WIRED)
new /obj/item/stack/cable_coil(drop_loc, 5)

return ..()

/obj/structure/frame/computer/add_context(atom/source, list/context, obj/item/held_item, mob/user)
. = NONE
if(isnull(held_item))
return

switch(state)
if(FRAME_COMPUTER_STATE_EMPTY)
if(held_item.tool_behaviour == TOOL_WRENCH)
context[SCREENTIP_CONTEXT_LMB] = "[anchored ? "Un" : ""]anchor"
return CONTEXTUAL_SCREENTIP_SET
else if(anchored && istype(held_item, /obj/item/circuitboard/computer))
context[SCREENTIP_CONTEXT_LMB] = "Install board"
return CONTEXTUAL_SCREENTIP_SET
else if(held_item.tool_behaviour == TOOL_WELDER)
context[SCREENTIP_CONTEXT_LMB] = "Unweld frame"
return CONTEXTUAL_SCREENTIP_SET
else if(held_item.tool_behaviour == TOOL_SCREWDRIVER)
context[SCREENTIP_CONTEXT_LMB] = "Disassemble frame"
return CONTEXTUAL_SCREENTIP_SET
if(FRAME_COMPUTER_STATE_BOARD_INSTALLED)
if(held_item.tool_behaviour == TOOL_CROWBAR)
context[SCREENTIP_CONTEXT_LMB] = "Pry out board"
return CONTEXTUAL_SCREENTIP_SET
else if(held_item.tool_behaviour == TOOL_SCREWDRIVER)
context[SCREENTIP_CONTEXT_LMB] = "Secure board"
return CONTEXTUAL_SCREENTIP_SET
if(FRAME_COMPUTER_STATE_BOARD_SECURED)
if(held_item.tool_behaviour == TOOL_SCREWDRIVER)
context[SCREENTIP_CONTEXT_LMB] = "Unsecure board"
return CONTEXTUAL_SCREENTIP_SET
else if(istype(held_item, /obj/item/stack/cable_coil))
context[SCREENTIP_CONTEXT_LMB] = "Install cable"
return CONTEXTUAL_SCREENTIP_SET
if(FRAME_COMPUTER_STATE_WIRED)
if(held_item.tool_behaviour == TOOL_WIRECUTTER)
context[SCREENTIP_CONTEXT_LMB] = "Cut out cable"
return CONTEXTUAL_SCREENTIP_SET
else if(istype(held_item, /obj/item/stack/sheet/glass))
context[SCREENTIP_CONTEXT_LMB] = "Install panel"
return CONTEXTUAL_SCREENTIP_SET
if(FRAME_COMPUTER_STATE_GLASSED)
if(held_item.tool_behaviour == TOOL_CROWBAR)
context[SCREENTIP_CONTEXT_LMB] = "Pry out glass"
return CONTEXTUAL_SCREENTIP_SET
else if(held_item.tool_behaviour == TOOL_SCREWDRIVER)
context[SCREENTIP_CONTEXT_LMB] = "Complete frame"
return CONTEXTUAL_SCREENTIP_SET

/obj/structure/frame/computer/examine(user)
. = ..()

switch(state)
if(FRAME_STATE_EMPTY)
. += span_notice("It can be [EXAMINE_HINT("wrenched")] [anchored ? "loose" : "in place"].")
if(anchored)
. += span_warning("It's missing a circuit board.")
. += span_notice("It can be [EXAMINE_HINT("welded")] or [EXAMINE_HINT("screwed")] apart.")
if(FRAME_COMPUTER_STATE_BOARD_INSTALLED)
. += span_warning("An [circuit.name] is installed and should be [EXAMINE_HINT("screwed")] in place.")
. += span_notice("The circuit board can be [EXAMINE_HINT("pried")] out.")
if(FRAME_COMPUTER_STATE_BOARD_SECURED)
. += span_warning("Its requires [EXAMINE_HINT("5 cable")] pieces to wire it.")
. += span_notice("The circuit board can be [EXAMINE_HINT("screwed")] loose.")
if(FRAME_COMPUTER_STATE_WIRED)
. += span_notice("The wires can be cut out with [EXAMINE_HINT("wire cutters")].")
. += span_warning("Its requires [EXAMINE_HINT("2 glass")] sheets to complete the screen.")
if(FRAME_COMPUTER_STATE_GLASSED)
. += span_notice("The screen can be [EXAMINE_HINT("pried")] out.")
. += span_notice("The moniter can be [EXAMINE_HINT("screwed")] to complete it")

/obj/structure/frame/computer/circuit_added(obj/item/circuitboard/added)
state = FRAME_COMPUTER_STATE_BOARD_INSTALLED
Expand All @@ -22,7 +108,45 @@
if(state != FRAME_COMPUTER_STATE_EMPTY)
balloon_alert(user, "circuit already installed!")
return FALSE
return ..()
if(!anchored && istype(board))
balloon_alert(user, "frame must be anchored!")
return FALSE
. = ..()
if(. && !by_hand) // Installing via RPED auto-secures it
state = FRAME_COMPUTER_STATE_BOARD_SECURED
update_appearance(UPDATE_ICON_STATE)
return .

/obj/structure/frame/computer/install_parts_from_part_replacer(mob/living/user, obj/item/storage/part_replacer/replacer, no_sound = FALSE)
switch(state)
if(FRAME_COMPUTER_STATE_BOARD_SECURED)
var/obj/item/stack/cable_coil/cable = locate() in replacer
if(isnull(cable))
return FALSE

if(add_cabling(user, cable, time = 0))
if(!no_sound)
replacer.play_rped_sound()
if(replacer.works_from_distance)
user.Beam(src, icon_state = "rped_upgrade", time = 0.5 SECONDS)
no_sound = TRUE
return install_parts_from_part_replacer(user, replacer, no_sound = no_sound) // Recursive call to handle the next part

return FALSE

if(FRAME_COMPUTER_STATE_WIRED)
var/obj/item/stack/sheet/glass/glass_sheets = locate() in replacer
if(isnull(glass_sheets))
return FALSE

if(add_glass(user, glass_sheets, time = 0))
if(!no_sound)
replacer.play_rped_sound()
if(replacer.works_from_distance)
user.Beam(src, icon_state = "rped_upgrade", time = 0.5 SECONDS)
return TRUE

return FALSE

/obj/structure/frame/computer/item_interaction(mob/living/user, obj/item/tool, list/modifiers, is_right_clicking)
. = ..()
Expand All @@ -48,11 +172,9 @@
if(istype(tool, /obj/item/storage/part_replacer))
return install_parts_from_part_replacer(user, tool) ? ITEM_INTERACT_SUCCESS : ITEM_INTERACT_BLOCKING

return .

/obj/structure/frame/computer/screwdriver_act(mob/living/user, obj/item/tool)
. = ..()
if(. != NONE)
if(. & ITEM_INTERACT_ANY_BLOCKER)
return .

switch(state)
Expand Down Expand Up @@ -83,6 +205,9 @@
return ITEM_INTERACT_BLOCKING

/obj/structure/frame/computer/crowbar_act(mob/living/user, obj/item/tool)
if(user.combat_mode)
return NONE

switch(state)
if(FRAME_COMPUTER_STATE_BOARD_INSTALLED)
tool.play_tool_sound(src)
Expand All @@ -92,14 +217,12 @@
return ITEM_INTERACT_SUCCESS

if(FRAME_COMPUTER_STATE_BOARD_SECURED)
if(!user.combat_mode)
balloon_alert(user, "unsecure the circuit!")
return ITEM_INTERACT_BLOCKING
balloon_alert(user, "unsecure the circuit!")
return ITEM_INTERACT_BLOCKING

if(FRAME_COMPUTER_STATE_WIRED)
if(!user.combat_mode)
balloon_alert(user, "remove the wiring!")
return ITEM_INTERACT_BLOCKING
balloon_alert(user, "remove the wiring!")
return ITEM_INTERACT_BLOCKING

if(FRAME_COMPUTER_STATE_GLASSED)
tool.play_tool_sound(src)
Expand All @@ -111,38 +234,34 @@
dropped_glass.add_fingerprint(user)
return ITEM_INTERACT_SUCCESS

/obj/structure/frame/computer/install_parts_from_part_replacer(mob/living/user, obj/item/storage/part_replacer/replacer, no_sound = FALSE)
switch(state)
if(FRAME_COMPUTER_STATE_BOARD_SECURED)
var/obj/item/stack/cable_coil/cable = locate() in replacer
if(isnull(cable))
return FALSE

if(add_cabling(user, cable, time = 0))
if(!no_sound)
replacer.play_rped_sound()
if(replacer.works_from_distance)
user.Beam(src, icon_state = "rped_upgrade", time = 0.5 SECONDS)
no_sound = TRUE
return install_parts_from_part_replacer(user, replacer, no_sound = no_sound) // Recursive call to handle the next part

return FALSE
/obj/structure/frame/computer/wirecutter_act(mob/living/user, obj/item/tool)
if(user.combat_mode)
return NONE

if(FRAME_COMPUTER_STATE_WIRED)
var/obj/item/stack/sheet/glass/glass_sheets = locate() in replacer
if(isnull(glass_sheets))
return FALSE
if(state != FRAME_COMPUTER_STATE_WIRED)
return ITEM_INTERACT_BLOCKING

if(add_glass(user, glass_sheets, time = 0))
if(!no_sound)
replacer.play_rped_sound()
if(replacer.works_from_distance)
user.Beam(src, icon_state = "rped_upgrade", time = 0.5 SECONDS)
return TRUE
tool.play_tool_sound(src)
balloon_alert(user, "cables removed")
state = FRAME_COMPUTER_STATE_BOARD_SECURED
update_appearance(UPDATE_ICON_STATE)

return FALSE
var/obj/item/stack/cable_coil/dropped_cables = new (drop_location(), 5)
if (!QDELETED(dropped_cables))
dropped_cables.add_fingerprint(user)
return ITEM_INTERACT_SUCCESS

/**
* Adds cable to the computer to wire it
* Arguments
*
* * mob/living/user - the player who is adding the cable
* * obj/item/stack/cable_coil/cable - the cable we are trying to add
* * time - time taken to complete the operation
*/
/obj/structure/frame/computer/proc/add_cabling(mob/living/user, obj/item/stack/cable_coil/cable, time = 2 SECONDS)
PRIVATE_PROC(TRUE)

if(state != FRAME_COMPUTER_STATE_BOARD_SECURED)
return FALSE
if(!cable.tool_start_check(user, amount = 5))
Expand All @@ -156,7 +275,17 @@
update_appearance(UPDATE_ICON_STATE)
return TRUE

/**
* Adds glass sheets to the computer to complete the screen
* Arguments
*
* * mob/living/user - the player who is adding the glass
* * obj/item/stack/sheet/glass/glass - the glass we are trying to add
* * time - time taken to complete the operation
*/
/obj/structure/frame/computer/proc/add_glass(mob/living/user, obj/item/stack/sheet/glass/glass, time = 2 SECONDS)
PRIVATE_PROC(TRUE)

if(state != FRAME_COMPUTER_STATE_WIRED)
return FALSE
if(!glass.tool_start_check(user, amount = 2))
Expand All @@ -171,22 +300,6 @@
update_appearance(UPDATE_ICON_STATE)
return TRUE

/obj/structure/frame/computer/wirecutter_act(mob/living/user, obj/item/tool)
if(state != FRAME_COMPUTER_STATE_WIRED)
return NONE

tool.play_tool_sound(src)
balloon_alert(user, "cables removed")
state = FRAME_COMPUTER_STATE_BOARD_SECURED
update_appearance(UPDATE_ICON_STATE)
var/obj/item/stack/cable_coil/dropped_cables = new (drop_location(), 5)
if (!QDELETED(dropped_cables))
dropped_cables.add_fingerprint(user)
return ITEM_INTERACT_SUCCESS

/obj/structure/frame/computer/AltClick(mob/user)
return ..() // This hotkey is BLACKLISTED since it's used by /datum/component/simple_rotation

/obj/structure/frame/computer/finalize_construction(mob/living/user, obj/item/tool)
tool.play_tool_sound(src)
var/obj/machinery/new_machine = new circuit.build_path(loc)
Expand Down Expand Up @@ -221,20 +334,6 @@
qdel(src)
return TRUE

/obj/structure/frame/computer/deconstruct(disassembled = TRUE)
if(!(obj_flags & NO_DECONSTRUCTION))
var/atom/drop_loc = drop_location()
if(state == FRAME_COMPUTER_STATE_GLASSED)
if(disassembled)
new /obj/item/stack/sheet/glass(drop_loc, 2)
else
new /obj/item/shard(drop_loc)
new /obj/item/shard(drop_loc)
if(state >= FRAME_COMPUTER_STATE_WIRED)
new /obj/item/stack/cable_coil(drop_loc, 5)

return ..()

/// Helpers for rcd
/obj/structure/frame/computer/rcd
icon = 'icons/hud/radial.dmi'
Expand Down
Loading
Loading