mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-11 10:11:09 +00:00
## About The Pull Request I've been meaning to do this for some time. I need this for portable/handheld aquariums/fishtanks to be possible. I'll sprite and code them before I call this PR ready, however suggestions and code reviews are welcome in the meantime. Being a pretty heavy refactor, some things might break (we have more than a few unit tests so perhaps not) while others, coincidentally, might be fixed without me knowing. Anyway I'm sure this PR fixes aquarium beauty, which wasn't really working to begin with because the code was so fucking bad. Nothing really worth of a CL entry tho. TODO: - [x] handheld aquariums, craftable with a kit and little plastic or buyable from the fun vendor ig. - [x] an aquarium upgrade for handheld aquariums to bypass possible restrictions. - [x] update the beauty element to consider items, which shouldn't contribute to the area beauty when held or otherwise not on a turf. ## Why It's Good For The Game This should make handheld aquariums possible. ## Changelog 🆑 refactor: refactored aquariums heavily. Please report any fishy bug. add: Added portable/handheld fish tanks to the game. They can be crafted with an aquarium kit and 5 sheets of plastic. While portable, they cannot store fish that are too big or if there're too many already. This restriction can be removed by using the new "bluespace fish tank kit" techweb item. map: Replaced the lawyer's stationary pet aquarium with a fish tank, so you can carry McGill around. balance: Reduced the iron cost of stationary aquariums a little. /🆑
57 lines
2.4 KiB
Plaintext
57 lines
2.4 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_ATOM_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_ATOM_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 && !HAS_TRAIT(source, TRAIT_SUICIDED))
|
|
return COMPONENT_DONT_WRITE_MEMORY
|
|
|
|
/datum/component/multiple_lives/proc/respawn(mob/living/source, gibbed)
|
|
SIGNAL_HANDLER
|
|
if(HAS_TRAIT(source, TRAIT_SUICIDED)) //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_They()] [source.p_have()] [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(datum/new_parent)
|
|
if(!isliving(new_parent))
|
|
return COMPONENT_INCOMPATIBLE
|