Merge pull request #5559 from CHOMPStation2/upstream-merge-14344

[MIRROR] better persistent dirt
This commit is contained in:
Nadyr
2023-01-27 09:32:25 -05:00
committed by GitHub
5 changed files with 40 additions and 3 deletions
@@ -38,11 +38,24 @@
icon_state = "dirt"
mouse_opacity = 0
/obj/effect/decal/cleanable/dirt/Initialize(var/mapload, var/_age) //CHOMPEdit
/obj/effect/decal/cleanable/dirt/Initialize(var/mapload, var/_age, var/dirt)
.=..()
var/turf/simulated/our_turf = src.loc
if(our_turf && istype(our_turf) && our_turf.can_dirty && _age)
our_turf.dirt = 101
if(our_turf && istype(our_turf) && our_turf.can_dirty)
our_turf.dirt = clamp(max(age ? (dirt ? dirt : 101) : our_turf.dirt, our_turf.dirt), 0, 101)
var/calcalpha = our_turf.dirt > 50 ? min((our_turf.dirt - 50) * 5, 255) : 0
var/alreadyfound = FALSE
for (var/obj/effect/decal/cleanable/dirt/alreadythere in our_turf) //in case of multiple
if (alreadythere == src)
continue
else if (alreadyfound)
qdel(alreadythere)
continue
alreadyfound = TRUE
alreadythere.alpha = calcalpha //don't need to constantly recalc for all of them in it because it'll just max if a non-persistent dirt overlay gets added, and then the new dirt overlay will be deleted
if (alreadyfound)
return INITIALIZE_HINT_QDEL
alpha = calcalpha
/obj/effect/decal/cleanable/flour
name = "flour"