[s] Fixes an issue with potted plants (#21529)

* fixes this

* tweaks
This commit is contained in:
S34N
2023-07-01 11:12:29 +01:00
committed by GitHub
parent 8ce541adb1
commit 980fee9b60
3 changed files with 23 additions and 5 deletions
+18 -5
View File
@@ -276,28 +276,41 @@
icon_state = "plant-36"
/obj/item/twohanded/required/kirbyplants/Destroy()
if(isliving(loc))
if(iscarbon(loc))
unhide_user(loc)
QDEL_NULL(mob_overlay)
return ..()
/obj/item/twohanded/required/kirbyplants/equipped(mob/living/user)
/obj/item/twohanded/required/kirbyplants/equipped(mob/living/carbon/user)
. = ..()
if(wielded)
hide_user(user)
return
unhide_user(user)
/obj/item/twohanded/required/kirbyplants/proc/hide_user(mob/living/user)
/// User has decided to hold a plant, apply stealth.
/obj/item/twohanded/required/kirbyplants/proc/hide_user(mob/living/carbon/user)
RegisterSignal(user, COMSIG_CARBON_REGENERATE_ICONS, PROC_REF(reapply_hide))
mob_overlay = mutable_appearance(icon, icon_state, user.layer, user.plane, 255, appearance_flags = RESET_COLOR | RESET_TRANSFORM | RESET_ALPHA | KEEP_APART)
user.add_overlay(mob_overlay)
user.alpha = 0
/obj/item/twohanded/required/kirbyplants/proc/unhide_user(mob/living/user)
/// User has either dropped the plant, or plant is being destroyed, restore user to normal.
/obj/item/twohanded/required/kirbyplants/proc/unhide_user(mob/living/carbon/user)
UnregisterSignal(user, COMSIG_CARBON_REGENERATE_ICONS)
user.cut_overlay(mob_overlay)
user.alpha = initial(user.alpha)
QDEL_NULL(mob_overlay)
/obj/item/twohanded/required/kirbyplants/dropped(mob/living/user)
/// Icon operation has occured, time to make sure we're showing a plant again if we need to be.
/obj/item/twohanded/required/kirbyplants/proc/reapply_hide(mob/living/carbon/user)
SIGNAL_HANDLER
// Reset the state of the user
unhide_user(user)
hide_user(user)
/obj/item/twohanded/required/kirbyplants/dropped(mob/living/carbon/user)
..()
unhide_user(user)