Makes prefs application for ghost roles more flexible and granular (#96683)

## About The Pull Request

Tin, also applies this to the nightmare role since they shouldn't be
getting prefs applied to their mob.

## Why It's Good For The Game

You don't always want prefs to be applied the same way (or sometimes, at
all) for each ghost role, and by just moving that logic out to
overridable procs. this allows for granular control over that

## Changelog

🆑
fix: shadows will no longer get the candidate's prefs applied to their
mob
/🆑

---------

Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
This commit is contained in:
Bloop
2026-07-05 09:02:56 +02:00
committed by GitHub
co-authored by MrMelbert
parent 57c34810ac
commit e4b395055c
@@ -230,11 +230,8 @@
if(isnull(body))
return
candidate.transfer_to(body, force_key_move = TRUE) // yoinks the candidate's client
if(ishuman(body))
var/mob/living/carbon/human/human_body = body
body.client?.prefs.safe_transfer_prefs_to(body)
human_body.dna.remove_all_mutations()
human_body.dna.update_dna_identity()
if(ishuman(body) && apply_prefs_to_body(body))
on_prefs_applied(body)
/**
* Handles making the body for the candidate
@@ -262,6 +259,24 @@
role_name_text = readable_poll_role,
)
/**
* Handles prepping the body with the candidate's prefs
*
* Applies prefs to a given body. Usually that's what you want, but sometimes you don't, in which case you can override this proc.
* Returns TRUE if prefs were applied
*/
/datum/dynamic_ruleset/midround/from_ghosts/proc/apply_prefs_to_body(mob/living/carbon/human/body)
body.client?.prefs.safe_transfer_prefs_to(body)
body.dna.remove_all_mutations()
body.dna.update_dna_identity()
return TRUE
/**
* Handles anything extra you want to happen after applying prefs
*/
/datum/dynamic_ruleset/midround/from_ghosts/proc/on_prefs_applied(mob/living/carbon/human/body)
return
/datum/dynamic_ruleset/midround/from_ghosts/wizard
name = "Wizard"
config_tag = "Midround Wizard"
@@ -512,6 +527,9 @@
max_antag_cap = 1
signup_atom_appearance = /obj/item/light_eater
/datum/dynamic_ruleset/midround/from_ghosts/nightmare/apply_prefs_to_body(mob/living/carbon/human/body)
return FALSE
/datum/dynamic_ruleset/midround/from_ghosts/nightmare/can_be_selected()
return ..() && !isnull(find_maintenance_spawn(atmos_sensitive = TRUE, require_darkness = TRUE))