Files
Bubberstation/code/datums/elements/bombable_turf.dm
SkyratBot 7845a0cde6 [MIRROR] Replace wall/indestructible/destructible typepath with mapping helper [MDB IGNORE] (#23735)
* Replace wall/indestructible/destructible typepath with mapping helper (#78365)

## About The Pull Request

#78239 is a fun mapping add but engineered in a way that
1. Creates a real eyesore of a typepath
2. Would further proliferate a hundred subtypes if it became commonly
used

Instead of using subtypes for this I put the behaviour in a component
and made a mapping helper to apply the component.
Now you can just put the mapping helper on top of any turf you want to
make into a zelda bomb wall and it will be so, rather than having to
make different subtypes for walls with different icons.

## Why It's Good For The Game

Cleaner, more maintainable.

## Changelog

not player facing

---------

Co-authored-by: san7890 <the@ san7890.com>

* Replace wall/indestructible/destructible typepath with mapping helper

---------

Co-authored-by: Jacquerel <hnevard@gmail.com>
Co-authored-by: san7890 <the@ san7890.com>
2023-09-17 14:41:05 -04:00

46 lines
1.8 KiB
Plaintext

/**
* Apply this to a turf (usually a wall) and it will be destroyed instantly by any explosion.
* Most walls can already be destroyed by explosions so this is largely for usually indestructible ones.
* For applying it in a map editor, use /obj/effect/mapping_helpers/bombable_wall
*/
/datum/element/bombable_turf
/datum/element/bombable_turf/Attach(turf/target)
. = ..()
if(!isturf(target))
return ELEMENT_INCOMPATIBLE
target.explosive_resistance = 1
RegisterSignal(target, COMSIG_ATOM_EX_ACT, PROC_REF(detonate))
RegisterSignal(target, COMSIG_TURF_CHANGE, PROC_REF(turf_changed))
RegisterSignal(target, COMSIG_ATOM_UPDATE_OVERLAYS, PROC_REF(on_update_overlays))
RegisterSignal(target, COMSIG_ATOM_EXAMINE, PROC_REF(on_examined))
target.update_appearance(UPDATE_OVERLAYS)
/datum/element/bombable_turf/Detach(turf/source)
UnregisterSignal(source, list(COMSIG_ATOM_EX_ACT, COMSIG_TURF_CHANGE, COMSIG_ATOM_UPDATE_OVERLAYS, COMSIG_ATOM_EXAMINE))
source.explosive_resistance = initial(source.explosive_resistance)
source.update_appearance(UPDATE_OVERLAYS)
return ..()
/// If we get blowed up, move to the next turf
/datum/element/bombable_turf/proc/detonate(turf/source)
SIGNAL_HANDLER
source.ScrapeAway()
/// If this turf becomes something else we either just went off or regardless don't want this any more
/datum/element/bombable_turf/proc/turf_changed(turf/source)
SIGNAL_HANDLER
Detach(source)
/// Show a little crack on here
/datum/element/bombable_turf/proc/on_update_overlays(turf/source, list/overlays)
SIGNAL_HANDLER
overlays += mutable_appearance('icons/turf/overlays.dmi', "explodable", source.layer + 0.1)
/// Show a little extra on examine
/datum/element/bombable_turf/proc/on_examined(turf/source, mob/user, list/examine_list)
SIGNAL_HANDLER
examine_list += span_notice("It seems to be slightly cracked...")