diff --git a/code/__DEFINES/dcs/signals.dm b/code/__DEFINES/dcs/signals.dm index ad993433eac..b64c5f799a0 100644 --- a/code/__DEFINES/dcs/signals.dm +++ b/code/__DEFINES/dcs/signals.dm @@ -479,6 +479,8 @@ #define COMSIG_CARBON_THROWN_ITEM_CAUGHT "carbon_thrown_item_caught" /// From /mob/living/carbon/flash_eyes() #define COMSIG_CARBON_FLASH_EYES "carbon_flash_eyes" +/// From /mob/living/carbon/regenerate_icons() +#define COMSIG_CARBON_REGENERATE_ICONS "carbon_regen_icons" // /mob/living/simple_animal/hostile signals diff --git a/code/game/objects/structures/flora.dm b/code/game/objects/structures/flora.dm index be9ba9d938d..a1f13c82e8b 100644 --- a/code/game/objects/structures/flora.dm +++ b/code/game/objects/structures/flora.dm @@ -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) diff --git a/code/modules/mob/living/carbon/carbon_update_icons.dm b/code/modules/mob/living/carbon/carbon_update_icons.dm index 6222a6a7faa..2b9bbee950d 100644 --- a/code/modules/mob/living/carbon/carbon_update_icons.dm +++ b/code/modules/mob/living/carbon/carbon_update_icons.dm @@ -24,6 +24,9 @@ floating = FALSE animate(src, transform = ntransform, time = (lying_prev == 0 || lying_angle == 0) ? 2 : 0, pixel_y = final_pixel_y, dir = final_dir, easing = (EASE_IN|EASE_OUT)) +/mob/living/carbon/regenerate_icons() + SEND_SIGNAL(src, COMSIG_CARBON_REGENERATE_ICONS, src) + return ..() /mob/living/carbon/proc/handle_transform_change() return