Files
Bubberstation/code/modules/admin/create_mob.dm
SkyratBot dc9294dff2 [MIRROR] Avoid wasted work creating body parts that are just going to be destroyed [0.3s of init] [MDB IGNORE] (#18125)
* Avoid wasted work creating body parts that are just going to be destroyed [0.3s of init] (#71916)

Current process:
- Human created
- Body parts created for basic human
- Species set
- Body parts torn down, recreated

New process:
- Human created
- Species set
- Body parts created then and there

I think the same is being done to organs, can be adjusted.

Set species was also being invoked asynchronously, but it's not clear
why, and SHOULD_NOT_SLEEP indicates nothing sleeps, so alas. This isn't
done for init, just for consistency.

Reorders init a little to accomodate the body parts not necessarily
being there, huds now need to safety check.

Saves about 0.3s of init. Closes
https://github.com/tgstation/dev-cycles-initiative/issues/18

* Avoid wasted work creating body parts that are just going to be destroyed [0.3s of init]

* update modular

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
Co-authored-by: Funce <funce.973@gmail.com>
Co-authored-by: Tom <8881105+tf-4@users.noreply.github.com>
2023-01-06 15:29:15 +00:00

47 lines
1.9 KiB
Plaintext

/datum/admins/proc/create_mob(mob/user)
var/static/create_mob_html
if (!create_mob_html)
var/mobjs = null
mobjs = jointext(typesof(/mob), ";")
create_mob_html = file2text('html/create_object.html')
create_mob_html = replacetext(create_mob_html, "Create Object", "Create Mob")
create_mob_html = replacetext(create_mob_html, "null /* object types */", "\"[mobjs]\"")
user << browse(create_panel_helper(create_mob_html), "window=create_mob;size=425x475")
/proc/randomize_human(mob/living/carbon/human/human)
if(human.dna.species.sexes)
human.gender = pick(MALE, FEMALE, PLURAL)
else
human.gender = PLURAL
human.physique = human.gender
human.real_name = human.dna?.species.random_name(human.gender) || random_unique_name(human.gender)
human.name = human.real_name
human.hairstyle = random_hairstyle(human.gender)
human.facial_hairstyle = random_facial_hairstyle(human.gender)
human.hair_color = "#[random_color()]"
human.facial_hair_color = human.hair_color
var/random_eye_color = random_eye_color()
human.eye_color_left = random_eye_color
human.eye_color_right = random_eye_color
//SKYRAT EDIT ADDITION BEGIN - CUSTOMIZATION
human.dna.mutant_bodyparts = human.dna.species.get_random_mutant_bodyparts(human.dna.features)
human.dna.body_markings = human.dna.species.get_random_body_markings(human.dna.features)
human.dna.species.mutant_bodyparts = human.dna.mutant_bodyparts.Copy()
human.dna.species.body_markings = human.dna.body_markings.Copy()
//SKYRAT EDIT ADDITION END
human.dna.blood_type = random_blood_type()
human.dna.features["mcolor"] = "#[random_color()]"
human.dna.species.randomize_active_underwear_only(human)
for(var/datum/species/species_path as anything in subtypesof(/datum/species))
var/datum/species/new_species = new species_path
new_species.randomize_features(human)
human.dna.species.spec_updatehealth(human)
human.dna.update_dna_identity()
human.updateappearance()
human.update_body(is_creating = TRUE)