Files
Bubberstation/code/datums/components/space_camo.dm
SkyratBot 16854f2358 [MIRROR] The Voidwalker | New Midround Antagonist (#28832)
* The Voidwalker | New Midround Antagonist

* [MIRROR] The Voidwalker | New Midround Antagonist [MDB IGNORE] (#3755)

* The Voidwalker | New Midround Antagonist

* Update role_preferences.dm

* Update sql_ban_system.dm

* Update _bodyparts.dm

* Update role_preferences.dm

* Update lazy_templates.dm

* Update _bodyparts.dm

* Update _bodyparts.dm

* Grep

---------

Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com>
Co-authored-by: SomeRandomOwl <2568378+SomeRandomOwl@users.noreply.github.com>
Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com>

---------

Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com>
Co-authored-by: SpaceLoveSs13 <68121607+SpaceLoveSs13@users.noreply.github.com>
Co-authored-by: NovaBot <154629622+NovaBot13@users.noreply.github.com>
Co-authored-by: SomeRandomOwl <2568378+SomeRandomOwl@users.noreply.github.com>
Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com>
2024-07-20 17:44:24 +05:30

55 lines
1.9 KiB
Plaintext

/// Camouflage us when we enter space by increasing alpha and or changing color
/datum/component/space_camo
/// Alpha we have in space
var/space_alpha
/// Alpha we have elsewhere
var/non_space_alpha
/// How long we can't enter camo after hitting or being hit
var/reveal_after_combat
/// The world time after we can camo again
VAR_PRIVATE/next_camo
/datum/component/space_camo/Initialize(space_alpha, non_space_alpha, reveal_after_combat)
if(!ismovable(parent))
return COMPONENT_INCOMPATIBLE
src.space_alpha = space_alpha
src.non_space_alpha = non_space_alpha
src.reveal_after_combat = reveal_after_combat
RegisterSignal(parent, COMSIG_ATOM_ENTERING, PROC_REF(on_atom_entering))
if(isliving(parent))
RegisterSignals(parent, list(COMSIG_ATOM_WAS_ATTACKED, COMSIG_MOB_ITEM_ATTACK, COMSIG_LIVING_UNARMED_ATTACK, COMSIG_ATOM_BULLET_ACT, COMSIG_ATOM_REVEAL), PROC_REF(force_exit_camo))
/datum/component/space_camo/proc/on_atom_entering(atom/movable/entering, atom/entered)
SIGNAL_HANDLER
if(!attempt_enter_camo())
exit_camo(parent)
/datum/component/space_camo/proc/attempt_enter_camo()
if(!isspaceturf(get_turf(parent)) || next_camo > world.time)
return FALSE
enter_camo(parent)
return TRUE
/datum/component/space_camo/proc/force_exit_camo()
SIGNAL_HANDLER
exit_camo(parent)
next_camo = world.time + reveal_after_combat
addtimer(CALLBACK(src, PROC_REF(attempt_enter_camo)), reveal_after_combat, TIMER_OVERRIDE | TIMER_UNIQUE)
/datum/component/space_camo/proc/enter_camo(atom/movable/parent)
if(parent.alpha != space_alpha)
animate(parent, alpha = space_alpha, time = 0.5 SECONDS)
parent.remove_from_all_data_huds()
parent.add_atom_colour(SSparallax.get_parallax_color(), TEMPORARY_COLOUR_PRIORITY)
/datum/component/space_camo/proc/exit_camo(atom/movable/parent)
animate(parent, alpha = non_space_alpha, time = 0.5 SECONDS)
parent.add_to_all_human_data_huds()
parent.remove_atom_colour(TEMPORARY_COLOUR_PRIORITY)