mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-28 10:01:58 +00:00
## About The Pull Request This PR completely rewrites our embedding system in favor of embedding datum handlers which acts as containers for all embedding-related data and logic. Currently embedding logic relies on an element-component-datum triad, where elements on the items handle embedding logic, singleton datums store embedding data and components (which get assigned to ***mobs*** in whom the item embedded) handle pain and the item being ripped out. How do we access all the procs? By using comsigs as procs, which is really bad. This code was written back in 2020 when DCS was hot stuff but in hindsight this implementation was a mistake, as it heavily restricts custom embedding behaviors unless you're willing to constantly run GetComponent (bad, ugly, incarnation of evil) This PR rewrites all that logic to be handled by lazyloaded ``/datum/embedding``, which is stored similarly to current ``/datum/embed_data``. Upon being requested, it is initialized and assigned to a parent from whom all the logic is handled, from being embedded to pain and having the item ripped out. On projectiles this only handles one proc, after which it copies itself down to the shrapnel item instead and runs the chain further from there. Ideally, most embedding-related logic now should be handled purely datum-side - in most cases items should not be hooking up to themselves like they did before (unless said logic is for when the item is made sticky or smth) and instead the code should be handled by the embedding datum (see sholean grapes implementation in this PR). This should allow us to do fancy stuff like syringe guns embedding syringes into targets and injecting them that way, and fix some bugs along the way. Closes #88115 Closes #87946 Also fixed a bug with scars not displaying when examined closely from #86506 because i was in the area anyways
100 lines
3.4 KiB
Plaintext
100 lines
3.4 KiB
Plaintext
/datum/round_event_control/wizard/embedpocalypse
|
|
name = "Make Everything Embeddable"
|
|
weight = 2
|
|
typepath = /datum/round_event/wizard/embedpocalypse
|
|
max_occurrences = 1
|
|
earliest_start = 0 MINUTES
|
|
description = "Everything becomes pointy enough to embed in people when thrown."
|
|
min_wizard_trigger_potency = 3
|
|
max_wizard_trigger_potency = 7
|
|
|
|
///behold... the only reason sticky is a subtype...
|
|
/datum/round_event_control/wizard/embedpocalypse/can_spawn_event(players_amt, allow_magic = FALSE)
|
|
. = ..()
|
|
if(!.)
|
|
return .
|
|
|
|
if(GLOB.global_funny_embedding)
|
|
return FALSE
|
|
return TRUE
|
|
|
|
/datum/round_event/wizard/embedpocalypse/start()
|
|
GLOB.global_funny_embedding = new /datum/global_funny_embedding/pointy
|
|
|
|
/datum/round_event_control/wizard/embedpocalypse/sticky
|
|
name = "Make Everything Sticky"
|
|
weight = 6
|
|
typepath = /datum/round_event/wizard/embedpocalypse/sticky
|
|
max_occurrences = 1
|
|
earliest_start = 0 MINUTES
|
|
description = "Everything becomes sticky enough to be glued to people when thrown."
|
|
|
|
/datum/round_event/wizard/embedpocalypse/sticky/start()
|
|
GLOB.global_funny_embedding = new /datum/global_funny_embedding/sticky
|
|
|
|
///set this to a new instance of a SUBTYPE of global_funny_embedding. The main type is a prototype and will runtime really hard
|
|
GLOBAL_DATUM(global_funny_embedding, /datum/global_funny_embedding)
|
|
|
|
/**
|
|
* ## global_funny_embedding!
|
|
*
|
|
* Stored in a global datum, and created when it is turned on via event or VV'ing the GLOB.embedpocalypse_controller to be a new /datum/global_funny_embedding.
|
|
* Gives every item in the world a prefix to their name, and...
|
|
* Makes every item in the world embed when thrown, but also hooks into global signals for new items created to also bless them with embed-ability(??).
|
|
*/
|
|
/datum/global_funny_embedding
|
|
var/embed_type = /datum/embedding/global_funny
|
|
var/prefix = "error"
|
|
|
|
/datum/embedding/global_funny
|
|
ignore_throwspeed_threshold = TRUE
|
|
|
|
/datum/global_funny_embedding/New()
|
|
. = ..()
|
|
//second operation takes MUCH longer, so lets set up signals first.
|
|
RegisterSignal(SSdcs, COMSIG_GLOB_NEW_ITEM, PROC_REF(on_new_item_in_existence))
|
|
handle_current_items()
|
|
|
|
/datum/global_funny_embedding/Destroy(force)
|
|
. = ..()
|
|
UnregisterSignal(SSdcs, COMSIG_GLOB_NEW_ITEM)
|
|
|
|
///signal sent by a new item being created.
|
|
/datum/global_funny_embedding/proc/on_new_item_in_existence(datum/source, obj/item/created_item)
|
|
SIGNAL_HANDLER
|
|
|
|
// this proc says it's for initializing components, but we're initializing elements too because it's you and me against the world >:)
|
|
if(created_item.get_embed())
|
|
return //already embeds to some degree, so whatever // No rat allowed
|
|
|
|
created_item.name = "[prefix] [created_item.name]"
|
|
created_item.set_embed(embed_type)
|
|
|
|
/**
|
|
* ### handle_current_items
|
|
*
|
|
* Gives every viable item in the world the embed_type, and the prefix prefixed to the name.
|
|
*/
|
|
/datum/global_funny_embedding/proc/handle_current_items()
|
|
for(var/obj/item/embed_item in world)
|
|
CHECK_TICK
|
|
if(!(embed_item.flags_1 & INITIALIZED_1))
|
|
continue
|
|
if(embed_item.get_embed())
|
|
continue
|
|
embed_item.set_embed(embed_type)
|
|
embed_item.name = "[prefix] [embed_item.name]"
|
|
|
|
///everything will be... POINTY!!!!
|
|
/datum/global_funny_embedding/pointy
|
|
prefix = "pointy"
|
|
|
|
///everything will be... sticky? sure, why not
|
|
/datum/global_funny_embedding/sticky
|
|
embed_type = /datum/embedding/global_funny/sticky
|
|
prefix = "sticky"
|
|
|
|
/datum/embedding/global_funny/sticky
|
|
pain_mult = 0
|
|
jostle_pain_mult = 0
|