Advertisement
Leon1337

Untitled

Feb 27th, 2021
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.82 KB | None | 0 0
  1.     uint32_t count = module->GetObjectTypeCount();
  2.     for(uint32_t i = 0; i < count; i++)
  3.     {
  4.         // Get the type for the class
  5.         auto type = module->GetObjectTypeByIndex(i);
  6.  
  7.         // Get metadata for the class
  8.         std::vector<std::string> metadata = builder.GetMetadataForType(type->GetTypeId());
  9.         for(auto meta : metadata)
  10.         {
  11.             // The metadata equals IServer so its our main server class
  12.             if(meta != "IServer") continue;
  13.  
  14.             // Create an instance
  15.             auto factory = type->GetFactoryByIndex(0);
  16.             context->Prepare(factory);
  17.             context->Execute();
  18.             asIScriptObject* obj = *(asIScriptObject**)context->GetAddressOfReturnValue();
  19.             obj->AddRef();
  20.             // Store our instance on the resource
  21.             mainScriptClass = obj;
  22.  
  23.             // Get all methods and check their metadata
  24.             for(uint32_t n = 0; n < type->GetMethodCount(); n++)
  25.             {
  26.                 auto method = type->GetMethodByIndex(n, false);
  27.                 // Get metadata for the method
  28.                 std::vector<std::string> methodMetas = builder.GetMetadataForTypeMethod(type->GetTypeId(), method);
  29.                 Log::Info << methodMetas.size() << Log::Endl;
  30.  
  31.                 for(auto methodMeta : methodMetas)
  32.                 {
  33.                     Log::Info << methodMeta << Log::Endl;
  34.                     // Get the event associated with the metadata
  35.                     Event* event = Event::GetByMetadata(methodMeta);
  36.                     if(event == nullptr) continue;
  37.                     // Store the event on the method
  38.                     method->SetUserData(event);
  39.                 }
  40.             }
  41.  
  42.             // We are done so we break out of all the loops and return
  43.             goto done;
  44.         }
  45.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement