-- OE ProTune: load the effects-pack particle datablocks (BNGP_9601-9631
-- Flame V5.4 full-opacity event particles/variants/embers and BNGP_9616-9618 Show / Coal smoke).
--
-- WHY THIS FILE EXISTS: the game's own datablock scan (loadDirRec("art/") in client init) runs during
-- BOOT, BEFORE mods are mounted - so datablocks shipped inside a mod are invisible to it and the
-- effects pack never loaded ("Effects pack: Not loaded" even after a full restart, community report
-- 2026-07-02). modScript.lua is the official mod-boot hook: the mod manager executes it right after
-- the mod mounts, when our files ARE visible in the VFS. loadJsonMaterialsFile is the same global the
-- game uses for its own managed particle files (ge/server/server.lua).
--
-- Order matters: ParticleData first, then the emitters that reference it by name.
local okData, errData = pcall(function()
  loadJsonMaterialsFile("art/datablocks/oepParticles00_data.datablocks.json")
end)
local okEmit, errEmit = pcall(function()
  loadJsonMaterialsFile("art/datablocks/oepParticles01_emitters.datablocks.json")
end)
local okLight, errLight = pcall(function()
  extensions.load("oeProTuneEffects")
end)

if not okData then log("E", "oeProTune", "effects pack ParticleData load FAILED: " .. tostring(errData)) end
if not okEmit then log("E", "oeProTune", "effects pack emitters load FAILED: " .. tostring(errEmit)) end
if not okLight then log("W", "oeProTune", "transient exhaust light unavailable: " .. tostring(errLight)) end
if okData and okEmit then
  -- the UI's availability check reads THIS flag (scenetree.findObject can't see datablocks - they
  -- aren't scene objects - which kept the app saying "Not loaded" even after a successful load)
  rawset(_G, "oeProTuneFxLoaded", true)
  rawset(_G, "oeProTuneFxVersion", 9)
  log("I", "oeProTune", "effects pack datablocks loaded (BNGP_9601-9631; Flame V5.4 full-opacity comparison)")
end
