Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/ICmpAIManager.cpp
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | static Status Callback(const VfsPath& pathname, const CFileInfo& UNUSED(fileInfo), const uintptr_t cbData) | ||||
// Extract the 3rd component of the path (i.e. the directory after simulation/ai/) | // Extract the 3rd component of the path (i.e. the directory after simulation/ai/) | ||||
fs::wpath components = pathname.string(); | fs::wpath components = pathname.string(); | ||||
fs::wpath::iterator it = components.begin(); | fs::wpath::iterator it = components.begin(); | ||||
std::advance(it, 2); | std::advance(it, 2); | ||||
std::wstring dirname = GetWstringFromWpath(*it); | std::wstring dirname = GetWstringFromWpath(*it); | ||||
JS::RootedValue ai(cx); | JS::RootedValue ai(cx); | ||||
self->m_ScriptInterface.CreateObject(&ai); | ScriptInterface::CreateObject(cx, &ai); | ||||
JS::RootedValue data(cx); | JS::RootedValue data(cx); | ||||
self->m_ScriptInterface.ReadJSONFile(pathname, &data); | self->m_ScriptInterface.ReadJSONFile(pathname, &data); | ||||
self->m_ScriptInterface.SetProperty(ai, "id", dirname, true); | self->m_ScriptInterface.SetProperty(ai, "id", dirname, true); | ||||
self->m_ScriptInterface.SetProperty(ai, "data", data, true); | self->m_ScriptInterface.SetProperty(ai, "data", data, true); | ||||
u32 length; | u32 length; | ||||
JS_GetArrayLength(cx, self->m_AIs, &length); | JS_GetArrayLength(cx, self->m_AIs, &length); | ||||
JS_SetElement(cx, self->m_AIs, length, ai); | JS_SetElement(cx, self->m_AIs, length, ai); | ||||
Show All 14 Lines |
Wildfire Games · Phabricator