Files
Bubberstation/code/datums/components/ling_decoy_brain.dm
Ghom 778ed9f1ab The death or internal/external organ pathing (ft. fixed fox ears and recoloring bodypart overlays with dye sprays) (#87434)
## About The Pull Request
This PR kills the abstract internal and external typepaths for organs,
now replaced by an EXTERNAL_ORGAN flag to distinguish the two kinds.

This PR also fixes fox ears (from #87162, no tail is added) and
mushpeople's caps (they should be red, the screenshot is a tad
outdated).

And yes, you can now use a hair dye spray to recolor body parts like
most tails, podpeople hair, mushpeople caps and cat ears. The process
can be reversed by using the spray again.

## Why It's Good For The Game
Time-Green put some effort during the last few months to untie functions
and mechanics from external/internal organ pathing. Now, all that this
pathing is good for are a few typechecks, easily replaceable with
bitflags.

Also podpeople and mushpeople need a way to recolor their "hair". This
kind of applies to fish tails from the fish infusion, which colors can't
be selected right now. The rest is just there if you ever want to
recolor your lizard tail for some reason.

Proof of testing btw (screenshot taken before mushpeople cap fix, right
side has dyed body parts, moth can't be dyed, they're already fabolous):

![immagine](https://github.com/user-attachments/assets/2bb625c9-9233-42eb-b9b8-e0bd6909ce89)

## Changelog

🆑
code: Removed internal/external pathing from organs in favor of a bit
flag. Hopefully this shouldn't break anything about organs.
fix: Fixed invisible fox ears.
fix: Fixed mushpeople caps not being colored red by default.
add: You can now dye most tails, podpeople hair, mushpeople caps etc.
with a hair dye spray.
/🆑
2024-10-30 08:03:02 +01:00

69 lines
2.8 KiB
Plaintext

/// Component applied to ling brains to make them into decoy brains, as ling brains are vestigial and don't do anything
/datum/component/ling_decoy_brain
/// The ling this brain is linked to
VAR_FINAL/datum/antagonist/changeling/parent_ling
/// A talk action that is granted to the ling when this decoy enters an MMI
VAR_FINAL/datum/action/changeling/mmi_talk/talk_action
/datum/component/ling_decoy_brain/Initialize(datum/antagonist/changeling/ling)
if(!istype(parent, /obj/item/organ/brain))
return COMPONENT_INCOMPATIBLE
if(isnull(ling))
stack_trace("[type] instantiated without a changeling to link to.")
return COMPONENT_INCOMPATIBLE
parent_ling = ling
RegisterSignal(parent_ling, COMSIG_QDELETING, PROC_REF(clear_decoy))
/datum/component/ling_decoy_brain/Destroy()
UnregisterSignal(parent_ling, COMSIG_QDELETING)
parent_ling = null
QDEL_NULL(talk_action)
return ..()
/datum/component/ling_decoy_brain/RegisterWithParent()
var/obj/item/organ/brain/ling_brain = parent
ling_brain.organ_flags &= ~ORGAN_VITAL
ling_brain.decoy_override = TRUE
RegisterSignal(ling_brain, COMSIG_ATOM_ENTERING, PROC_REF(entered_mmi))
/datum/component/ling_decoy_brain/UnregisterFromParent()
var/obj/item/organ/brain/ling_brain = parent
ling_brain.organ_flags |= ORGAN_VITAL
ling_brain.decoy_override = FALSE
UnregisterSignal(ling_brain, COMSIG_ATOM_ENTERING, PROC_REF(entered_mmi))
/**
* Signal proc for [COMSIG_ATOM_ENTERING], when the brain enters an MMI grant the MMI talk action to the ling
*
* Unfortunately this is hooked on Entering rather than its own dedicated MMI signal becuase MMI code is a fuck
*/
/datum/component/ling_decoy_brain/proc/entered_mmi(obj/item/organ/brain/source, atom/entering, atom/old_loc, ...)
SIGNAL_HANDLER
var/mob/living/the_real_ling = parent_ling.owner.current
if(!istype(the_real_ling))
return
if(istype(source.loc, /obj/item/mmi) && talk_action?.owner != the_real_ling)
if(isnull(talk_action))
talk_action = new() // Not linked to anything, we manage the reference (and don't want it disappearing on us)
talk_action.brain_ref = source
if(the_real_ling.key)
to_chat(the_real_ling, span_ghostalert("We detect our decoy brain has been placed within a Man-Machine Interface. \
We can use the \"MMI Talk\" action to command it to speak."))
else
the_real_ling.notify_revival("Your decoy brain has been placed in an MMI, re-enter your body to talk via it!", source = the_real_ling, flashwindow = TRUE)
talk_action.Grant(the_real_ling)
else if(talk_action?.owner == the_real_ling)
to_chat(the_real_ling, span_ghostalert("We can no longer detect our decoy brain."))
talk_action.Remove(the_real_ling)
/// Clear up the decoy if the ling is de-linged
/datum/component/ling_decoy_brain/proc/clear_decoy(datum/source)
SIGNAL_HANDLER
qdel(src)