mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-20 04:26:03 +01:00
Fixes water-resistant creampies (#76653)
## About The Pull Request Fixes https://github.com/tgstation/tgstation/issues/76641 Caused by the bodypart overlay being deleted before it got properly removed on UnregisterFromParent() ## Why It's Good For The Game One less hard delete and one less bug caused by said hard delete ## Changelog 🆑 fix: Creampies will no longer irreparably stain your face /🆑
This commit is contained in:
@@ -27,5 +27,5 @@
|
||||
|
||||
///A creampie drawn on the head
|
||||
/datum/bodypart_overlay/simple/creampie
|
||||
icon_state = "creampie"
|
||||
icon_state = "creampie_human"
|
||||
layers = EXTERNAL_FRONT
|
||||
|
||||
@@ -11,9 +11,9 @@ GLOBAL_LIST_INIT(creamable, typecacheof(list(
|
||||
/datum/component/creamed
|
||||
dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS
|
||||
/// Creampie overlay we use for non-carbon mobs
|
||||
var/mutable_appearance/creamface
|
||||
var/mutable_appearance/normal_overlay
|
||||
/// Creampie bodypart overlay we use for carbon mobs
|
||||
var/datum/bodypart_overlay/simple/creampie/creampie
|
||||
var/datum/bodypart_overlay/simple/creampie/bodypart_overlay
|
||||
/// Cached head for carbons, to ensure proper removal of the creampie overlay
|
||||
var/obj/item/bodypart/my_head
|
||||
|
||||
@@ -26,10 +26,10 @@ GLOBAL_LIST_INIT(creamable, typecacheof(list(
|
||||
add_memory_in_range(parent, 7, /datum/memory/witnessed_creampie, protagonist = parent)
|
||||
|
||||
/datum/component/creamed/Destroy(force)
|
||||
creamface = null
|
||||
. = ..()
|
||||
normal_overlay = null
|
||||
my_head = null
|
||||
QDEL_NULL(creampie)
|
||||
return ..()
|
||||
QDEL_NULL(bodypart_overlay)
|
||||
|
||||
/datum/component/creamed/RegisterWithParent()
|
||||
if(iscarbon(parent))
|
||||
@@ -38,28 +38,28 @@ GLOBAL_LIST_INIT(creamable, typecacheof(list(
|
||||
if(!my_head) //just to be sure
|
||||
qdel(src)
|
||||
return
|
||||
creampie = new()
|
||||
if(my_head.bodytype & BODYTYPE_SNOUTED)
|
||||
creampie.icon_state = "creampie_lizard"
|
||||
bodypart_overlay = new()
|
||||
if(carbon_parent.bodytype & BODYTYPE_SNOUTED) //stupid, but external organ bodytypes are not stored on the limb
|
||||
bodypart_overlay.icon_state = "creampie_lizard"
|
||||
else if(my_head.bodytype & BODYTYPE_MONKEY)
|
||||
creampie.icon_state = "creampie_monkey"
|
||||
bodypart_overlay.icon_state = "creampie_monkey"
|
||||
else
|
||||
creampie.icon_state = "creampie_human"
|
||||
my_head.add_bodypart_overlay(creampie)
|
||||
RegisterSignal(my_head, COMSIG_BODYPART_REMOVED, PROC_REF(lost_head))
|
||||
bodypart_overlay.icon_state = "creampie_human"
|
||||
my_head.add_bodypart_overlay(bodypart_overlay)
|
||||
RegisterSignals(my_head, list(COMSIG_BODYPART_REMOVED, COMSIG_QDELETING), PROC_REF(lost_head))
|
||||
carbon_parent.add_mood_event("creampie", /datum/mood_event/creampie)
|
||||
carbon_parent.update_body_parts()
|
||||
else if(iscorgi(parent))
|
||||
creamface = mutable_appearance('icons/effects/creampie.dmi', "creampie_corgi")
|
||||
normal_overlay = mutable_appearance('icons/effects/creampie.dmi', "creampie_corgi")
|
||||
else if(isAI(parent))
|
||||
creamface = mutable_appearance('icons/effects/creampie.dmi', "creampie_ai")
|
||||
normal_overlay = mutable_appearance('icons/effects/creampie.dmi', "creampie_ai")
|
||||
|
||||
RegisterSignals(parent, list(
|
||||
COMSIG_COMPONENT_CLEAN_ACT,
|
||||
COMSIG_COMPONENT_CLEAN_FACE_ACT),
|
||||
PROC_REF(clean_up)
|
||||
)
|
||||
if(creamface)
|
||||
if(normal_overlay)
|
||||
var/atom/atom_parent = parent
|
||||
RegisterSignal(atom_parent, COMSIG_ATOM_UPDATE_OVERLAYS, PROC_REF(update_overlays))
|
||||
atom_parent.update_appearance()
|
||||
@@ -69,34 +69,39 @@ GLOBAL_LIST_INIT(creamable, typecacheof(list(
|
||||
COMSIG_COMPONENT_CLEAN_ACT,
|
||||
COMSIG_COMPONENT_CLEAN_FACE_ACT))
|
||||
if(my_head)
|
||||
if(creampie)
|
||||
my_head.remove_bodypart_overlay(creampie)
|
||||
UnregisterSignal(my_head, COMSIG_BODYPART_REMOVED)
|
||||
if(bodypart_overlay)
|
||||
my_head.remove_bodypart_overlay(bodypart_overlay)
|
||||
if(!my_head.owner)
|
||||
my_head.update_icon_dropped()
|
||||
QDEL_NULL(bodypart_overlay)
|
||||
UnregisterSignal(my_head, list(COMSIG_BODYPART_REMOVED, COMSIG_QDELETING))
|
||||
my_head = null
|
||||
if(iscarbon(parent))
|
||||
var/mob/living/carbon/carbon_parent = parent
|
||||
carbon_parent.clear_mood_event("creampie")
|
||||
carbon_parent.update_body_parts()
|
||||
if(creamface)
|
||||
if(normal_overlay)
|
||||
var/atom/atom_parent = parent
|
||||
UnregisterSignal(atom_parent, COMSIG_ATOM_UPDATE_OVERLAYS)
|
||||
atom_parent.update_appearance()
|
||||
normal_overlay = null
|
||||
|
||||
///Callback to remove pieface
|
||||
/datum/component/creamed/proc/clean_up(datum/source, clean_types)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
. = NONE
|
||||
if(!(clean_types & CLEAN_TYPE_BLOOD))
|
||||
return
|
||||
return NONE
|
||||
|
||||
qdel(src)
|
||||
return COMPONENT_CLEANED
|
||||
|
||||
/// Ensures creamface overlay in case the mob is not a carbon
|
||||
/// Ensures normal_overlay overlay in case the mob is not a carbon
|
||||
/datum/component/creamed/proc/update_overlays(atom/parent_atom, list/overlays)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
if(creamface)
|
||||
overlays += creamface
|
||||
if(normal_overlay)
|
||||
overlays += normal_overlay
|
||||
|
||||
/// Removes creampie when the head gets dismembered
|
||||
/datum/component/creamed/proc/lost_head(obj/item/bodypart/source, mob/living/carbon/owner, dismembered)
|
||||
|
||||
Reference in New Issue
Block a user