Post-merge code cleanup for botanic trays (#96352)

## About The Pull Request
Melbert has tasked me to handle fixing and cleaning up a few things from
#96236 after I merged it before they could review it a second time, plus
a few things I've noticed on my own (changing the name and desc is best
handled by the update_name and update_desc proc respectively, and soil
shouldn't process while inside trays).
This commit is contained in:
Ghom
2026-06-07 00:10:54 -05:00
committed by GitHub
parent d2d7b0d9ec
commit e1c581e13a
3 changed files with 61 additions and 54 deletions
@@ -1318,24 +1318,23 @@
/obj/item/circuitboard/machine/hydroponics/proc/changeindicators(mob/living/user, obj/item/I)
if(build_path == /obj/machinery/hydroponics/constructable/oldstyle)
name = "Hydroponics Tray"
name = "Hydroponics Tray [name_extension]"
build_path = /obj/machinery/hydroponics/constructable
balloon_alert(user, "defaulting indicator location.")
balloon_alert(user, "defaulting indicator location")
else
name = "Old-Designed Hydropoincs Tray"
name = "Hydroponics Tray (Alt) [name_extension]"
build_path = /obj/machinery/hydroponics/constructable/oldstyle
balloon_alert(user, "moving the indicators...")
return TRUE
balloon_alert(user, "moved indicators location")
/obj/item/circuitboard/machine/hydroponics/item_interaction(mob/living/user, obj/item/I, list/modifiers)
if(istype(I, /obj/item/plant_analyzer))
changeindicators(user)
else
return ..()
return ITEM_INTERACT_SUCCESS
return ..()
/obj/item/circuitboard/machine/hydroponics/screwdriver_act(mob/living/user, obj/item/tool)
src.changeindicators(user)
return
changeindicators(user)
return ITEM_INTERACT_SUCCESS
/obj/item/circuitboard/machine/hydroponics/fullupgrade
build_path = /obj/machinery/hydroponics/constructable/fullupgrade
+35 -38
View File
@@ -52,8 +52,6 @@
var/datum/weakref/lastuser
///If the tray generates nutrients and water on its own
var/self_sustaining = FALSE
///If the tray is currently able to self-sustain
var/can_self_sustain = TRUE
///The icon state for the overlay used to represent that this tray is self-sustaining.
var/self_sustaining_overlay_icon_state = "gaia_blessing"
///Whether the plant is currently being pollinated or polinating the nearby plants
@@ -68,10 +66,8 @@
var/plant_offset_y = 0
///Suffix things
var/alt_tray = FALSE
var/indicatorsuffix = ""
///Soil things
var/obj/machinery/hydroponics/soil/current_soil = null
var/current_soil_overlay = null
var/obj/machinery/hydroponics/soil/current_soil
/obj/machinery/hydroponics/Initialize(mapload)
//ALRIGHT YOU DEGENERATES. YOU HAD REAGENT HOLDERS FOR AT LEAST 4 YEARS AND NONE OF YOU MADE HYDROPONICS TRAYS HOLD NUTRIENT CHEMS INSTEAD OF USING "Points".
@@ -169,12 +165,10 @@
return NONE
/obj/machinery/hydroponics/constructable
name = "hydroponics tray"
icon = 'icons/obj/service/hydroponics/equipment.dmi'
icon_state = "hydrotray3"
/obj/machinery/hydroponics/constructable/oldstyle
name = "hydroponics tray"
icon = 'icons/obj/service/hydroponics/equipment.dmi'
icon_state = "hydrotray3-alt"
alt_tray = TRUE
@@ -191,9 +185,6 @@
AddComponent(/datum/component/usb_port, typecacheof(list(/obj/item/circuit_component/hydroponics), only_root_path = TRUE))
AddComponent(/datum/component/fishing_spot, /datum/fish_source/hydro_tray)
/obj/machinery/hydroponics/constructable/on_deconstruction(disassembled)
current_soil?.forceMove(drop_location())
/obj/machinery/hydroponics/constructable/RefreshParts()
. = ..()
var/tmp_capacity = 0
@@ -247,21 +238,27 @@
if(myseed)
QDEL_NULL(myseed)
remove_shared_particles(/particles/pollen)
QDEL_NULL(current_soil)
return ..()
/obj/machinery/hydroponics/Exited(atom/movable/gone)
. = ..()
if(!QDELETED(src) && gone == myseed)
set_seed(null, FALSE)
if(!istype(gone, /obj/item/mob_holder/snail))
return
var/obj/item/mob_holder/snail_object = gone
if(snail_object.held_mob)
UnregisterSignal(snail_object.held_mob, list(
COMSIG_LIVING_DEATH,
COMSIG_MOVABLE_ATTEMPTED_MOVE,
))
QDEL_NULL(our_snail)
if(gone == current_soil)
current_soil = null
if(!QDELETED(src))
update_appearance()
return
if(istype(gone, /obj/item/mob_holder/snail))
var/obj/item/mob_holder/snail_object = gone
if(snail_object.held_mob)
UnregisterSignal(snail_object.held_mob, list(
COMSIG_LIVING_DEATH,
COMSIG_MOVABLE_ATTEMPTED_MOVE,
))
QDEL_NULL(our_snail)
/obj/machinery/hydroponics/constructable/screwdriver_act(mob/living/user, obj/item/tool)
return default_deconstruction_screwdriver(user, tool)
@@ -474,8 +471,19 @@
/obj/machinery/hydroponics/update_name(updates)
. = ..()
if(!GetComponent(/datum/component/rename) && myseed)
name = "[initial(name)] ([myseed.plantname])"
if(GetComponent(/datum/component/rename))
return
name = current_soil ? "botanic tray" : initial(name)
if(myseed)
name += " ([myseed.plantname])"
/obj/machinery/hydroponics/update_desc(updates)
. = ..()
if(GetComponent(/datum/component/rename))
return
desc = initial(desc)
if(current_soil)
desc += " Filled with [current_soil.name]."
/obj/machinery/hydroponics/update_overlays()
. = ..()
@@ -483,8 +491,9 @@
. += myseed.get_tray_overlay(age, plant_status, plant_offset_y)
. += update_status_light_overlays()
if(current_soil && current_soil_overlay)
. += mutable_appearance(icon, current_soil_overlay, OBJ_LAYER + 0.001)
if(current_soil)
var/soil_overlay = "[current_soil.icon_state]_tray"
. += mutable_appearance(icon, soil_overlay, OBJ_LAYER + 0.001)
if(self_sustaining && self_sustaining_overlay_icon_state)
. += mutable_appearance(icon, self_sustaining_overlay_icon_state, OBJ_LAYER + 0.002)
@@ -492,8 +501,7 @@
/obj/machinery/hydroponics/proc/update_status_light_overlays()
. = list()
if(alt_tray)
indicatorsuffix = "-alt"
var/indicatorsuffix = alt_tray ? "-alt" : ""
if(waterlevel <= 10)
. += mutable_appearance('icons/obj/service/hydroponics/equipment.dmi', "over_lowwater3[indicatorsuffix]")
. += emissive_appearance(icon, "over_lowwater3[indicatorsuffix]", src, alpha = src.alpha)
@@ -1101,28 +1109,21 @@
return
if(!isnull(current_soil))
balloon_alert(user, "tray is full")
balloon_alert(user, "tray is full!")
return
balloon_alert(user, "filling the tray...")
if(!do_after(user, 2 SECONDS, src))
return
if(!oursoil.stored_soil)
balloon_alert(user, "sack is empty!")
return
current_soil = new oursoil.stored_soil(src)
oursoil.transfer_soil(src, inside_tray = TRUE)
RefreshParts()
tray_flags = current_soil.tray_flags
current_soil_overlay = "[current_soil.icon_state]_tray"
name = "botanic tray"
desc = "A basin used to grow plants in. Filled with [current_soil.name]."
qdel(oursoil)
update_appearance()
return
return TRUE
else
return ..()
@@ -1166,10 +1167,6 @@
update_use_power(NO_POWER_USE)
return CLICK_ACTION_BLOCKING
if(!can_self_sustain)
balloon_alert(user, "no self-sustain mode!")
return CLICK_ACTION_BLOCKING
set_self_sustaining(!self_sustaining)
to_chat(user, span_notice("You [self_sustaining ? "activate" : "deactivated"] [src]'s autogrow function[self_sustaining ? ", maintaining the tray's health while using high amounts of power" : ""]."))
return CLICK_ACTION_SUCCESS
+18 -7
View File
@@ -150,6 +150,12 @@
animate(time = 100 MILLISECONDS, pixel_z = 0, easing = QUAD_EASING | EASE_IN)
animate(time = 250 MILLISECONDS, pixel_x = rand(-6, 6), pixel_y = rand(-4, 4), flags = ANIMATION_PARALLEL)
/obj/item/soil_sack/Exited(atom/movable/gone)
. = ..()
if(gone == stored_soil)
stored_soil = null
qdel(src)
/obj/item/soil_sack/interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
if(!isopenturf(interacting_with) || isgroundlessturf(interacting_with))
return ..()
@@ -161,19 +167,24 @@
if(!do_after(user, 1 SECONDS, interacting_with))
return ITEM_INTERACT_BLOCKING
transfer_soil(interacting_with)
return ITEM_INTERACT_SUCCESS
//Proc responsible for placing the soil inside track onto the turf or inside a hydroponic tray
/obj/item/soil_sack/proc/transfer_soil(atom/target, inside_tray = FALSE)
if(ispath(stored_soil))
stored_soil = new stored_soil(src)
if(inside_tray)
STOP_PROCESSING(SSmachines, stored_soil)
stored_soil.reagents.add_reagent(/datum/reagent/plantnutriment/eznutriment, stored_soil.maxnutri / 2)
stored_soil.waterlevel = stored_soil.maxwater
else
else if(!inside_tray)
START_PROCESSING(SSmachines, stored_soil)
stored_soil.forceMove(interacting_with)
playsound(stored_soil, placement_sound, 65, vary = TRUE)
stored_soil.on_place()
qdel(src)
return ITEM_INTERACT_SUCCESS
playsound(target, placement_sound, 65, vary = TRUE)
if(!inside_tray)
stored_soil.on_place()
stored_soil.forceMove(target) //stored_soil is set to null at this point, and the soil sack is deleted when that happens
/obj/item/soil_sack/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK, damage_type = BRUTE)
if(attack_type == OVERWHELMING_ATTACK)