mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-18 18:44:48 +01:00
Adds soil clumps and a compost bin. (#22585)
* 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>
This commit is contained in:
committed by
GitHub
parent
e6addfc6ac
commit
23e2c250ec
@@ -6,6 +6,7 @@
|
||||
* Cloth
|
||||
* Durathread
|
||||
* Cardboard
|
||||
* Soil
|
||||
* Runed Metal (cult)
|
||||
* Brass (clockwork cult)
|
||||
* Bones
|
||||
@@ -240,7 +241,8 @@ GLOBAL_LIST_INIT(wood_recipes, list(
|
||||
new /datum/stack_recipe("honey frame", /obj/item/honey_frame, 5, time = 1 SECONDS),
|
||||
new /datum/stack_recipe("ore box", /obj/structure/ore_box, 4, time = 5 SECONDS, one_per_turf = TRUE, on_floor = TRUE),
|
||||
new /datum/stack_recipe("loom", /obj/structure/loom, 10, time = 1.5 SECONDS, one_per_turf = TRUE, on_floor = TRUE),
|
||||
new /datum/stack_recipe("fermenting barrel", /obj/structure/fermenting_barrel, 30, time = 5 SECONDS)
|
||||
new /datum/stack_recipe("fermenting barrel", /obj/structure/fermenting_barrel, 30, time = 5 SECONDS),
|
||||
new /datum/stack_recipe("compost bin", /obj/machinery/compost_bin, 10, time = 1.5 SECONDS, one_per_turf = TRUE, on_floor = TRUE)
|
||||
))
|
||||
|
||||
/obj/item/stack/sheet/wood
|
||||
@@ -434,6 +436,28 @@ GLOBAL_LIST_INIT(cardboard_recipes, list (
|
||||
recipes = GLOB.cardboard_recipes
|
||||
return ..()
|
||||
|
||||
/*
|
||||
* soil
|
||||
*/
|
||||
GLOBAL_LIST_INIT(soil_recipes, list (
|
||||
new /datum/stack_recipe("pile of dirt", /obj/machinery/hydroponics/soil, 3, time = 1 SECONDS, one_per_turf = TRUE, on_floor = TRUE)
|
||||
))
|
||||
|
||||
/obj/item/stack/sheet/soil
|
||||
name = "soil"
|
||||
desc = "A clump of fertile soil which can be used to make a plot."
|
||||
singular_name = "soil clump"
|
||||
icon = 'icons/obj/stacks/organic.dmi'
|
||||
icon_state = "sheet-soil"
|
||||
item_state = "sheet-soil"
|
||||
origin_tech = "materials=1"
|
||||
resistance_flags = FIRE_PROOF
|
||||
merge_type = /obj/item/stack/sheet/soil
|
||||
|
||||
/obj/item/stack/sheet/soil/Initialize(loc, amt)
|
||||
recipes = GLOB.soil_recipes
|
||||
return ..()
|
||||
|
||||
/*
|
||||
* Runed Metal
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
#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
|
||||
@@ -139,6 +139,14 @@
|
||||
build_path = /obj/item/reagent_containers/glass/bottle/nutrient/empty
|
||||
category = list("initial", "Botany Chemicals")
|
||||
|
||||
/datum/design/soil
|
||||
name = "Clump of Soil"
|
||||
id = "soil"
|
||||
build_type = BIOGENERATOR
|
||||
materials = list(MAT_BIOMASS = 50)
|
||||
build_path = /obj/item/stack/sheet/soil
|
||||
category = list("initial", "Organic Materials")
|
||||
|
||||
/datum/design/cloth
|
||||
name = "Roll of cloth"
|
||||
id = "cloth"
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 25 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 16 KiB |
@@ -1790,6 +1790,7 @@
|
||||
#include "code\modules\holiday\christmas.dm"
|
||||
#include "code\modules\holiday\holiday.dm"
|
||||
#include "code\modules\hydroponics\biogenerator.dm"
|
||||
#include "code\modules\hydroponics\compost_bin.dm"
|
||||
#include "code\modules\hydroponics\fermenting_barrel.dm"
|
||||
#include "code\modules\hydroponics\gene_modder.dm"
|
||||
#include "code\modules\hydroponics\grown.dm"
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
import { useBackend, useSharedState } from '../backend';
|
||||
import {
|
||||
Button,
|
||||
Section,
|
||||
Box,
|
||||
Flex,
|
||||
Icon,
|
||||
Collapsible,
|
||||
NumberInput,
|
||||
ProgressBar,
|
||||
Dimmer,
|
||||
LabeledList,
|
||||
} from '../components';
|
||||
import { Window } from '../layouts';
|
||||
|
||||
export const CompostBin = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
const { biomass, compost, biomass_capacity, compost_capacity } = data;
|
||||
|
||||
let [vendAmount, setVendAmount] = useSharedState(context, 'vendAmount', 1);
|
||||
|
||||
return (
|
||||
<Window>
|
||||
<Window.Content>
|
||||
<Section label="Resources">
|
||||
<Flex>
|
||||
<LabeledList>
|
||||
<LabeledList.Item label="Biomass">
|
||||
<ProgressBar
|
||||
value={biomass}
|
||||
minValue={0}
|
||||
maxValue={biomass_capacity}
|
||||
ranges={{
|
||||
good: [biomass_capacity * 0.5, Infinity],
|
||||
average: [biomass_capacity * 0.25, biomass_capacity * 0.5],
|
||||
bad: [-Infinity, biomass_capacity * 0.25],
|
||||
}}
|
||||
>
|
||||
{biomass} / {biomass_capacity} Units
|
||||
</ProgressBar>
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
</Flex>
|
||||
<Flex>
|
||||
<LabeledList>
|
||||
<LabeledList.Item label="Compost">
|
||||
<ProgressBar
|
||||
value={compost}
|
||||
minValue={0}
|
||||
maxValue={compost_capacity}
|
||||
ranges={{
|
||||
good: [compost_capacity * 0.5, Infinity],
|
||||
average: [compost_capacity * 0.25, compost_capacity * 0.5],
|
||||
bad: [-Infinity, compost_capacity * 0.25],
|
||||
}}
|
||||
>
|
||||
{compost} / {compost_capacity} Units
|
||||
</ProgressBar>
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
</Flex>
|
||||
</Section>
|
||||
<Section title="Controls">
|
||||
<Flex>
|
||||
<Box inline mr="5px" color="silver">
|
||||
Soil clumps to make:
|
||||
</Box>
|
||||
<NumberInput
|
||||
animated
|
||||
value={vendAmount}
|
||||
width="32px"
|
||||
minValue={1}
|
||||
maxValue={10}
|
||||
stepPixelSize={7}
|
||||
onChange={(e, value) => setVendAmount(value)}
|
||||
/>
|
||||
</Flex>
|
||||
<Flex.Item mr="5px" textAlign="right" width="0%">
|
||||
<Button
|
||||
align="right"
|
||||
content="Make Soil"
|
||||
disabled={compost < 25 * vendAmount}
|
||||
icon="arrow-circle-down"
|
||||
onClick={() =>
|
||||
act('create', {
|
||||
amount: vendAmount,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</Flex.Item>
|
||||
</Section>
|
||||
</Window.Content>
|
||||
</Window>
|
||||
);
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user