Skip to content

Commit

Permalink
make engravings removable with a welder (#411)
Browse files Browse the repository at this point in the history
* make engravings removable with a welder

* fix

* piss off linter

* fuck off trash ass linter you're WRONG

* make it actually work

* Fixes engraved component runtime on destroy() (#69323)

..() nulls the parent

---------

Co-authored-by: ShizCalev <ShizCalev@users.noreply.github.com>
  • Loading branch information
Kapu1178 and ShizCalev authored Jul 8, 2023
1 parent b145701 commit 5a3268c
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions code/datums/components/engraved.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,26 @@
engraved_wall.update_appearance()

/datum/component/engraved/Destroy(force, silent)
. = ..()
if(!parent)
return ..()
parent.RemoveElement(/datum/element/art)
//must be here to allow overlays to be updated
UnregisterSignal(parent, COMSIG_ATOM_UPDATE_OVERLAYS)
if(parent && !QDELING(parent))
if(!QDELING(parent))
var/atom/parent_atom = parent
parent_atom.update_appearance()
return ..() //call this after since we null out the parent

/datum/component/engraved/RegisterWithParent()
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, PROC_REF(on_examine))
RegisterSignal(parent, COMSIG_ATOM_TOOL_ACT(TOOL_WELDER), PROC_REF(on_tool_act))
//supporting component transfer means putting these here instead of initialize
SSpersistence.wall_engravings += src
ADD_TRAIT(parent, TRAIT_NOT_ENGRAVABLE, TRAIT_GENERIC)

/datum/component/engraved/UnregisterFromParent()
UnregisterSignal(parent, COMSIG_PARENT_EXAMINE)
UnregisterSignal(parent, COMSIG_ATOM_TOOL_ACT(TOOL_WELDER))
//supporting component transfer means putting these here instead of destroy
SSpersistence.wall_engravings -= src
REMOVE_TRAIT(parent, TRAIT_NOT_ENGRAVABLE, TRAIT_GENERIC)
Expand All @@ -81,6 +85,17 @@
/datum/component/engraved/proc/on_examine(datum/source, mob/user, list/examine_list)
SIGNAL_HANDLER
examine_list += span_boldnotice(engraved_description)
examine_list += span_notice("You can probably get this out with a <b>welding tool</b>.")

/datum/component/engraved/proc/on_tool_act(datum/source, mob/user, obj/item/tool)
SIGNAL_HANDLER
set waitfor = FALSE //Do not remove without removing the UNLINT below

. = COMPONENT_BLOCK_TOOL_ATTACK
to_chat(user, span_notice("You begin to remove the engraving on [parent]."))
if(UNLINT(do_after(user, parent, 4 SECONDS, DO_PUBLIC, display = tool)))
to_chat(user, span_notice("You remove the engraving on [parent]."))
qdel(src)

///returns all the information SSpersistence needs in a list to load up this engraving on a future round!
/datum/component/engraved/proc/save_persistent()
Expand Down

0 comments on commit 5a3268c

Please sign in to comment.