Standardize cleaning object behavior into "cleaning_act" proc (#19001)

* Standardizes cleaning item functionality into "cleaning_act" proc

* Culling commented-out code

* Damp rag now checks for humans before cleaning

* Change proc scoping, moved mop reagent check out of cleaning.dm

* Adds can_clean and post_clean procs to handle mopping, removes ismop parameter

* Adds can_clean() to cleaning objects/mobs

* cleaning_act() now carries message strings as params

* Refactored cleaning_act() for earlier returns and less redundancy

* cleaning_act now runs on the target atom, instead of the cleaning object

* Changed turf checks to overrides, rescoped clean_turf, lots of tidying

* Removed cleaner param from post_clean, since it'll always be src

* Code review tidying

* Tidying..........

* Removed clean_turf and put its functionality in turf/simulated/cleaning_act(), added new param to keep track of original targeted object

* Moved cleaning.dm from datums to code/game/objects

* Added early return, defined cleanspeed in seconds
This commit is contained in:
FloFluoro
2022-10-03 20:25:00 +01:00
committed by GitHub
parent dfad5f2004
commit 6a876e1994
10 changed files with 123 additions and 88 deletions
+15 -21
View File
@@ -35,33 +35,27 @@
to_chat(user, "<span class='notice'>You wet [src] in [o].</span>")
playsound(loc, 'sound/effects/slosh.ogg', 25, 1)
/obj/item/mop/proc/clean(turf/simulated/A)
if(reagents.has_reagent("water", 1) || reagents.has_reagent("cleaner", 1) || reagents.has_reagent("holywater", 1))
A.clean_blood()
for(var/obj/effect/O in A)
if(O.is_cleanable())
qdel(O)
reagents.reaction(A, REAGENT_TOUCH, 10) //10 is the multiplier for the reaction effect. probably needed to wet the floor properly.
reagents.remove_any(1) //reaction() doesn't use up the reagents
/obj/item/mop/afterattack(atom/A, mob/user, proximity)
if(!proximity) return
if(!proximity)
return
if(istype(A, /obj/item/reagent_containers/glass/bucket) || istype(A, /obj/structure/janitorialcart) || istype(A, /obj/structure/mopbucket))
return
if(reagents.total_volume < 1)
to_chat(user, "<span class='warning'>Your mop is dry!</span>")
return
A.cleaning_act(user, src, mopspeed, text_verb = "mop", text_description = ".")
var/turf/simulated/T = get_turf(A)
/obj/item/mop/can_clean()
if(reagents.has_reagent("water", 1) || reagents.has_reagent("cleaner", 1) || reagents.has_reagent("holywater", 1))
return TRUE
else
return FALSE
if(istype(A, /obj/item/reagent_containers/glass/bucket) || istype(A, /obj/structure/janitorialcart) || istype(A, /obj/structure/mopbucket))
return
if(istype(T))
user.visible_message("[user] begins to clean [T] with [src].", "<span class='notice'>You begin to clean [T] with [src]...</span>")
if(do_after(user, src.mopspeed, target = T))
to_chat(user, "<span class='notice'>You finish mopping.</span>")
clean(T)
/obj/item/mop/post_clean(atom/target, mob/user)
var/turf/T = get_turf(target)
if(issimulatedturf(T))
reagents.reaction(T, REAGENT_TOUCH, 10) //10 is the multiplier for the reaction effect. probably needed to wet the floor properly.
reagents.remove_any(1) //reaction() doesn't use up the reagents
/obj/effect/attackby(obj/item/I, mob/user, params)
if(istype(I, /obj/item/mop) || istype(I, /obj/item/soap))
+8 -32
View File
@@ -18,43 +18,16 @@
AddComponent(/datum/component/slippery, src, 8 SECONDS, 100, 0, FALSE)
/obj/item/soap/afterattack(atom/target, mob/user, proximity)
if(!proximity) return
//I couldn't feasibly fix the overlay bugs caused by cleaning items we are wearing.
//So this is a workaround. This also makes more sense from an IC standpoint. ~Carn
if(user.client && (target in user.client.screen))
to_chat(user, "<span class='notice'>You need to take that [target.name] off before cleaning it.</span>")
else if(target == user && user.a_intent == INTENT_GRAB && ishuman(target))
if(!proximity)
return
if(target == user && user.a_intent == INTENT_GRAB && ishuman(target))
var/mob/living/carbon/human/muncher = user
if(muncher && isdrask(muncher))
to_chat(user, "<span class='notice'>You take a bite of [src]. Delicious!</span>")
playsound(user.loc, 'sound/items/eatfood.ogg', 50, 0)
user.adjust_nutrition(2)
else if(istype(target, /obj/effect/decal/cleanable) || istype(target, /obj/effect/rune))
user.visible_message("<span class='warning'>[user] begins to scrub \the [target.name] out with [src].</span>")
if(do_after(user, cleanspeed, target = target) && target)
to_chat(user, "<span class='notice'>You scrub \the [target.name] out.</span>")
if(issimulatedturf(target.loc))
clean_turf(target.loc)
return
qdel(target)
else if(issimulatedturf(target))
user.visible_message("<span class='warning'>[user] begins to clean \the [target.name] with [src].</span>")
if(do_after(user, cleanspeed, target = target))
to_chat(user, "<span class='notice'>You clean \the [target.name].</span>")
clean_turf(target)
else
user.visible_message("<span class='warning'>[user] begins to clean \the [target.name] with [src].</span>")
if(do_after(user, cleanspeed, target = target))
to_chat(user, "<span class='notice'>You clean \the [target.name].</span>")
var/obj/effect/decal/cleanable/C = locate() in target
qdel(C)
target.clean_blood()
/obj/item/soap/proc/clean_turf(turf/simulated/T)
T.clean_blood()
for(var/obj/effect/O in T)
if(O.is_cleanable())
qdel(O)
return
target.cleaning_act(user, src, cleanspeed)
/obj/item/soap/attack(mob/target as mob, mob/user as mob)
if(target && user && ishuman(target) && ishuman(user) && !target.stat && !user.stat && user.zone_selected == "mouth" )
@@ -62,6 +35,9 @@
return
..()
/obj/item/soap/can_clean()
return TRUE
/obj/item/soap/nanotrasen
desc = "A Nanotrasen brand bar of soap. Smells of plasma."
icon_state = "soapnt"