[MIRROR] Refactors embedding to use datums instead of storing data in bespoke elements (#28699)

* Refactors embedding to use datums instead of storing data in bespoke elements (#84599)

## About The Pull Request

This refactors embedding elements to make them use singleton datums
(similarly to armor) instead being bespoke and creating a new element
every time armor values are supposed to be adjusted.
Default values have been removed from defines due to now being declared
in base class itself.
Additionally fixes vending machines and tackling gloves setting
generated shards (which they instantly embed into their victim) embed
properties to null after running the embedding code, despite said shards
having non-null embedding values by default, making them not be able to
embed into anyone else, also potentially breaking the pain/jostling code
if they somehow get updated.

## Why It's Good For The Game

Current embedding system is an unnecessarily complicated mess as bespoke
elements are hard to work with, and creating a new element every time
you change values is hacky at best. This change should make it easier to
read and work with.

## Changelog
🆑
fix: Fixed glass shards generated from falling vending machines or
tackling windows not being able to embed into anyone.
refactor: Refactored embedding code to use datums instead of bespoke
elements and ugly associated lists.
/🆑

* Refactors embedding to use datums instead of storing data in bespoke elements

* modular fixes

* fix c14

* paint -> pain ugggh

---------

Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com>
Co-authored-by: SpaceLoveSs13 <68121607+SpaceLoveSs13@users.noreply.github.com>
This commit is contained in:
SkyratBot
2024-07-08 11:20:05 +02:00
committed by GitHub
parent 6da3dcaa04
commit f4e244fb49
71 changed files with 701 additions and 450 deletions
+17 -11
View File
@@ -43,9 +43,12 @@ GLOBAL_DATUM(global_funny_embedding, /datum/global_funny_embedding)
* 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 = EMBED_POINTY
var/embed_type = /datum/embed_data/global_funny
var/prefix = "error"
/datum/embed_data/global_funny
ignore_throwspeed_threshold = TRUE
/datum/global_funny_embedding/New()
. = ..()
//second operation takes MUCH longer, so lets set up signals first.
@@ -61,11 +64,11 @@ GLOBAL_DATUM(global_funny_embedding, /datum/global_funny_embedding)
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(LAZYLEN(created_item.embedding))
return //already embeds to some degree, so whatever 🐀
created_item.embedding = embed_type
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.updateEmbedding()
created_item.set_embed(embed_type)
/**
* ### handle_current_items
@@ -77,17 +80,20 @@ GLOBAL_DATUM(global_funny_embedding, /datum/global_funny_embedding)
CHECK_TICK
if(!(embed_item.flags_1 & INITIALIZED_1))
continue
if(!embed_item.embedding)
embed_item.embedding = embed_type
embed_item.updateEmbedding()
embed_item.name = "[prefix] [embed_item.name]"
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
embed_type = EMBED_POINTY
prefix = "pointy"
///everything will be... sticky? sure, why not
/datum/global_funny_embedding/sticky
embed_type = EMBED_HARMLESS
embed_type = /datum/embed_data/global_funny/sticky
prefix = "sticky"
/datum/embed_data/global_funny/sticky
pain_mult = 0
jostle_pain_mult = 0