diff --git a/code/game/objects/structures/crates_lockers/crates/bins.dm b/code/game/objects/structures/crates_lockers/crates/bins.dm index 18f2aaf82194..d17ec9a52565 100644 --- a/code/game/objects/structures/crates_lockers/crates/bins.dm +++ b/code/game/objects/structures/crates_lockers/crates/bins.dm @@ -22,6 +22,7 @@ COMSIG_TURF_RECEIVE_SWEEPED_ITEMS = PROC_REF(ready_for_trash), ) AddElement(/datum/element/connect_loc, loc_connections) + AddComponent(/datum/component/trash_source) // DARKPACK EDIT ADD - DECOR /* // DARKPACK EDIT REMOVAL - No sprites for this yet. /obj/structure/closet/crate/bin/update_overlays() diff --git a/modular_darkpack/modules/decor/code/decor.dm b/modular_darkpack/modules/decor/code/decor.dm index c92250c73e91..b8afbd1afe38 100644 --- a/modular_darkpack/modules/decor/code/decor.dm +++ b/modular_darkpack/modules/decor/code/decor.dm @@ -148,6 +148,8 @@ if(istype(my_area) && my_area.outdoors) icon_state = "[base_icon_state]-snow" + AddComponent(/datum/component/trash_source) + /obj/structure/closet/crate/dumpster/PopulateContents() if(prob(internal_trash_chance)) if(prob(95)) diff --git a/modular_darkpack/modules/decor/code/trash_source.dm b/modular_darkpack/modules/decor/code/trash_source.dm new file mode 100644 index 000000000000..c4be34947a28 --- /dev/null +++ b/modular_darkpack/modules/decor/code/trash_source.dm @@ -0,0 +1,49 @@ +#define COMSIG_OBJ_NPC_WALKBY "obj_npc_walkby" +#define DISPOSED_TRASH_TRAIT "disposed_trash" + +/datum/component/trash_source + COOLDOWN_DECLARE(trash_spawn_cd) + var/datum/proximity_monitor/npc_walkby_detector/prox_monitor + +/datum/component/trash_source/Initialize() + . = ..() + + if(!isobj(parent)) + return COMPONENT_INCOMPATIBLE + +/datum/component/trash_source/RegisterWithParent() + . = ..() + RegisterSignal(parent, COMSIG_OBJ_NPC_WALKBY, PROC_REF(guy_walked_by)) + prox_monitor = new(parent, 1) + +/datum/component/trash_source/UnregisterFromParent() + . = ..() + + UnregisterSignal(parent, COMSIG_OBJ_NPC_WALKBY) + QDEL_NULL(prox_monitor) + + +/datum/component/trash_source/proc/guy_walked_by(obj/source, mob/living/carbon/human/npc/walker) + if(walker.hostile || walker.aggressive) + return // We are busy beating the shit out of someone. + + if(HAS_TRAIT(walker, DISPOSED_TRASH_TRAIT)) // Prevents making a conveyor of npcs to farm trash or accidential trash vortexes from stuck npcs. + return + + if(COOLDOWN_FINISHED(src, trash_spawn_cd)) + new /obj/effect/spawner/random/maintenance(get_turf(source)) + + ADD_TRAIT(walker, DISPOSED_TRASH_TRAIT, TRAIT_GENERIC) + + COOLDOWN_START(src, trash_spawn_cd, rand(1 MINUTES, 5 MINUTES)) + + +/datum/proximity_monitor/npc_walkby_detector + +/datum/proximity_monitor/npc_walkby_detector/on_entered(atom/source, atom/movable/arrived, turf/old_loc) + . = ..() + if(isnpc(arrived)) + SEND_SIGNAL(host, COMSIG_OBJ_NPC_WALKBY, arrived) + +#undef DISPOSED_TRASH_TRAIT +#undef COMSIG_OBJ_NPC_WALKBY diff --git a/tgstation.dme b/tgstation.dme index 1c1df1be4c0b..5561042a0490 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -7160,6 +7160,7 @@ #include "modular_darkpack\modules\decor\code\swaying.dm" #include "modular_darkpack\modules\decor\code\tables.dm" #include "modular_darkpack\modules\decor\code\trash.dm" +#include "modular_darkpack\modules\decor\code\trash_source.dm" #include "modular_darkpack\modules\decor\code\vents.dm" #include "modular_darkpack\modules\deprecated\code\runtime_town_types.dm" #include "modular_darkpack\modules\do_emotes\code\do_verbs.dm"