fix: pack environment not passed to components

This commit is contained in:
MihailRis 2025-12-01 22:01:18 +03:00
parent c0d326061e
commit 69cf4c1c04
4 changed files with 19 additions and 4 deletions

View file

@ -492,6 +492,7 @@ void ContentLoader::loadScripts(Content& content) {
load_scripts(content, content.items);
for (const auto& [packid, runtime] : content.getPacks()) {
auto env = runtime->getEnvironment();
const auto& pack = runtime->getInfo();
const auto& folder = pack.folder;
@ -500,9 +501,10 @@ void ContentLoader::loadScripts(Content& content) {
// Load entity components
io::path componentsDir = folder / "scripts/components";
foreach_file(componentsDir, [&pack](const io::path& file) {
foreach_file(componentsDir, [&pack, env](const io::path& file) {
auto name = pack.id + ":" + file.stem();
scripting::load_entity_component(
env,
name,
file,
pack.id + ":scripts/components/" + file.name()