Lightly refactors human Initialize() (#15738)

* Refactors human Initialize

* spelling

* use ComponentInitialize()

* 🇬🇧
This commit is contained in:
dearmochi
2021-07-15 23:07:24 +02:00
committed by GitHub
parent b67bab70c6
commit f8d510e7f5
3 changed files with 40 additions and 27 deletions
+4
View File
@@ -404,6 +404,10 @@
/mob/living/carbon/proc/tintcheck()
return 0
/mob/living/carbon/proc/create_dna()
if(!dna)
dna = new()
/mob/living/carbon/proc/getDNA()
return dna
+35 -26
View File
@@ -14,38 +14,47 @@
. = ..()
/mob/living/carbon/human/Initialize(mapload, datum/species/new_species = /datum/species/human)
if(!dna)
dna = new /datum/dna(null)
// Species name is handled by set_species()
create_dna()
. = ..()
set_species(new_species, 1, delay_icon_update = 1, skip_same_check = TRUE)
if(dna.species)
real_name = dna.species.get_random_name(gender)
name = real_name
if(mind)
mind.name = real_name
create_reagents(330)
handcrafting = new()
// Set up DNA.
if(dna)
dna.ready_dna(src)
dna.real_name = real_name
sync_organ_dna(1)
physiology = new()
AddComponent(/datum/component/footstep, FOOTSTEP_MOB_HUMAN, 1, -6)
setup_dna(new_species)
setup_other()
UpdateAppearance()
GLOB.human_list += src
/**
* Sets up DNA and species.
*
* Arguments:
* * new_species - The new species to assign.
*/
/mob/living/carbon/human/proc/setup_dna(datum/species/new_species)
set_species(new_species, use_default_color = TRUE, delay_icon_update = TRUE, skip_same_check = TRUE)
// Name
real_name = dna.species.get_random_name(gender)
name = real_name
if(mind)
mind.name = real_name
// DNA ready
dna.ready_dna(src)
dna.real_name = real_name
sync_organ_dna()
/**
* Sets up other variables and components that may be needed for gameplay.
*/
/mob/living/carbon/human/proc/setup_other()
create_reagents(330)
physiology = new()
/mob/living/carbon/human/ComponentInitialize()
AddComponent(/datum/component/footstep, FOOTSTEP_MOB_HUMAN, 1, -6)
/mob/living/carbon/human/OpenCraftingMenu()
if(!handcrafting)
handcrafting = new()
handcrafting.ui_interact(src)
/mob/living/carbon/human/prepare_data_huds()
@@ -1211,7 +1220,7 @@
sec_hud_set_ID()
/mob/living/carbon/human/proc/set_species(datum/species/new_species, default_colour, delay_icon_update = FALSE, skip_same_check = FALSE, retain_damage = FALSE, transformation = FALSE)
/mob/living/carbon/human/proc/set_species(datum/species/new_species, use_default_color = FALSE, delay_icon_update = FALSE, skip_same_check = FALSE, retain_damage = FALSE, transformation = FALSE)
if(!skip_same_check)
if(dna.species.name == initial(new_species.name))
return
@@ -1246,7 +1255,7 @@
hunger_drain = dna.species.hunger_drain
digestion_ratio = dna.species.digestion_ratio
if(dna.species.base_color && default_colour)
if(dna.species.base_color && use_default_color)
//Apply colour.
skin_colour = dna.species.base_color
else