mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-02-07 15:19:02 +00:00
* Adds soil clumps, which are used to make soil(alternative to sandstone). * Adds soil clump recipe to the biogenerator * Adds the compost bin to the game. Which converts biomass to compost and makes soil from it. * Adds sprites for the compost bin * Adds a recipe for the compost bin(10 planks) * Added interface for the compost bin. * Applying suggested changes to compost bin(redundant condition removal, spell check, auto doc) * Applying suggested changes to soil sheets(initialize, remove empty line) * Changed min and max to clamp where able, removed redundant return, compost recursion stays in convert_biomass(). * Call parent on init * Identation and style changes * Rephrase description * Unauto docing unnecessary bits, clicking with screwdriver no longer an attack, removed redundancies, reordred ui procs and changed ui data list to new format. * Converting plant to biomass is now its own function * removed SOIL define. using path as is instead * Moved the compost_bin-3 sprite up a pixel so it aligns with the rest * Added spaces for readability Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com> * Moved plant deletion to make_biomass() * Rebuilt tgui * Filled gaps in sprite with mostly transparent pixels to make it easier to click * Rebuild tgui * rebuild tgui * Adds the soil clump sprites back after update * Added Trailing newline to compost_bin.dm check said it's missing * Adds a check for presence of biomass when initializing to prevent unneeded proc call Checks whether a compost bin has any biomass before attempting to compost it. * Adding back compost bin icons * rebuild tgui * Made interface window slightly shorter. from 300 to 200 pixels tall. * Replaced the enough_compost() proc with an if statement in the only place it was used * Replaced the compost() proc and calls to it with process(). * Rebuild TGUI * Removed an unused var, idented a comment, and returned the onhit proc to it's original form * Ran prettier on the compost bin interface file * Wake Up Icon Diffbot * Aw shit, here we go again. * Empty-Commit * Wake up icondiffbot * Last attempt for today * Removed redundant new line from sheet_types.dm * removed redundant new lines and moved the ui procs together. * Changed compost label to Compost * Recompile tgui * Rebuild Tgui * Rebuild TGUI * Rebuild TGUI * Capitaliize the word soil in the biogenerator listing for it * following some suggestions Replaced compost capacity defines with "magic numbers", removed redundant init proc, added spaces around a '-' sign. * Removing a redundant check in the insertion proc. moved the check for the compost bin being full to the end of the loop since I already make one before the loop starts. * Rebuild TGUI * Rebuild Tgui * Update code/game/objects/items/stacks/sheets/sheet_types.dm Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com> * Rebuild TGUI * ReRebuild TGUI --------- Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com> Co-authored-by: S34N <12197162+S34NW@users.noreply.github.com> Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com>
161 lines
5.1 KiB
Plaintext
161 lines
5.1 KiB
Plaintext
#define SOIL_COST 25
|
|
#define DECAY 0.2
|
|
#define MIN_CONVERSION 10
|
|
/**
|
|
* # compost bin
|
|
* used to make soil from plants.
|
|
* Doesn't have components.
|
|
*/
|
|
/obj/machinery/compost_bin
|
|
name = "compost bin"
|
|
desc = "A wooden bin for composting."
|
|
icon = 'icons/obj/hydroponics/equipment.dmi'
|
|
icon_state = "compost_bin-empty"
|
|
power_state = NO_POWER_USE
|
|
density = TRUE
|
|
anchored = TRUE
|
|
/// stage in the process, for timing purposes.
|
|
var/process_counter = 0
|
|
/// amount of biomass in the compost bin
|
|
var/biomass = 0
|
|
/// amount of compost in the compost bin
|
|
var/compost = 0
|
|
/// The maximum amount of biomass the compost bin can store.
|
|
var/biomass_capacity = 1500
|
|
/// The maximum amount of compost the compost bin can store.
|
|
var/compost_capacity = 1500
|
|
|
|
/obj/machinery/compost_bin/on_deconstruction()
|
|
// returns wood instead of the non-existent components
|
|
new /obj/item/stack/sheet/wood(loc, 10)
|
|
return ..()
|
|
|
|
/obj/machinery/compost_bin/screwdriver_act(mob/living/user, obj/item/I)
|
|
// there are no screws either
|
|
to_chat(user, "<span class='warning'>[src] has no screws!</span>")
|
|
return TRUE
|
|
|
|
/obj/machinery/compost_bin/crowbar_act(mob/living/user, obj/item/I)
|
|
// no panel either
|
|
return default_deconstruction_crowbar(user, I, ignore_panel = TRUE)
|
|
|
|
// Accepts inserted plants and converts them to biomass
|
|
/obj/machinery/compost_bin/proc/make_biomass(obj/item/reagent_containers/food/snacks/grown/O)
|
|
// calculate biomass from plant nutriment and plant matter
|
|
var/plant_biomass = O.reagents.get_reagent_amount("nutriment") + O.reagents.get_reagent_amount("plantmatter")
|
|
biomass += clamp(plant_biomass * 10, 1, biomass_capacity - biomass)
|
|
//plant delenda est
|
|
qdel(O)
|
|
|
|
// takes care of plant insertion and conversion to biomass, and start composting what was inserted
|
|
/obj/machinery/compost_bin/attackby(obj/item/O, mob/user, params)
|
|
if(user.a_intent == INTENT_HARM)
|
|
return ..()
|
|
|
|
if(istype(O, /obj/item/storage/bag/plants))
|
|
if(biomass >= biomass_capacity)
|
|
to_chat(user, "<span class='warning'>[src] can't hold any more biomass!</span>")
|
|
return
|
|
|
|
var/obj/item/storage/bag/plants/PB = O
|
|
for(var/obj/item/reagent_containers/food/snacks/grown/G in PB.contents)
|
|
|
|
PB.remove_from_storage(G, src)
|
|
make_biomass(G)
|
|
|
|
if(biomass >= biomass_capacity)
|
|
to_chat(user, "<span class='info'>You fill [src] to its capacity.</span>")
|
|
break
|
|
|
|
if(biomass < biomass_capacity)
|
|
to_chat(user, "<span class='info'>You empty [PB] into [src].</span>")
|
|
|
|
SStgui.update_uis(src)
|
|
update_icon_state()
|
|
return TRUE
|
|
|
|
if(istype(O, /obj/item/reagent_containers/food/snacks/grown))
|
|
if(biomass >= biomass_capacity)
|
|
to_chat(user, "<span class='warning'>[src] can't hold any more plants!</span>")
|
|
return
|
|
if(!user.unEquip(O))
|
|
return
|
|
|
|
O.forceMove(src)
|
|
make_biomass(O)
|
|
to_chat(user, "<span class='info'>You put [O] in [src].</span>")
|
|
SStgui.update_uis(src)
|
|
update_icon_state()
|
|
return TRUE
|
|
|
|
to_chat(user, "<span class='warning'>You cannot put this in [name]!</span>")
|
|
|
|
//Compost compostable material if there is any
|
|
/obj/machinery/compost_bin/process()
|
|
if(compost >= compost_capacity || biomass <= 0)
|
|
return
|
|
process_counter++
|
|
if(process_counter < 5)
|
|
return
|
|
process_counter = 0
|
|
//converts 20% of the biomass to compost each cycle, unless there isn't enough compost space or there is 10 or less biomass
|
|
var/conversion_amount = clamp(DECAY * biomass, min(MIN_CONVERSION, biomass), compost_capacity - compost)
|
|
biomass -= conversion_amount
|
|
compost += conversion_amount
|
|
update_icon_state()
|
|
SStgui.update_uis(src)
|
|
|
|
// Makes soil from compost
|
|
/obj/machinery/compost_bin/proc/create_soil(amount)
|
|
// Verify theres enough compost
|
|
if(compost < (SOIL_COST * amount))
|
|
return
|
|
new /obj/item/stack/sheet/soil(loc, amount)
|
|
compost -= SOIL_COST * amount
|
|
update_icon_state()
|
|
SStgui.update_uis(src)
|
|
|
|
/obj/machinery/compost_bin/attack_hand(mob/user)
|
|
ui_interact(user)
|
|
|
|
/obj/machinery/compost_bin/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
|
|
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
|
if(!ui)
|
|
ui = new(user, src, ui_key, "CompostBin", "Compost Bin", 390, 200, master_ui, state)
|
|
ui.set_autoupdate(FALSE)
|
|
ui.open()
|
|
|
|
/obj/machinery/compost_bin/ui_data(mob/user)
|
|
var/list/data = list()
|
|
data["biomass"] = biomass
|
|
data["biomass_capacity"] = biomass_capacity
|
|
data["compost"] = compost
|
|
data["compost_capacity"] = compost_capacity
|
|
return data
|
|
|
|
// calls functions according to ui interaction(just making compost for now)
|
|
/obj/machinery/compost_bin/ui_act(action, list/params)
|
|
if(..())
|
|
return
|
|
|
|
. = TRUE
|
|
switch(action)
|
|
if("create")
|
|
var/amount = clamp(text2num(params["amount"]), 1, 10)
|
|
create_soil(amount)
|
|
|
|
// sets compost bin sprite according to the amount of compost in it
|
|
/obj/machinery/compost_bin/update_icon_state()
|
|
if(!compost)
|
|
icon_state = "compost_bin-empty"
|
|
else if(compost <= compost_capacity / 3)
|
|
icon_state = "compost_bin-1"
|
|
else if(compost <= 2 * (compost_capacity) / 3)
|
|
icon_state = "compost_bin-2"
|
|
else
|
|
icon_state = "compost_bin-3"
|
|
|
|
#undef SOIL_COST
|
|
#undef DECAY
|
|
#undef MIN_CONVERSION
|