Files
Bubberstation/code/datums/components/evolutionary_leap.dm
AnturK 4d6a8bc537 515 Compatibility (#71161)
Makes the code compatible with 515.1594+

Few simple changes and one very painful one.
Let's start with the easy:
* puts call behind `LIBCALL` define, so call_ext is properly used in 515
* Adds `NAMEOF_STATIC(_,X)` macro for nameof in static definitions since
src is now invalid there.
* Fixes tgui and devserver. From 515 onward the tmp3333{procid} cache
directory is not appened to base path in browser controls so we don't
check for it in base js and put the dev server dummy window file in
actual directory not the byond root.
* Renames the few things that had /final/ in typepath to ultimate since
final is a new keyword

And the very painful change:
`.proc/whatever` format is no longer valid, so we're replacing it with
new nameof() function. All this wrapped in three new macros.
`PROC_REF(X)`,`TYPE_PROC_REF(TYPE,X)`,`GLOBAL_PROC_REF(X)`. Global is
not actually necessary but if we get nameof that does not allow globals
it would be nice validation.
This is pretty unwieldy but there's no real alternative.
If you notice anything weird in the commits let me know because majority
was done with regex replace.

@tgstation/commit-access Since the .proc/stuff is pretty big change.

Co-authored-by: san7890 <the@san7890.com>
Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
2022-11-15 03:50:11 +00:00

59 lines
2.0 KiB
Plaintext

/**
* ### Evolutionary Leap Component; set a time in the round for a mob to evolve into a more dangerous form!
*
* Used for bileworms, to turn into vileworms!
*/
/datum/component/evolutionary_leap
/// how much time until the parent makes an evolutionary leap
var/evolve_mark
/// id for leap timer
var/timer_id
/// what this mob turns into
var/evolve_path
/datum/component/evolutionary_leap/Initialize(evolve_mark, evolve_path)
if(!isliving(parent))
return COMPONENT_INCOMPATIBLE
src.evolve_mark = evolve_mark
src.evolve_path = evolve_path
//don't setup timer yet, timer calc requires the round to have started
if(!SSticker.HasRoundStarted())
RegisterSignal(SSticker, COMSIG_TICKER_ROUND_STARTING, PROC_REF(comp_on_round_start))
return
//if the round has already taken long enough, just leap right away.
if((world.time - SSticker.round_start_time) > evolve_mark)
leap(silent = TRUE)
return
setup_timer()
/datum/component/evolutionary_leap/Destroy(force, silent)
. = ..()
deltimer(timer_id)
/datum/component/evolutionary_leap/UnregisterFromParent()
UnregisterSignal(SSticker, COMSIG_TICKER_ROUND_STARTING)
/// Proc ran when round starts.
/datum/component/evolutionary_leap/proc/comp_on_round_start()
SIGNAL_HANDLER
UnregisterSignal(SSticker, COMSIG_TICKER_ROUND_STARTING)
setup_timer()
/datum/component/evolutionary_leap/proc/setup_timer()
//in cases where this is calculating roundstart, world.time - SSticker.round_start_time should equal 0
var/sum = (world.time - SSticker.round_start_time)
var/mark = evolve_mark - sum
timer_id = addtimer(CALLBACK(src, PROC_REF(leap), FALSE), mark, TIMER_STOPPABLE)
/datum/component/evolutionary_leap/proc/leap(silent)
var/mob/living/old_mob = parent
var/mob/living/new_mob = evolve_path
var/new_mob_name = initial(new_mob.name)
if(!silent)
old_mob.visible_message(span_warning("[old_mob] evolves into \a [new_mob_name]!"))
old_mob.change_mob_type(evolve_path, old_mob.loc, new_name = new_mob_name, delete_old_mob = TRUE)