fixes cleaning animation disappearing if you clean something that's already being cleaned (#71673)

## About The Pull Request
1: Start cleaning something.
2: Clean the same thing again before the original cleaning manages to
finish. This removes the cleaning bubbles animation early, before the
actual cleaning is done. You can also spam the start cleaning message
with this.

The cleaning overlay is removed after the do_after that makes you wait
the time it takes to clean. When you're already waiting and you clean it
a second time the do_after returns instantly and removes the overlay
while the first one is still waiting.

But it seems that we don't even need to bother with any of that code if
we're already cleaning the thing, so we can just return early and
prevent the issue.
## Why It's Good For The Game
Fixes a graphical bug.
## Changelog
🆑
fix: trying to clean something while it's already being cleaned will no
longer prematurely remove the cleaning animation
/🆑
This commit is contained in:
kawoppi
2022-12-06 00:39:01 -08:00
committed by GitHub
parent e1489d6288
commit dba21aa8bd
+16 -15
View File
@@ -88,22 +88,25 @@
* * clean_target set this to false if the target should not be washed and if experience should not be awarded to the user
*/
/datum/component/cleaner/proc/clean(datum/source, atom/target, mob/living/user, clean_target = TRUE)
if(!HAS_TRAIT(target, TRAIT_CURRENTLY_CLEANING)) //add the trait and overlay
ADD_TRAIT(target, TRAIT_CURRENTLY_CLEANING, REF(src))
//make sure we don't attempt to clean something while it's already being cleaned
if(HAS_TRAIT(target, TRAIT_CURRENTLY_CLEANING))
return
// We need to update our planes on overlay changes
RegisterSignal(target, COMSIG_MOVABLE_Z_CHANGED, PROC_REF(cleaning_target_moved))
var/mutable_appearance/low_bubble = mutable_appearance('icons/effects/effects.dmi', "bubbles", FLOOR_CLEAN_LAYER, target, GAME_PLANE)
var/mutable_appearance/high_bubble = mutable_appearance('icons/effects/effects.dmi', "bubbles", FLOOR_CLEAN_LAYER, target, ABOVE_GAME_PLANE)
if(target.plane > low_bubble.plane) //check if the higher overlay is necessary
//add the trait and overlay
ADD_TRAIT(target, TRAIT_CURRENTLY_CLEANING, REF(src))
// We need to update our planes on overlay changes
RegisterSignal(target, COMSIG_MOVABLE_Z_CHANGED, PROC_REF(cleaning_target_moved))
var/mutable_appearance/low_bubble = mutable_appearance('icons/effects/effects.dmi', "bubbles", FLOOR_CLEAN_LAYER, target, GAME_PLANE)
var/mutable_appearance/high_bubble = mutable_appearance('icons/effects/effects.dmi', "bubbles", FLOOR_CLEAN_LAYER, target, ABOVE_GAME_PLANE)
if(target.plane > low_bubble.plane) //check if the higher overlay is necessary
target.add_overlay(high_bubble)
else if(target.plane == low_bubble.plane)
if(target.layer > low_bubble.layer)
target.add_overlay(high_bubble)
else if(target.plane == low_bubble.plane)
if(target.layer > low_bubble.layer)
target.add_overlay(high_bubble)
else
target.add_overlay(low_bubble)
else //(target.plane < low_bubble.plane)
else
target.add_overlay(low_bubble)
else //(target.plane < low_bubble.plane)
target.add_overlay(low_bubble)
//set the cleaning duration
var/cleaning_duration = base_cleaning_duration
@@ -123,8 +126,6 @@
on_cleaned_callback?.Invoke(source, target, user)
//remove the cleaning overlay
var/mutable_appearance/low_bubble = mutable_appearance('icons/effects/effects.dmi', "bubbles", FLOOR_CLEAN_LAYER, target, GAME_PLANE)
var/mutable_appearance/high_bubble = mutable_appearance('icons/effects/effects.dmi', "bubbles", FLOOR_CLEAN_LAYER, target, ABOVE_GAME_PLANE)
target.cut_overlay(low_bubble)
target.cut_overlay(high_bubble)
UnregisterSignal(target, COMSIG_MOVABLE_Z_CHANGED)