Files
Bubberstation/code/datums/components/glass_passer.dm
GhomandGitHub 54df8cab2d Moved a few monkeys features out of species code (+ updated a couple infusion organs) (#96735)
## About The Pull Request
Title. I'm moving a few monkey features away from the species and into
its bodyparts and organs. I plan on following up with another PR for the
various `ismonkey()` in the code, as these are necessary changes for a
niche thing I'm ultimately working on.

Also one carp organ and one stoat organ both had bits of code made
redundant by available traits. This takes care of them.
Also removed the passwindow_on/off and passtable_on/off procs. We can
just register the associated trait signals on init for living mobs (plus
they were being misused on non-mobs).

## Why It's Good For The Game
Less code associated directly to the species and more to its body parts
and organs, which is basically something we've been doing for a few
years ~~(also I need it for skeletonized monkeys)~~.

## Changelog
N/A
2026-07-11 21:51:39 +01:00

78 lines
2.6 KiB
Plaintext

/// Allows us to move through glass but not electrified glass. Can also do a little slowdown before passing through
/datum/component/glass_passer
/// How long does it take us to move into glass?
var/pass_time = 0 SECONDS
/// How long does the window stay deformed and passable for others?
var/deform_glass = 0 SECONDS
/datum/component/glass_passer/Initialize(pass_time, deform_glass)
if(!ismob(parent)) //if its not a mob then just directly use passwindow
return COMPONENT_INCOMPATIBLE
src.pass_time = pass_time
src.deform_glass = deform_glass
/datum/component/glass_passer/RegisterWithParent()
if(!pass_time)
ADD_TRAIT(parent, TRAIT_PASSWINDOW, type)
else
RegisterSignal(parent, COMSIG_MOVABLE_BUMP, PROC_REF(bumped))
var/mob/mobbers = parent
mobbers.generic_canpass = FALSE
RegisterSignal(parent, COMSIG_MOVABLE_CROSS_OVER, PROC_REF(on_cross_over))
if(deform_glass)
RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved))
/datum/component/glass_passer/UnregisterFromParent()
if(parent)
REMOVE_TRAIT(parent, TRAIT_PASSWINDOW, type)
/datum/component/glass_passer/proc/on_cross_over(mob/passer, atom/crosser)
SIGNAL_HANDLER
if(istype(crosser, /obj/structure/grille))
var/obj/structure/grille/grillefriend = crosser
if(grillefriend.is_shocked()) //prevent passage of shocked
crosser.balloon_alert(passer, "is shocked!")
return COMPONENT_BLOCK_CROSS
return null
/datum/component/glass_passer/proc/on_moved(mob/living/phaser, atom/old_loc, dir, forced, list/old_locs)
SIGNAL_HANDLER
for(var/obj/structure/structure as anything in old_loc)
if(!structure.density || !istype(structure, /obj/structure/window) && !istype(structure, /obj/structure/grille))
continue
blomperize(structure)
/// Make the window temporarily passable
/datum/component/glass_passer/proc/blomperize(obj/structure/structure)
structure.density = FALSE
apply_wibbly_filters(structure)
addtimer(CALLBACK(src, PROC_REF(unblomperize), structure), deform_glass)
/// Reset the windows passability
/datum/component/glass_passer/proc/unblomperize(obj/structure/structure)
structure.density = initial(structure.density)
remove_wibbly_filters(structure, 0.5 SECONDS)
/datum/component/glass_passer/proc/bumped(mob/living/owner, atom/bumpee)
SIGNAL_HANDLER
if(!istype(bumpee, /obj/structure/window))
return
INVOKE_ASYNC(src, PROC_REF(phase_through_glass), owner, bumpee)
/datum/component/glass_passer/proc/phase_through_glass(mob/living/owner, atom/bumpee)
if(!do_after(owner, pass_time, bumpee))
return
ADD_TRAIT(owner, TRAIT_PASSWINDOW, type)
try_move_adjacent(owner, get_dir(owner, bumpee))
REMOVE_TRAIT(owner, TRAIT_PASSWINDOW, type)