mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 17:52:36 +00:00
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>
57 lines
2.3 KiB
Plaintext
57 lines
2.3 KiB
Plaintext
/**
|
|
* A simple component that spawns a mob of the same type and transfers itself to it when parent dies.
|
|
* For more complex behaviors, use the COMSIG_ON_MULTIPLE_LIVES_RESPAWN comsig.
|
|
*/
|
|
/datum/component/multiple_lives
|
|
can_transfer = TRUE
|
|
dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS
|
|
/// The number of respawns the living mob has left.
|
|
var/lives_left
|
|
|
|
/datum/component/multiple_lives/Initialize(lives_left)
|
|
if(!isliving(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
|
|
src.lives_left = lives_left
|
|
|
|
/datum/component/multiple_lives/RegisterWithParent()
|
|
RegisterSignal(parent, COMSIG_LIVING_DEATH, PROC_REF(respawn))
|
|
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, PROC_REF(on_examine))
|
|
RegisterSignal(parent, COMSIG_LIVING_WRITE_MEMORY, PROC_REF(on_write_memory))
|
|
|
|
/datum/component/multiple_lives/UnregisterFromParent()
|
|
UnregisterSignal(parent, list(COMSIG_LIVING_DEATH, COMSIG_PARENT_EXAMINE, COMSIG_LIVING_WRITE_MEMORY))
|
|
|
|
/// Stops a dying station pet from overriding persistence data before we respawn it and thus causing issues.
|
|
/datum/component/multiple_lives/proc/on_write_memory(mob/living/source, dead, gibbed)
|
|
if(dead && !source.suiciding)
|
|
return COMPONENT_DONT_WRITE_MEMORY
|
|
|
|
/datum/component/multiple_lives/proc/respawn(mob/living/source, gibbed)
|
|
SIGNAL_HANDLER
|
|
if(source.suiciding) //Freed from this mortail coil.
|
|
qdel(src)
|
|
return
|
|
//Gives the old mob this trait in case it gets revived, so we won't end up eventually overriding data
|
|
//that would be read by the current holder when he respawns if the old corpse is ever revived.
|
|
ADD_TRAIT(source, TRAIT_DONT_WRITE_MEMORY, EXPIRED_LIFE_TRAIT)
|
|
var/mob/living/respawned_mob = new source.type (source.drop_location())
|
|
source.mind?.transfer_to(respawned_mob)
|
|
lives_left--
|
|
if(lives_left <= 0)
|
|
qdel(src)
|
|
source.TransferComponents(respawned_mob)
|
|
SEND_SIGNAL(source, COMSIG_ON_MULTIPLE_LIVES_RESPAWN, respawned_mob, gibbed, lives_left)
|
|
|
|
/datum/component/multiple_lives/proc/on_examine(mob/living/source, mob/user, list/examine_list)
|
|
SIGNAL_HANDLER
|
|
if(isobserver(user) || source == user)
|
|
examine_list += "[source.p_theyve(TRUE)] [lives_left] extra lives left."
|
|
|
|
/datum/component/multiple_lives/InheritComponent(datum/component/multiple_lives/new_comp , lives_left)
|
|
src.lives_left += new_comp ? new_comp.lives_left : lives_left
|
|
|
|
/datum/component/multiple_lives/PostTransfer()
|
|
if(!isliving(parent))
|
|
return COMPONENT_INCOMPATIBLE
|