private unsafe InjectComponentGroupData(ComponentSystemBase system, FieldInfo groupField, InjectionData[] componentDataInjections, InjectionData[] bufferArrayInjections, InjectionData[] sharedComponentInjections, FieldInfo entityArrayInjection, FieldInfo indexFromEntityInjection, InjectionContext injectionContext, FieldInfo lengthInjection, FieldInfo componentGroupIndexField, ComponentType[] componentRequirements) { m_EntityGroup = system.GetComponentGroupInternal(componentRequirements); m_ComponentGroupIndex = Array.IndexOf(system.ComponentGroups, m_EntityGroup); m_ComponentDataInjections = componentDataInjections; m_BufferArrayInjections = bufferArrayInjections; m_SharedComponentInjections = sharedComponentInjections; m_InjectionContext = injectionContext; PatchGetIndexInComponentGroup(m_ComponentDataInjections); PatchGetIndexInComponentGroup(m_BufferArrayInjections); PatchGetIndexInComponentGroup(m_SharedComponentInjections); injectionContext.PrepareEntries(m_EntityGroup); if (entityArrayInjection != null) { m_EntityArrayOffset = UnsafeUtility.GetFieldOffset(entityArrayInjection); } else { m_EntityArrayOffset = -1; } if (lengthInjection != null) { m_LengthOffset = UnsafeUtility.GetFieldOffset(lengthInjection); } else { m_LengthOffset = -1; } m_GroupFieldOffset = UnsafeUtility.GetFieldOffset(groupField); if (componentGroupIndexField != null) { ulong gchandle; var pinnedSystemPtr = (byte *)UnsafeUtility.PinGCObjectAndGetAddress(system, out gchandle); var groupIndexPtr = pinnedSystemPtr + m_GroupFieldOffset + UnsafeUtility.GetFieldOffset(componentGroupIndexField); int groupIndex = m_ComponentGroupIndex; UnsafeUtility.CopyStructureToPtr(ref groupIndex, groupIndexPtr); UnsafeUtility.ReleaseGCObject(gchandle); } }
InjectComponentGroupData(ComponentSystemBase system, FieldInfo groupField, InjectionData[] componentDataInjections, InjectionData[] fixedArrayInjections, InjectionData[] sharedComponentInjections, FieldInfo entityArrayInjection, FieldInfo indexFromEntityInjection, InjectionContext injectionContext, FieldInfo lengthInjection, ComponentType[] componentRequirements) { var requiredComponentTypes = componentRequirements; m_EntityGroup = system.GetComponentGroup(requiredComponentTypes); m_ComponentDataInjections = componentDataInjections; m_FixedArrayInjections = fixedArrayInjections; m_SharedComponentInjections = sharedComponentInjections; m_InjectionContext = injectionContext; PatchGetIndexInComponentGroup(m_ComponentDataInjections); PatchGetIndexInComponentGroup(m_FixedArrayInjections); PatchGetIndexInComponentGroup(m_SharedComponentInjections); injectionContext.PrepareEntries(m_EntityGroup); if (entityArrayInjection != null) { m_EntityArrayOffset = UnsafeUtility.GetFieldOffset(entityArrayInjection); } else { m_EntityArrayOffset = -1; } if (indexFromEntityInjection != null) { m_IndexFromEntityOffset = UnsafeUtility.GetFieldOffset(indexFromEntityInjection); } else { m_IndexFromEntityOffset = -1; } if (lengthInjection != null) { m_LengthOffset = UnsafeUtility.GetFieldOffset(lengthInjection); } else { m_LengthOffset = -1; } m_GroupFieldOffset = UnsafeUtility.GetFieldOffset(groupField); }
private unsafe InjectComponentGroupData(ComponentSystemBase system, FieldInfo groupField, InjectionData[] componentDataInjections, InjectionData[] bufferArrayInjections, InjectionData[] sharedComponentInjections, FieldInfo entityArrayInjection, FieldInfo indexFromEntityInjection, InjectionContext injectionContext, FieldInfo lengthInjection, FieldInfo componentGroupIndexField, ComponentType[] componentRequirements) { this.m_EntityGroup = system.GetComponentGroupInternal(componentRequirements); this.m_ComponentGroupIndex = Array.IndexOf <ComponentGroup>(system.ComponentGroups, this.m_EntityGroup); this.m_ComponentDataInjections = componentDataInjections; this.m_BufferArrayInjections = bufferArrayInjections; this.m_SharedComponentInjections = sharedComponentInjections; this.m_InjectionContext = injectionContext; this.PatchGetIndexInComponentGroup(this.m_ComponentDataInjections); this.PatchGetIndexInComponentGroup(this.m_BufferArrayInjections); this.PatchGetIndexInComponentGroup(this.m_SharedComponentInjections); injectionContext.PrepareEntries(this.m_EntityGroup); if (entityArrayInjection != null) { this.m_EntityArrayOffset = UnsafeUtility.GetFieldOffset(entityArrayInjection); } else { this.m_EntityArrayOffset = -1; } if (lengthInjection != null) { this.m_LengthOffset = UnsafeUtility.GetFieldOffset(lengthInjection); } else { this.m_LengthOffset = -1; } this.m_GroupFieldOffset = UnsafeUtility.GetFieldOffset(groupField); if (componentGroupIndexField != null) { ulong num; UnsafeUtility.CopyStructureToPtr <int>(ref this.m_ComponentGroupIndex, (UnsafeUtility.PinGCObjectAndGetAddress(system, out num) + this.m_GroupFieldOffset) + UnsafeUtility.GetFieldOffset(componentGroupIndexField)); UnsafeUtility.ReleaseGCObject(num); } }