MCPcopy Create free account
hub / github.com/defold/defold / InitComponents

Function InitComponents

engine/gameobject/src/gameobject/gameobject.cpp:1780–1813  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1778 }
1779
1780 static bool InitComponents(Collection* collection, HInstance instance)
1781 {
1782 uint32_t next_component_instance_data = 0;
1783 Prototype* prototype = instance->m_Prototype;
1784 bool init_result = true;
1785 for (uint32_t i = 0; i < prototype->m_ComponentCount; ++i)
1786 {
1787 Prototype::Component* component = &prototype->m_Components[i];
1788 ComponentType* component_type = component->m_Type;
1789
1790 uintptr_t* component_instance_data = 0;
1791 if (component_type->m_InstanceHasUserData)
1792 {
1793 component_instance_data = &instance->m_ComponentInstanceUserData[next_component_instance_data++];
1794 }
1795 assert(next_component_instance_data <= instance->m_ComponentInstanceUserDataCount);
1796
1797 if (component_type->m_InitFunction)
1798 {
1799 ComponentInitParams params;
1800 params.m_Collection = collection->m_HCollection;
1801 params.m_Instance = instance;
1802 params.m_World = collection->m_ComponentWorlds[component->m_TypeIndex];
1803 params.m_Context = component_type->m_Context;
1804 params.m_UserData = component_instance_data;
1805 CreateResult result = component_type->m_InitFunction(params);
1806 if (result != CREATE_RESULT_OK)
1807 {
1808 init_result = false;
1809 }
1810 }
1811 }
1812 return init_result;
1813 }
1814
1815 static bool InitInstance(Collection* collection, HInstance instance)
1816 {

Callers 2

InitInstanceFunction · 0.85
RecreateInstanceFunction · 0.85

Calls 1

assertFunction · 0.50

Tested by

no test coverage detected