Files
Bubberstation/code/datums/components/onwear_mood.dm
T
d4cc3b3e68 [MIRROR] Fixes a bad argument for onwear comp [MDB IGNORE] (#18699)
* Fixes a bad argument for onwear comp (#72653)

## About The Pull Request

Everywhere used `saved_event_type` but the parameters, causing runtime

## Why It's Good For The Game

Runtimes bad

## Changelog

🆑 Melbert
fix: Fixed not getting moodlet from freshly laundered clothing
/🆑

* Fixes a bad argument for onwear comp

Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
2023-01-13 19:34:07 -08:00

55 lines
2.0 KiB
Plaintext

/// Add to clothing to give the wearer a mood buff and a unique examine text
/datum/component/onwear_mood
/// the event the wearer experiences
var/datum/mood_event/saved_event_type
/// examine string added to examine
var/examine_string
/// what slots it needs to be equipped to to work
var/slot_equip
/datum/component/onwear_mood/Initialize(datum/mood_event/saved_event_type, examine_string, slot_equip = ITEM_SLOT_ON_BODY)
if(!isitem(parent))
return COMPONENT_INCOMPATIBLE
src.saved_event_type = saved_event_type
src.examine_string = examine_string
if(!isnum(slot_equip))
stack_trace("Attempted to initialize onwear component with improper slot_equip [slot_equip]")
slot_equip = ITEM_SLOT_ON_BODY
src.slot_equip = slot_equip
/datum/component/onwear_mood/RegisterWithParent()
RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, PROC_REF(affect_wearer))
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, PROC_REF(on_examine))
/datum/component/onwear_mood/UnregisterFromParent()
UnregisterSignal(parent, list(COMSIG_ITEM_EQUIPPED, COMSIG_PARENT_EXAMINE))
clear_effects()
/datum/component/onwear_mood/proc/affect_wearer(datum/source, mob/living/target, slot)
SIGNAL_HANDLER
if(!(slot & slot_equip))
return // only affects "worn" slots by default
target.add_mood_event(REF(src), saved_event_type)
RegisterSignal(target, COMSIG_PARENT_EXAMINE, PROC_REF(on_examine))
RegisterSignal(target, COMSIG_MOB_UNEQUIPPED_ITEM, PROC_REF(clear_effects))
/datum/component/onwear_mood/proc/on_examine(datum/source, mob/user, list/examine_text)
SIGNAL_HANDLER
examine_text += span_notice(examine_string)
/// clears the effects on the wearer
/datum/component/onwear_mood/proc/clear_effects(mob/living/source, obj/item/dropped_item)
SIGNAL_HANDLER
var/obj/item/clothing = parent
// if called from a signal, check clothing
if(dropped_item && dropped_item != clothing)
return
source ||= clothing.loc
if(!istype(source))
return
UnregisterSignal(source, list(COMSIG_PARENT_EXAMINE, COMSIG_MOB_UNEQUIPPED_ITEM))
source.clear_mood_event(REF(src))