Files
BatrachophrenoandGitHub 4ecb0bc21c Repath obj/machinery to obj/structure/machinery [MDB Ignore] (#22500)
Repaths obj/machinery to obj/structure/machinery. **Note for
reviewers:** the only meaningful changed code exists within
**code/game/objects/structures.dm** and
**code/game/objects/structures/_machinery.dm**, largely concerning
damage procs. With the exception of moving airlock defines to their own
file, ALL OTHER CHANGES ARE STRICTLY PATH CHANGES.

Objects, _categorically_, are largely divided between those you can hold
in your hand/inventory and those you can't. Machinery objects are
already subtypes of Structures behaviorally, this PR just makes their
pathing reflect that, and allows for future work (tool actions, more
health/destruction functionality) to be developed without unnecessary
code duplication.

I have tested this PR by loading up the Horizon and dismantling various
machines and structures with tools, shooting guns of various types
throughout the ship, and detonating a bunch of explosions throughout the
ship.
2026-05-26 19:35:48 +00:00

92 lines
3.3 KiB
Plaintext

/obj/structure/machinery/portable_atmospherics/hydroponics/soil
name = "soil"
desc = "A mound of earth. You could plant some seeds here."
icon_state = "soil"
density = FALSE
use_power = POWER_USE_OFF
mechanical = FALSE
maxhealth = null
tray_light = 0
/// Water level begins at zero.
waterlevel = 0
/// Nutrient level begins at zero. Soil's hard mode, baby.
nutrilevel = 0
/// Retains the ability for soil to grow weeds, as it should.
maxWeedLevel = 10
/// TODO: Really need to just merge this with its parent proc, this is all duplicated.
/obj/structure/machinery/portable_atmospherics/hydroponics/soil/attackby(obj/item/attacking_item, mob/user)
//A special case for if the container has only water, for manual watering with buckets
if (istype(attacking_item, /obj/item/reagent_containers))
var/obj/item/reagent_containers/RC = attacking_item
if (LAZYLEN(RC.reagents.reagent_volumes) == 1)
if (RC.reagents.has_reagent(/singleton/reagent/water, 1))
if (waterlevel < maxWaterLevel)
var/amountToRemove = min((maxWaterLevel - waterlevel), RC.reagents.total_volume)
RC.reagents.remove_reagent(/singleton/reagent/water, amountToRemove, 1)
waterlevel += amountToRemove
user.visible_message("[user] pours [amountToRemove]u of water into the soil."," You pour [amountToRemove]u of water into the soil.")
playsound(src, SFX_POUR, 25, 1)
else
to_chat(user, "The soil is saturated with water already.")
return 1
if(istype(attacking_item, /obj/item/tank))
return
if(istype(attacking_item, /obj/item/shovel))
if(attacking_item.use_tool(src, user, 50, volume = 50))
new /obj/item/stack/material/sandstone{amount = 3}(loc)
to_chat(user, SPAN_NOTICE("You remove the soil from the bed and dismantle the sandstone base."))
playsound(src, 'sound/effects/stonedoor_openclose.ogg', 40, 1)
qdel(src)
else
..()
/* Holder for vine plants.
Icons for plants are generated as overlays, so setting it to invisible wouldn't work.
Hence using a blank icon. */
/obj/structure/machinery/portable_atmospherics/hydroponics/soil/invisible
name = "plant"
desc = null
icon = 'icons/obj/seeds.dmi'
icon_state = "blank"
/obj/structure/machinery/portable_atmospherics/hydroponics/soil/invisible/Initialize(var/newloc,var/datum/seed/newseed,var/start_mature)
. = ..()
seed = newseed
dead = 0
age = start_mature ? GET_SEED_TRAIT(seed, TRAIT_MATURATION) : 1
plant_health = GET_SEED_TRAIT(seed, TRAIT_ENDURANCE)
lastcycle = world.time
pixel_y = rand(-5,5)
waterlevel = 100
nutrilevel = 100
check_health()
/obj/structure/machinery/portable_atmospherics/hydroponics/soil/invisible/remove_dead()
..()
qdel(src)
/obj/structure/machinery/portable_atmospherics/hydroponics/soil/invisible/harvest()
..()
if(!seed) // Repeat harvests are a thing.
qdel(src)
/obj/structure/machinery/portable_atmospherics/hydroponics/soil/invisible/die()
qdel(src)
/obj/structure/machinery/portable_atmospherics/hydroponics/soil/invisible/process()
if(!seed)
qdel(src)
return
else if(name=="plant")
name = seed.display_name
..()
/obj/structure/machinery/portable_atmospherics/hydroponics/soil/invisible/Destroy()
// Check if we're masking a decal that needs to be visible again.
for(var/obj/effect/plant/plant in get_turf(src))
if(plant.invisibility == INVISIBILITY_MAXIMUM)
plant.set_invisibility(initial(plant.invisibility))
return ..()