Files
Bubberstation/code/modules/client/preferences/middleware/species.dm
SkyratBot 4a2a4829b8 [MIRROR] Make spritesheets cacheable by default, killing a lot of overtime in the round start spike [MDB IGNORE] (#25820)
* Make spritesheets cacheable by default, killing a lot of overtime in the round start spike (#80522)

## About The Pull Request
Makes all spritesheets cache by default. This wasn't the case originally
because some spritesheets like vending machines relied on in world
state, but none of them do anymore because that's whack.

Also fixes a bug that would cause half completed caches to break other
stuff. This didn't happen in real gameplay, but would've happened if you
tried to change cachable on anything while you already had a tmp folder.

## Changelog
🆑
fix: Cut down a significant amount of time that caused the start of
rounds to lag.
/🆑

* Make spritesheets cacheable by default, killing a lot of overtime in the round start spike

---------

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
2023-12-24 19:25:58 +00:00

34 lines
1.1 KiB
Plaintext

/// Handles the assets for species icons
/datum/preference_middleware/species
/datum/preference_middleware/species/get_ui_assets()
return list(
get_asset_datum(/datum/asset/spritesheet/species),
)
/datum/asset/spritesheet/species
name = "species"
early = TRUE
/datum/asset/spritesheet/species/create_spritesheets()
var/list/to_insert = list()
for (var/species_id in get_selectable_species() | get_customizable_races()) // SKYRAT EDIT CHANGE - ORIGINAL: for (var/species_id in get_selectable_species())
var/datum/species/species_type = GLOB.species_list[species_id]
var/mob/living/carbon/human/dummy/consistent/dummy = new
dummy.set_species(species_type)
dummy.equipOutfit(/datum/outfit/job/assistant/consistent, visualsOnly = TRUE)
dummy.dna.species.prepare_human_for_preview(dummy)
var/icon/dummy_icon = getFlatIcon(dummy)
dummy_icon.Scale(64, 64)
dummy_icon.Crop(15, 64, 15 + 31, 64 - 31)
dummy_icon.Scale(64, 64)
to_insert[sanitize_css_class_name(initial(species_type.name))] = dummy_icon
SSatoms.prepare_deletion(dummy)
for (var/spritesheet_key in to_insert)
Insert(spritesheet_key, to_insert[spritesheet_key])