From 64d27e50e3da1a094a225a78c7c19ec935626d9e Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Fri, 4 Nov 2022 17:58:53 +0100 Subject: [PATCH] [MIRROR] Saves 2 seconds off init by inlining the bumpclick element [MDB IGNORE] (#17339) * Saves 2 seconds off init by inlining the bumpclick element (#71008) ## About The Pull Request It was also a tad yorked so I fixed that bit bump_click did very little in this case, and while the modularity is nice, the hotness of minerals made this totally untenable * Saves 2 seconds off init by inlining the bumpclick element Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> --- code/datums/elements/bump_click.dm | 2 +- code/game/turfs/closed/minerals.dm | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/code/datums/elements/bump_click.dm b/code/datums/elements/bump_click.dm index 15e83d787b4..6f7e3be66ea 100644 --- a/code/datums/elements/bump_click.dm +++ b/code/datums/elements/bump_click.dm @@ -17,7 +17,7 @@ ///Click with any item? var/allow_any = TRUE -/datum/element/bump_click/Attach(datum/target, list/tool_behaviours, list/tool_items, allow_unarmed = FALSE, allow_combat = FALSE, allow_any = FALSE) +/datum/element/bump_click/Attach(datum/target, list/tool_behaviours, list/tool_types, allow_unarmed = FALSE, allow_combat = FALSE, allow_any = FALSE) . = ..() if(!isatom(target) || isarea(target)) diff --git a/code/game/turfs/closed/minerals.dm b/code/game/turfs/closed/minerals.dm index ffa1bbe719d..dacff329ba3 100644 --- a/code/game/turfs/closed/minerals.dm +++ b/code/game/turfs/closed/minerals.dm @@ -37,8 +37,18 @@ M.Translate(-4, -4) transform = M icon = smooth_icon - var/static/list/behaviors = list(TOOL_MINING) - AddElement(/datum/element/bump_click, tool_behaviours = behaviors, allow_unarmed = TRUE) + +// Inlined version of the bump click element. way faster this way, the element's nice but it's too much overhead +/turf/closed/mineral/Bumped(atom/movable/bumped_atom) + . = ..() + if(!isliving(bumped_atom)) + return + + var/mob/living/bumping = bumped_atom + var/obj/item/held_item = bumping.get_active_held_item() + // !held_item exists to be nice to snow. the other bit is for pickaxes obviously + if(!held_item || held_item.tool_behaviour == TOOL_MINING) + INVOKE_ASYNC(bumping, /mob.proc/ClickOn, src) /turf/closed/mineral/proc/Spread_Vein() var/spreadChance = initial(mineralType.spreadChance)