mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-11 18:22:14 +00:00
Productionizes #80615. The core optimization is this: ```patch - var/hint = to_delete.Destroy(arglist(args.Copy(2))) // Let our friend know they're about to get fucked up. + var/hint = to_delete.Destroy(force) // Let our friend know they're about to get fucked up. ``` We avoid a heap allocation in the form of copying the args over to a new list. A/B testing shows this results in 33% better overtime, and in a real round shaving off a full second of self time and 0.4 seconds of overtime--both of these would be doubled in the event this is merged as the new proc was only being run 50% of the time.
38 lines
804 B
Plaintext
38 lines
804 B
Plaintext
/// Makes a mob friendly with most NPC factions
|
|
/datum/component/npc_friendly
|
|
/// The list of factions to add to the player
|
|
var/list/npc_factions = list(
|
|
FACTION_BOSS,
|
|
FACTION_CARP,
|
|
FACTION_HIVEBOT,
|
|
FACTION_HOSTILE,
|
|
FACTION_MIMIC,
|
|
FACTION_PIRATE,
|
|
FACTION_SPIDER,
|
|
FACTION_STICKMAN,
|
|
ROLE_ALIEN,
|
|
ROLE_GLITCH,
|
|
ROLE_SYNDICATE,
|
|
)
|
|
/// List of factions previously held by the player
|
|
var/list/previous_factions = list()
|
|
|
|
/datum/component/npc_friendly/Initialize()
|
|
. = ..()
|
|
|
|
if(!isliving(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
|
|
var/mob/living/player = parent
|
|
|
|
previous_factions.Add(player.faction)
|
|
player.faction |= npc_factions
|
|
|
|
/datum/component/npc_friendly/Destroy(force)
|
|
. = ..()
|
|
|
|
var/mob/living/player = parent
|
|
|
|
player.faction.Cut()
|
|
player.faction.Add(previous_factions)
|