Datumizes DNA blocks, makes DNA cleaner in general (#92061)

## About The Pull Request

Moves all the dna block handling onto singleton datums initialized
inside global lists, to make the handling dna less of a copy-paste mess
and make adding new blocks significantly easier. There is still some
work to be done in the copypaste department but ultimately that falls
under its own PR scope after the core refactor goes through. (Ill
probably do those but it will also be easier for everyone else as the
code is now significantly less of an eyesore)

Both features and identities have been tested through and through, and
seem to be working fine.

Also removed the reliance on weird hardcoded lookup tables for length,
and other similar things that just didn't make sense when I was passing
through DNA code. There's a lot more that fall out of scope for this
exact PR's goal however

## Why It's Good For The Game

I've been told the maintainers will love me for doing this

## Changelog

🆑
code: feature keys are no longer magical strings floating around the
codebase and use proper defines
refactor: DNA blocks are now handled with singleton datums.
/🆑
This commit is contained in:
Waterpig
2025-07-14 16:51:45 -06:00
committed by GitHub
parent c4ee3d604f
commit b01756b97c
52 changed files with 622 additions and 492 deletions
+13 -12
View File
@@ -10,7 +10,7 @@ Unlike normal organs, we're actually inside a persons limbs at all times
/// The savefile_key of the preference this relates to. Used for the preferences UI.
var/preference
///With what DNA block do we mutate in mutate_feature() ? For genetics
var/dna_block
var/datum/dna_block/dna_block
///Set to EXTERNAL_BEHIND, EXTERNAL_FRONT or EXTERNAL_ADJACENT if you want to draw one of those layers as the object sprite. FALSE to use your own
///This will not work if it doesn't have a limb to generate its icon with
@@ -75,7 +75,8 @@ Unlike normal organs, we're actually inside a persons limbs at all times
var/list/feature_list = bodypart_overlay.get_global_feature_list()
bodypart_overlay.set_appearance_from_name(feature_list[deconstruct_block(get_uni_feature_block(features, dna_block), feature_list.len)])
var/datum/dna_block/feature/feature_block = GLOB.dna_feature_blocks[dna_block]
bodypart_overlay.set_appearance_from_name(feature_list[deconstruct_block(feature_block.get_block(features), feature_list.len)])
///If you need to change an external_organ for simple one-offs, use this. Pass the accessory type : /datum/accessory/something
/obj/item/organ/proc/simple_change_sprite(accessory_type)
@@ -109,7 +110,7 @@ Unlike normal organs, we're actually inside a persons limbs at all times
slot = ORGAN_SLOT_EXTERNAL_HORNS
preference = "feature_lizard_horns"
dna_block = DNA_HORNS_BLOCK
dna_block = /datum/dna_block/feature/horn
restyle_flags = EXTERNAL_RESTYLE_ENAMEL
bodypart_overlay = /datum/bodypart_overlay/mutant/horns
@@ -118,7 +119,7 @@ Unlike normal organs, we're actually inside a persons limbs at all times
/datum/bodypart_overlay/mutant/horns
layers = EXTERNAL_ADJACENT
feature_key = "horns"
feature_key = FEATURE_HORNS
dyable = TRUE
/datum/bodypart_overlay/mutant/horns/can_draw_on_bodypart(obj/item/bodypart/bodypart_owner)
@@ -142,7 +143,7 @@ Unlike normal organs, we're actually inside a persons limbs at all times
slot = ORGAN_SLOT_EXTERNAL_FRILLS
preference = "feature_lizard_frills"
dna_block = DNA_FRILLS_BLOCK
dna_block = /datum/dna_block/feature/frill
restyle_flags = EXTERNAL_RESTYLE_FLESH
bodypart_overlay = /datum/bodypart_overlay/mutant/frills
@@ -151,7 +152,7 @@ Unlike normal organs, we're actually inside a persons limbs at all times
/datum/bodypart_overlay/mutant/frills
layers = EXTERNAL_ADJACENT
feature_key = "frills"
feature_key = FEATURE_FRILLS
/datum/bodypart_overlay/mutant/frills/can_draw_on_bodypart(obj/item/bodypart/bodypart_owner)
var/mob/living/carbon/human/human = bodypart_owner.owner
@@ -176,7 +177,7 @@ Unlike normal organs, we're actually inside a persons limbs at all times
preference = "feature_lizard_snout"
external_bodyshapes = BODYSHAPE_SNOUTED
dna_block = DNA_SNOUT_BLOCK
dna_block = /datum/dna_block/feature/snout
restyle_flags = EXTERNAL_RESTYLE_FLESH
bodypart_overlay = /datum/bodypart_overlay/mutant/snout
@@ -185,7 +186,7 @@ Unlike normal organs, we're actually inside a persons limbs at all times
/datum/bodypart_overlay/mutant/snout
layers = EXTERNAL_ADJACENT
feature_key = "snout"
feature_key = FEATURE_SNOUT
/datum/bodypart_overlay/mutant/snout/can_draw_on_bodypart(obj/item/bodypart/bodypart_owner)
var/mob/living/carbon/human/human = bodypart_owner.owner
@@ -208,7 +209,7 @@ Unlike normal organs, we're actually inside a persons limbs at all times
slot = ORGAN_SLOT_EXTERNAL_ANTENNAE
preference = "feature_moth_antennae"
dna_block = DNA_MOTH_ANTENNAE_BLOCK
dna_block = /datum/dna_block/feature/moth_antenna
restyle_flags = EXTERNAL_RESTYLE_FLESH
bodypart_overlay = /datum/bodypart_overlay/mutant/antennae
@@ -262,7 +263,7 @@ Unlike normal organs, we're actually inside a persons limbs at all times
///Moth antennae datum, with full burning functionality
/datum/bodypart_overlay/mutant/antennae
layers = EXTERNAL_FRONT | EXTERNAL_BEHIND
feature_key = "moth_antennae"
feature_key = FEATURE_MOTH_ANTENNAE
dyable = TRUE
///Accessory datum of the burn sprite
var/datum/sprite_accessory/burn_datum = /datum/sprite_accessory/moth_antennae/burnt_off
@@ -299,7 +300,7 @@ Unlike normal organs, we're actually inside a persons limbs at all times
preference = "feature_pod_hair"
use_mob_sprite_as_obj_sprite = TRUE
dna_block = DNA_POD_HAIR_BLOCK
dna_block = /datum/dna_block/feature/pod_hair
restyle_flags = EXTERNAL_RESTYLE_PLANT
bodypart_overlay = /datum/bodypart_overlay/mutant/pod_hair
@@ -309,7 +310,7 @@ Unlike normal organs, we're actually inside a persons limbs at all times
///Podperson bodypart overlay, with special coloring functionality to render the flowers in the inverse color
/datum/bodypart_overlay/mutant/pod_hair
layers = EXTERNAL_FRONT|EXTERNAL_ADJACENT
feature_key = "pod_hair"
feature_key = FEATURE_POD_HAIR
dyable = TRUE
///This layer will be colored differently than the rest of the organ. So we can get differently colored flowers or something
+2 -2
View File
@@ -9,7 +9,7 @@
preference = "feature_lizard_spines"
dna_block = DNA_SPINES_BLOCK
dna_block = /datum/dna_block/feature/spine
restyle_flags = EXTERNAL_RESTYLE_FLESH
bodypart_overlay = /datum/bodypart_overlay/mutant/spines
@@ -31,7 +31,7 @@
///Bodypart overlay for spines
/datum/bodypart_overlay/mutant/spines
layers = EXTERNAL_ADJACENT|EXTERNAL_BEHIND
feature_key = "spines"
feature_key = FEATURE_SPINES
dyable = TRUE
/datum/bodypart_overlay/mutant/spines/get_global_feature_list()
+8 -8
View File
@@ -7,7 +7,7 @@
zone = BODY_ZONE_PRECISE_GROIN
slot = ORGAN_SLOT_EXTERNAL_TAIL
dna_block = DNA_TAIL_BLOCK
dna_block = /datum/dna_block/feature/tail
restyle_flags = EXTERNAL_RESTYLE_FLESH
// defaults to cat, but the parent type shouldn't be created regardless
@@ -65,7 +65,7 @@
tail_spines_overlay = new
tail_spines_overlay.tail_spine_key = tail_spine_key
var/feature_name = bodypart.owner.dna.features["spines"] //tail spines don't live in DNA, but share feature names with regular spines
var/feature_name = bodypart.owner.dna.features[FEATURE_SPINES] //tail spines don't live in DNA, but share feature names with regular spines
tail_spines_overlay.set_appearance_from_name(feature_name)
bodypart.add_bodypart_overlay(tail_spines_overlay)
@@ -169,7 +169,7 @@
///Cat tail bodypart overlay
/datum/bodypart_overlay/mutant/tail/cat
feature_key = "tail_cat"
feature_key = FEATURE_TAIL
color_source = ORGAN_COLOR_HAIR
/datum/bodypart_overlay/mutant/tail/cat/get_global_feature_list()
@@ -185,7 +185,7 @@
///Monkey tail bodypart overlay
/datum/bodypart_overlay/mutant/tail/monkey
color_source = NONE
feature_key = "tail_monkey"
feature_key = FEATURE_TAIL_MONKEY
/datum/bodypart_overlay/mutant/tail/monkey/get_global_feature_list()
return SSaccessories.tails_list_monkey
@@ -228,7 +228,7 @@
///Alien tail bodypart overlay
/datum/bodypart_overlay/mutant/tail/xeno
color_source = NONE
feature_key = "tail_xeno"
feature_key = FEATURE_TAIL_XENO
imprint_on_next_insertion = FALSE
/// We don't want to bother writing this in DNA, just use this appearance
var/default_appearance = "Xeno"
@@ -254,11 +254,11 @@
bodypart_overlay = /datum/bodypart_overlay/mutant/tail/lizard
wag_flags = WAG_ABLE
dna_block = DNA_LIZARD_TAIL_BLOCK
dna_block = /datum/dna_block/feature/tail_lizard
///Lizard tail bodypart overlay datum
/datum/bodypart_overlay/mutant/tail/lizard
feature_key = "tail_lizard"
feature_key = FEATURE_TAIL_LIZARD
/datum/bodypart_overlay/mutant/tail/lizard/get_global_feature_list()
return SSaccessories.tails_list_lizard
@@ -270,7 +270,7 @@
///Bodypart overlay for tail spines. Handled by the tail - has no actual organ associated.
/datum/bodypart_overlay/mutant/tail_spines
layers = EXTERNAL_ADJACENT|EXTERNAL_BEHIND
feature_key = "tailspines"
feature_key = FEATURE_TAILSPINES
///Spines wag when the tail does
var/wagging = FALSE
/// Key for tail spine states, depends on the shape of the tail. Defined in the tail sprite datum.
+2 -2
View File
@@ -7,7 +7,7 @@
preference = "feature_moth_wings"
dna_block = DNA_MOTH_WINGS_BLOCK
dna_block = /datum/dna_block/feature/moth_wing
bodypart_overlay = /datum/bodypart_overlay/mutant/wings/moth
restyle_flags = EXTERNAL_RESTYLE_FLESH
@@ -101,7 +101,7 @@
///Moth wing bodypart overlay, including burn functionality!
/datum/bodypart_overlay/mutant/wings/moth
feature_key = "moth_wings"
feature_key = FEATURE_MOTH_WINGS
layers = EXTERNAL_BEHIND | EXTERNAL_FRONT
///Accessory datum of the burn sprite
var/datum/sprite_accessory/burn_datum = /datum/sprite_accessory/moth_wings/burnt_off
+1 -1
View File
@@ -22,7 +22,7 @@
///Bodypart overlay of default wings. Does not have any wing functionality
/datum/bodypart_overlay/mutant/wings
layers = ALL_EXTERNAL_OVERLAYS
feature_key = "wings"
feature_key = FEATURE_WINGS
/datum/bodypart_overlay/mutant/wings/can_draw_on_bodypart(obj/item/bodypart/bodypart_owner)
var/mob/living/carbon/human/human = bodypart_owner.owner