From 462c1cf84ff4d2d5479abc79b683e2e4dea029a3 Mon Sep 17 00:00:00 2001 From: CHOMPStation2StaffMirrorBot <94713762+CHOMPStation2StaffMirrorBot@users.noreply.github.com> Date: Fri, 16 May 2025 10:52:23 -0700 Subject: [PATCH] [MIRROR] Photosynthesis Component (#10903) Co-authored-by: Will <7099514+Willburd@users.noreply.github.com> Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com> --- code/datums/components/traits/photosynth.dm | 28 +++++++++++++++++++ code/modules/mob/living/carbon/human/life.dm | 6 ---- .../living/carbon/human/species/species.dm | 1 - .../human/species/station/traits/positive.dm | 2 +- vorestation.dme | 1 + 5 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 code/datums/components/traits/photosynth.dm diff --git a/code/datums/components/traits/photosynth.dm b/code/datums/components/traits/photosynth.dm new file mode 100644 index 0000000000..1f012e482c --- /dev/null +++ b/code/datums/components/traits/photosynth.dm @@ -0,0 +1,28 @@ +// If a mob has this component, every life tick it will gain nutrition if it's standing in light up to nutrition_max. +// Extremely good tutorial component if you need an example with no special bells and whistles, and no "gotcha" behaviors. +/datum/component/photosynth + var/mob/living/owner + var/nutrition_max = 1000 + +/datum/component/photosynth/Initialize() + if(!isliving(parent)) + return COMPONENT_INCOMPATIBLE + owner = parent + RegisterSignal(owner, COMSIG_LIVING_LIFE, PROC_REF(process_component)) + +/datum/component/photosynth/proc/process_component() + if(QDELETED(parent)) + return + if(owner.stat == DEAD) + return + if(!isturf(owner.loc)) + return + if(owner.nutrition >= nutrition_max) + return + var/turf/T = owner.loc + owner.adjust_nutrition(T.get_lumcount() / 10) + +/datum/component/photosynth/Destroy(force = FALSE) + UnregisterSignal(owner, COMSIG_LIVING_LIFE) + owner = null + . = ..() diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 508cd6422c..5c51cfc4b1 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -1177,12 +1177,6 @@ take_overall_damage(1,1) else //heal in the dark heal_overall_damage(1,1) - if(species.photosynthesizing && nutrition < 1000) - var/light_amount = 0 - if(isturf(loc)) - var/turf/T = loc - light_amount = T.get_lumcount() / 10 - adjust_nutrition(light_amount) // nutrition decrease if(nutrition <= 0 && species.shrinks && size_multiplier > RESIZE_TINY) nutrition = 0.1 diff --git a/code/modules/mob/living/carbon/human/species/species.dm b/code/modules/mob/living/carbon/human/species/species.dm index 1c4b42d72c..125a19cf52 100644 --- a/code/modules/mob/living/carbon/human/species/species.dm +++ b/code/modules/mob/living/carbon/human/species/species.dm @@ -244,7 +244,6 @@ var/gluttonous // Can eat some mobs. 1 for mice, 2 for monkeys, 3 for people. var/soft_landing = FALSE // Can fall down and land safely on small falls. - var/photosynthesizing = FALSE // If we get nutrition from light or not. var/shrinks = FALSE // If we shrink when we have no nutrition. Not added but here for downstream's sake. var/grows = FALSE // Same as above but if we grow when >1000 nutrition. var/crit_mod = 1 // Used for when we go unconscious. Used downstream. diff --git a/code/modules/mob/living/carbon/human/species/station/traits/positive.dm b/code/modules/mob/living/carbon/human/species/station/traits/positive.dm index e84f2d89b1..06c0bae7e2 100644 --- a/code/modules/mob/living/carbon/human/species/station/traits/positive.dm +++ b/code/modules/mob/living/carbon/human/species/station/traits/positive.dm @@ -374,8 +374,8 @@ name = "Photosynthesis" desc = "Your body is able to produce nutrition from being in light." cost = 3 - var_changes = list("photosynthesizing" = TRUE) can_take = ORGANICS|SYNTHETICS //Synths actually use nutrition, just with a fancy covering. + added_component_path = /datum/component/photosynth /datum/trait/positive/rad_resistance name = "Radiation Resistance" diff --git a/vorestation.dme b/vorestation.dme index 5294cf0f6c..4a13bb92ee 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -545,6 +545,7 @@ #include "code\datums\components\disabilities\tourettes.dm" #include "code\datums\components\traits\drippy.dm" #include "code\datums\components\traits\gargoyle.dm" +#include "code\datums\components\traits\photosynth.dm" #include "code\datums\components\traits\weaver.dm" #include "code\datums\components\species\shadekin.dm" #include "code\datums\components\species\xenochimera.dm"