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] Plant Tank #1176

Merged
merged 1 commit into from
Dec 18, 2023
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
19 changes: 17 additions & 2 deletions modular_skyrat/modules/ashwalkers/code/buildings/ash_farming.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
//now lets register the signals
RegisterSignal(atom_parent, COMSIG_ATOM_ATTACKBY, PROC_REF(check_attack))
RegisterSignal(atom_parent, COMSIG_ATOM_EXAMINE, PROC_REF(check_examine))
RegisterSignal(atom_parent, COMSIG_QDELETING, PROC_REF(delete_farm))

/datum/component/simple_farm/Destroy(force, silent)
//lets not hard del
UnregisterSignal(atom_parent, list(COMSIG_ATOM_ATTACKBY, COMSIG_ATOM_EXAMINE))
UnregisterSignal(atom_parent, list(COMSIG_ATOM_ATTACKBY, COMSIG_ATOM_EXAMINE, COMSIG_QDELETING))
atom_parent = null
return ..()

Expand All @@ -42,6 +43,9 @@
locate_farm.pixel_x = pixel_shift[1]
locate_farm.pixel_y = pixel_shift[2]
locate_farm.layer = atom_parent.layer + 0.1
if(ismovable(atom_parent))
var/atom/movable/movable_parent = atom_parent
locate_farm.glide_size = movable_parent.glide_size
attacking_item.forceMove(locate_farm)
locate_farm.planted_seed = attacking_item
locate_farm.attached_atom = atom_parent
Expand All @@ -53,7 +57,18 @@
* check_examine is meant to listen for the COMSIG_ATOM_EXAMINE signal, where it will put additional information in the examine
*/
/datum/component/simple_farm/proc/check_examine(datum/source, mob/user, list/examine_list)
examine_list += span_notice("You are able to plant seeds here!")
examine_list += span_notice("<br>You are able to plant seeds here!")

/**
* delete_farm is meant to be called when the parent of this component has been deleted-- thus deleting the ability to grow the simple farm
* it will delete the farm that can be found on the turf of the parent of this component
*/
/datum/component/simple_farm/proc/delete_farm()
SIGNAL_HANDLER

var/obj/structure/simple_farm/locate_farm = locate() in get_turf(atom_parent)
if(locate_farm)
qdel(locate_farm)

/obj/structure/simple_farm
name = "simple farm"
Expand Down
126 changes: 126 additions & 0 deletions modular_skyrat/modules/ashwalkers/code/buildings/planttank.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/obj/structure/plant_tank
name = "plant tank"
desc = "A small little glass tank that is used to grow plants; this tank promotes the nitrogen and oxygen cycle."
icon = 'modular_skyrat/modules/ashwalkers/icons/structures.dmi'
icon_state = "plant_tank_e"
anchored = FALSE
density = TRUE
///the amount of times the tank can produce-- can be increased through feeding the tank
var/operation_number = 0

/obj/structure/plant_tank/Initialize(mapload)
. = ..()
START_PROCESSING(SSobj, src)

/obj/structure/plant_tank/Destroy()
STOP_PROCESSING(SSobj, src)
return ..()

/obj/structure/plant_tank/examine(mob/user)
. = ..()
. += span_notice("<br>Use food or worm fertilizer to allow nitrogen production and carbon dioxide processing!")
. += span_notice("There are [operation_number] cycles left!")
var/datum/component/simple_farm/find_farm = GetComponent(/datum/component/simple_farm)
if(!find_farm)
. += span_notice("<br>Use five sand to allow planting!")

/obj/structure/plant_tank/attackby(obj/item/attacking_item, mob/user, params)
if(istype(attacking_item, /obj/item/food) || istype(attacking_item, /obj/item/stack/worm_fertilizer))
var/obj/item/stack/stack_item = attacking_item
if(isstack(stack_item))
if(!stack_item.use(1))
return

else
qdel(attacking_item)

balloon_alert(user, "[attacking_item] placed inside")
operation_number += 2
return

if(istype(attacking_item, /obj/item/storage/bag/plants))
balloon_alert(user, "placing food inside")
for(var/obj/item/food/selected_food in attacking_item.contents)
qdel(selected_food)
operation_number += 2

return

if(istype(attacking_item, /obj/item/stack/ore/glass))
var/datum/component/simple_farm/find_farm = GetComponent(/datum/component/simple_farm)
if(find_farm)
balloon_alert(user, "no more [attacking_item] required")
return

var/obj/item/stack/attacking_stack = attacking_item
if(!attacking_stack.use(5))
balloon_alert(user, "farms require five sand")
return

AddComponent(/datum/component/simple_farm, TRUE, TRUE, list(0, 12))
icon_state = "plant_tank_f"
return

return ..()

/obj/structure/plant_tank/process(seconds_per_tick)
if(operation_number <= 0) //we require "fuel" to actually produce stuff
return

if(!locate(/obj/structure/simple_farm) in get_turf(src)) //we require a plant to process the "fuel"
return

operation_number--

var/turf/open/src_turf = get_turf(src)
if(!isopenturf(src_turf) || isspaceturf(src_turf) || src_turf.planetary_atmos) //must be open turf, can't be space turf, and can't be a turf that regenerates its atmos
return

var/datum/gas_mixture/src_mixture = src_turf.return_air()

src_mixture.assert_gases(/datum/gas/carbon_dioxide, /datum/gas/oxygen, /datum/gas/nitrogen)

var/proportion = src_mixture.gases[/datum/gas/carbon_dioxide][MOLES]
if(proportion) //if there is carbon dioxide in the air, lets turn it into oxygen
proportion = min(src_mixture.gases[/datum/gas/carbon_dioxide][MOLES], MOLES_CELLSTANDARD)
src_mixture.gases[/datum/gas/carbon_dioxide][MOLES] -= proportion
src_mixture.gases[/datum/gas/oxygen][MOLES] += proportion

src_mixture.gases[/datum/gas/nitrogen][MOLES] += MOLES_CELLSTANDARD //the nitrogen cycle-- plants (and bacteria) participate in the nitrogen cycle

/obj/structure/plant_tank/wrench_act(mob/living/user, obj/item/tool)
balloon_alert(user, "[anchored ? "un" : ""]bolting")
tool.play_tool_sound(src, 50)
if(!tool.use_tool(src, user, 2 SECONDS))
return TRUE

anchored = !anchored
balloon_alert(user, "[anchored ? "" : "un"]bolted")
return TRUE

/obj/structure/plant_tank/screwdriver_act(mob/living/user, obj/item/tool)
balloon_alert(user, "deconstructing")
tool.play_tool_sound(src, 50)
if(!tool.use_tool(src, user, 2 SECONDS))
return TRUE

deconstruct()
return TRUE

/obj/structure/plant_tank/deconstruct(disassembled)
var/target_turf = get_turf(src)
for(var/loop in 1 to 4)
new /obj/item/stack/sheet/glass(target_turf)
new /obj/item/stack/rods(target_turf)
new /obj/item/forging/complete/plate(target_turf)
return ..()

/datum/crafting_recipe/plant_tank
name = "Plant Tank"
result = /obj/structure/plant_tank
reqs = list(
/obj/item/forging/complete/plate = 1,
/obj/item/stack/sheet/glass = 4,
/obj/item/stack/rods = 4,
)
category = CAT_STRUCTURE
Binary file modified modular_skyrat/modules/ashwalkers/icons/structures.dmi
Binary file not shown.
1 change: 1 addition & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -6545,6 +6545,7 @@
#include "modular_skyrat\modules\ashwalkers\code\buildings\ash_tendril.dm"
#include "modular_skyrat\modules\ashwalkers\code\buildings\fuelwell.dm"
#include "modular_skyrat\modules\ashwalkers\code\buildings\gutluncher_foodtrough.dm"
#include "modular_skyrat\modules\ashwalkers\code\buildings\planttank.dm"
#include "modular_skyrat\modules\ashwalkers\code\buildings\railroad.dm"
#include "modular_skyrat\modules\ashwalkers\code\buildings\tendril_cursing.dm"
#include "modular_skyrat\modules\ashwalkers\code\buildings\wormfarm.dm"
Expand Down
Loading