local ____lualib = require("lualib_bundle") local __TS__TypeOf = ____lualib.__TS__TypeOf local __TS__StringEndsWith = ____lualib.__TS__StringEndsWith local __TS__ArraySort = ____lualib.__TS__ArraySort local ____exports = {} --- Модели, которых нет в npc_units_custom / #base, но нужны коду (дроп, эффекты). local EXTRA_PRECACHE_MODELS = { "models/props_gameplay/roshans_banner.vmdl", "models/development/invisiblebox.vmdl", "models/props_gameplay/lantern/lantern_of_sight.vmdl", "models/heroes/undying/undying_tower.vmdl", "models/items/lifestealer/promo_bloody_ripper_belt/promo_bloody_ripper_belt.vmdl", "models/items/warlock/golem/puppet_summoner_golem/puppet_summoner_golem.vmdl", "models/items/lifestealer/promo_bloody_ripper_head/promo_bloody_ripper_head.vmdl", "models/items/lifestealer/promo_bloody_ripper_back/promo_bloody_ripper_back.vmdl", "models/items/lifestealer/promo_bloody_ripper_arms/promo_bloody_ripper_arms.vmdl", "models/items/kunkka/spiritoftide_gloves/spiritoftide_gloves.vmdl", "models/items/kunkka/kunkka_bandana.vmdl", "models/items/kunkka/claddish_shoulder/claddish_shoulder.vmdl", "models/items/kunkka/arm_lev_pipe/arm_lev_pipe.vmdl", "models/heroes/kunkka/kunkka_shoulders.vmdl", "models/items/kunkka/kunkka_shadow_blade/kunkka_shadow_blade.vmdl", "models/heroes/dragon_knight_persona/dk_persona_armor.vmdl", "models/heroes/dragon_knight_persona/dk_persona_head_hair.vmdl", "models/items/omniknight/stalwart_back/stalwart_back.vmdl", "models/heroes/omniknight/head.vmdl", "models/items/omniknight/grey_night_head/grey_night_head.vmdl", "models/items/lina/magnificentflame_head/magnificentflame_head.vmdl", "models/items/lina/pw_fire_lotus/lina_belt.vmdl", "models/items/lina/everlastingheat_arms/everlastingheat_arms.vmdl", "models/items/lina/ember_crane_neck/ember_crane_neck.vmdl", "models/items/crystal_maiden/esl_frozen_lotus_head/esl_frozen_lotus_head.vmdl", "models/items/crystal_maiden/esl_frozen_lotus_shoulder/esl_frozen_lotus_shoulder.vmdl", "models/items/crystal_maiden/esl_frozen_lotus_arms/esl_frozen_lotus_arms.vmdl", "models/items/crystal_maiden/esl_frozen_lotus_back/esl_frozen_lotus_back.vmdl", "models/heroes/bard/bard_frog_upperbody.vmdl", "models/heroes/bard/bard_frog_lowerbody.vmdl", "models/heroes/bard/bard_frog_weapon.vmdl", "models/items/witchdoctor/bonkers_the_mad/bonkers_the_mad.vmdl", "models/items/witchdoctor/teller_of_the_auspice_belt/teller_of_the_auspice_belt.vmdl", "models/items/witchdoctor/teller_of_the_auspice_head/teller_of_the_auspice_head.vmdl", "models/items/witchdoctor/teller_of_the_auspice_weapon/teller_of_the_auspice_weapon.vmdl", "models/items/grimstroke/grimreaver_hood/grimreaver_hood.vmdl", "models/items/grimstroke/the_chained_scribe_head/the_chained_scribe_head.vmdl", "models/items/grimstroke/the_chained_scribe_belt/the_chained_scribe_belt.vmdl", "models/items/grimstroke/the_chained_scribe_armor/the_chained_scribe_armor.vmdl", "models/items/grimstroke/grimreaver_scythe/grimreaver_scythe.vmdl", "models/items/death_prophet/woman_of_the_snow_belt/woman_of_the_snow_belt.vmdl", "models/items/death_prophet/woman_of_the_snow_legs/woman_of_the_snow_legs.vmdl", "models/items/death_prophet/woman_of_the_snow_misc/woman_of_the_snow_misc.vmdl", "models/items/death_prophet/woman_of_the_snow_head/woman_of_the_snow_head.vmdl", "models/items/death_prophet/woman_of_the_snow_armor/woman_of_the_snow_armor.vmdl" } local function collectVmdlStringsFromKv(self, value, bucket) if value == nil or value == nil then return end local t = __TS__TypeOf(value) if t == "string" then local s = value if __TS__StringEndsWith(s, ".vmdl") then bucket[s] = true end return end if t == "object" then local o = value for key in pairs(o) do collectVmdlStringsFromKv(nil, o[key], bucket) end end end --- KV, из которых LoadKeyValues подмешивает #base и собирает дерево как у движка. local NPC_KV_MODEL_SOURCES = {"scripts/npc/npc_units_custom.txt", "scripts/npc/npc_items_custom.txt"} local LOG_PFX = "[precache_models_from_kv]" local function sortedModelPaths(self, bucket) local out = {} for p in pairs(bucket) do out[#out + 1] = p end __TS__ArraySort(out) return out end local function printModelList(self, title, paths) print(((((LOG_PFX .. " --- ") .. title) .. " (") .. tostring(#paths)) .. ") ---") for ____, p in ipairs(paths) do print((LOG_PFX .. " model: ") .. p) end end --- Прекеширует все .vmdl из npc_units_custom и npc_items_custom (с их #base). function ____exports.precacheModelsFromNpcUnitsCustomKv(self, context) local bucket = {} --- Модели только из этого корневого KV (для лога; дубликаты между файлами возможны). local perSource = {} for ____, path in ipairs(NPC_KV_MODEL_SOURCES) do local kv = LoadKeyValues(path) if kv == nil then print((LOG_PFX .. " Не удалось загрузить ") .. path) else local ____local = {} collectVmdlStringsFromKv(nil, kv, ____local) perSource[path] = ____local for m in pairs(____local) do bucket[m] = true end end end local extraBucket = {} for ____, path in ipairs(EXTRA_PRECACHE_MODELS) do bucket[path] = true extraBucket[path] = true end print(LOG_PFX .. " Список моделей к прекешу:") for ____, path in ipairs(NPC_KV_MODEL_SOURCES) do local ____local = perSource[path] if ____local ~= nil then printModelList( nil, path, sortedModelPaths(nil, ____local) ) end end printModelList( nil, "EXTRA_PRECACHE_MODELS (не из KV)", sortedModelPaths(nil, extraBucket) ) local allPaths = sortedModelPaths(nil, bucket) for ____, modelPath in ipairs(allPaths) do PrecacheResource("model", modelPath, context) end print((LOG_PFX .. " Итого запрошено PrecacheResource(model): ") .. tostring(#allPaths)) end return ____exports