Converts diggable from component to bespoke element (#67695)

* Changes diggable to an element and fixes it, saving on some memory.
This commit is contained in:
MrMelbert
2022-06-19 11:25:37 -04:00
committed by GitHub
parent c8f6b802c3
commit 325915e459
6 changed files with 52 additions and 34 deletions
-28
View File
@@ -1,28 +0,0 @@
/// Lets you make hitting a turf with a shovel pop something out, and scrape the turf
/datum/component/diggable
/// Typepath to spawn on hit
var/to_spawn
/// Amount to spawn on hit
var/amount
/// What should we tell the user they did?
var/action_text
/datum/component/diggable/Initialize(to_spawn, amount = 1, action_text)
. = ..()
if(!isturf(parent))
return COMPONENT_INCOMPATIBLE
src.to_spawn = to_spawn
src.amount = amount
src.action_text = action_text
RegisterSignal(parent, COMSIG_PARENT_ATTACKBY, .proc/handle_attack)
/datum/component/diggable/proc/handle_attack(datum/source, obj/item/hit_by, mob/living/bastard, params)
if(hit_by.tool_behaviour != TOOL_SHOVEL || !params)
return
var/turf/parent_turf = parent
for(var/i in 1 to amount)
new to_spawn(parent_turf)
bastard.visible_message(span_notice("[bastard] digs up [parent_turf]."), span_notice("You [action_text] [parent_turf]."))
playsound(parent_turf, 'sound/effects/shovel_dig.ogg', 50, TRUE)
parent_turf.ScrapeAway(flags = CHANGETURF_INHERIT_AIR)