mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2026-08-31 01:00:59 +01:00
[MIRROR] Photosynthesis Component (#10903)
Co-authored-by: Will <7099514+Willburd@users.noreply.github.com> Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
This commit is contained in:
co-authored by
Will
Kashargul
parent
56e9fc0c0e
commit
462c1cf84f
@@ -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
|
||||
. = ..()
|
||||
Reference in New Issue
Block a user