mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 17:52:36 +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
14 lines
755 B
Plaintext
14 lines
755 B
Plaintext
/datum/unit_test/embedding
|
|
|
|
/datum/unit_test/embedding/Run()
|
|
var/mob/living/carbon/human/victim = allocate(/mob/living/carbon/human/consistent)
|
|
var/mob/living/carbon/human/firer = allocate(/mob/living/carbon/human/consistent)
|
|
var/obj/projectile/bullet/c38/bullet = new(get_turf(firer))
|
|
bullet.get_embed().embed_chance = 100
|
|
TEST_ASSERT_EQUAL(bullet.get_embed().embed_chance, 100, "embed_chance failed to modify")
|
|
bullet.aim_projectile(victim, firer)
|
|
bullet.fire(get_angle(firer, victim), victim)
|
|
var/obj/item/shrapnel/shrapnel = locate() in victim
|
|
TEST_ASSERT(!isnull(shrapnel), "Projectile with 100% embed chance didn't embed")
|
|
TEST_ASSERT_EQUAL(shrapnel.get_embed().embed_chance, 100, "embed_chance modification did not transfer to shrapnel")
|