mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-11 10:11:09 +00:00
## About The Pull Request This takes all the gib related procs: - `gib()` - `spawn_gibs()` - `spill_organs()` - `spread_bodyparts()` And adds heavy documentation that communicates what the procs are used for and how the different bitflags affect them. The difference is noticeable: `gib(TRUE, FALSE, FALSE, null)` vs `gib(DROP_ORGANS|DROP_BODYPARTS)` The code is now much more legible which is important considering it's used in a lot of places! Another robust change, is that we had several places in the code where there were double negatives like so: ``` /mob/living/carbon/spill_organs(no_brain, no_organs, no_bodyparts) if(!no_bodyparts) // DOUBLE NEGATIVES ARE BAD M'KAY?!? // do stuff here ``` This is a mindfuck to untangle. I inverted a lot of these parts so we don't lose our sanity. Last thing that was changed was a big `if()` loop in the `spill_organ()` proc. This was refactored to just be a simple `for` loop with `continue` statements where we needed to skip enabled bitflags. It's now shorter and cleaner than before. The only slight gameplay change this affects is that gibbing a mob now guarantees to drop all items unless the `DROP_ITEMS` bitflag is deliberately omitted. Some places like admin gib self, we don't want this to happen. ## Why It's Good For The Game Gib code is very old. (~15 years) People kept adding more arguments to the procs when it should have been a bitflag initially. By doing it this way, there is more flexibility and readability when it comes to adding new code in the future. ## Changelog 🆑 refactor: Refactor gib code to be more robust. qol: Gibbing a mob will result in all items being dropped instead of getting deleted. There are a few exceptions (like admin gib self) where this will not take place. /🆑
31 lines
947 B
Plaintext
31 lines
947 B
Plaintext
/**
|
|
* ## Death link component
|
|
*
|
|
* When the owner of this component dies it also gibs a linked mob
|
|
*/
|
|
/datum/component/death_linked
|
|
///The mob that also dies when the user dies
|
|
var/datum/weakref/linked_mob
|
|
|
|
/datum/component/death_linked/Initialize(mob/living/target_mob)
|
|
. = ..()
|
|
if(!isliving(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
if(isnull(target_mob))
|
|
stack_trace("[type] added to [parent] with no linked mob.")
|
|
src.linked_mob = WEAKREF(target_mob)
|
|
|
|
/datum/component/death_linked/RegisterWithParent()
|
|
. = ..()
|
|
RegisterSignal(parent, COMSIG_LIVING_DEATH, PROC_REF(on_death))
|
|
|
|
/datum/component/death_linked/UnregisterFromParent()
|
|
. = ..()
|
|
UnregisterSignal(parent, COMSIG_LIVING_DEATH)
|
|
|
|
///signal called by the stat of the target changing
|
|
/datum/component/death_linked/proc/on_death(mob/living/target, gibbed)
|
|
SIGNAL_HANDLER
|
|
var/mob/living/linked_mob_resolved = linked_mob?.resolve()
|
|
linked_mob_resolved?.gib(DROP_ALL_REMAINS)
|