MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / getAllObjects

Method getAllObjects

src/openrct2/scripting/bindings/object/ScObjectManager.cpp:229–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227}
228
229JSValue ScObjectManager::getAllObjects(JSContext* ctx, JSValue thisVal, int argc, JSValue* argv)
230{
231 JS_UNPACK_STR(typez, ctx, argv[0]);
232
233 auto& objManager = GetContext()->GetObjectManager();
234 auto type = objectTypeFromString(typez);
235
236 if (type != ObjectType::none)
237 {
238 JSValue result = JS_NewArray(ctx);
239 size_t count = getObjectEntryGroupCount(type);
240 int64_t resultIndex = 0;
241 for (size_t i = 0; i < count; i++)
242 {
243 auto obj = objManager.GetLoadedObject(type, i);
244 if (obj != nullptr)
245 {
246 JSValue scObj = CreateScObject(ctx, type, static_cast<int32_t>(i));
247 JS_SetPropertyInt64(ctx, result, resultIndex++, scObj);
248 }
249 }
250 return result;
251 }
252 return JS_ThrowPlainError(ctx, "Invalid object type.");
253}
254
255void ScObjectManager::MarkAsResearched(const Object* object)
256{

Callers

nothing calls this directly

Calls 4

GetContextFunction · 0.85
objectTypeFromStringFunction · 0.85
getObjectEntryGroupCountFunction · 0.85
GetLoadedObjectMethod · 0.45

Tested by

no test coverage detected