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] Colony wall heater qol & fixes #4219

Merged
merged 1 commit into from
Jul 5, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
anchored = TRUE
density = FALSE
circuit = null
heating_energy = 20 KILO JOULES
efficiency = 10
heating_energy = STANDARD_CELL_RATE * 0.2
efficiency = 30
display_panel = TRUE
cell = null
/// What this repacks into when its wrenched off a wall
var/repacked_type = /obj/item/wallframe/wall_heater

Expand All @@ -18,11 +19,13 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/space_heater/wall_mounted, 29)
. = ..()
find_and_hang_on_wall()
AddElement(/datum/element/manufacturer_examine, COMPANY_FRONTIER)
RemoveElement(/datum/element/elevation, pixel_shift = 8) //they're on the wall, you can't climb this
RemoveElement(/datum/element/climbable)

/obj/machinery/space_heater/wall_mounted/RefreshParts()
. = ..()
heating_energy = 20 KILO JOULES
efficiency = 10
heating_energy = STANDARD_CELL_RATE * 0.2
efficiency = 30

/obj/machinery/space_heater/wall_mounted/default_deconstruction_crowbar()
return
Expand All @@ -37,7 +40,12 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/space_heater/wall_mounted, 29)

/obj/machinery/space_heater/wall_mounted/on_deconstruction(disassembled)
if(disassembled)
new repacked_type(drop_location())
var/obj/item/wallframe/wall_heater/frame = new repacked_type(drop_location())
frame.cell = cell
cell?.forceMove(frame)
else
cell.forceMove(drop_location())
cell = null
return ..()

// Wallmount for creating the heaters
Expand All @@ -56,3 +64,61 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/space_heater/wall_mounted, 29)
/datum/material/silver = SHEET_MATERIAL_AMOUNT * 1,
/datum/material/gold = SMALL_MATERIAL_AMOUNT,
)
/// lazy-initialized cell stored in the actual heater (so that it can start with one without making a new one every placement)
var/obj/item/stock_parts/power_store/cell = /obj/machinery/space_heater::cell

/obj/item/wallframe/wall_heater/Initialize(mapload)
. = ..()
register_context()

/obj/item/wallframe/wall_heater/after_attach(obj/machinery/space_heater/wall_mounted/attached_to)
. = ..()
if(!istype(attached_to))
return
if(ispath(cell))
cell = new cell
attached_to.cell = cell
cell?.forceMove(attached_to)
cell = null

/obj/item/wallframe/wall_heater/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
if(!istype(tool, /obj/item/stock_parts/power_store/cell))
return NONE
if(ispath(cell))
cell = new cell
playsound(src, 'sound/machines/click.ogg', 75, TRUE)
user.transferItemToLoc(tool, src)
if(!isnull(cell))
user.put_in_hands(cell)
user.balloon_alert(user, "swapped")
cell = tool
return ITEM_INTERACT_SUCCESS

/obj/item/wallframe/wall_heater/attack_hand_secondary(mob/user, list/modifiers)
. = ..()
if(. == SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN)
return
if(isnull(cell))
return SECONDARY_ATTACK_CALL_NORMAL
if(ispath(cell))
cell = new cell
playsound(src, 'sound/machines/click.ogg', 75, TRUE)
user.put_in_hands(cell)
cell = null
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN

/obj/item/wallframe/wall_heater/examine(mob/user)
. = ..()
if(cell)
. += span_notice("It contains a [ispath(cell) ? cell::name : cell.name], which could be replaced.")
else
. += span_notice("It is empty. You could insert a [span_bold("cell")].")

/obj/item/wallframe/wall_heater/add_context(atom/source, list/context, obj/item/held_item, mob/user)
. = ..()
if(!isnull(cell) && isnull(held_item))
context[SCREENTIP_CONTEXT_RMB] = "Remove cell"
. = CONTEXTUAL_SCREENTIP_SET
if(istype(held_item, /obj/item/stock_parts/power_store))
context[SCREENTIP_CONTEXT_LMB] = "Insert cell"
. = CONTEXTUAL_SCREENTIP_SET
Loading