public void AssertCanAddComponent(Archetype *archetype, ComponentType componentType) { if (componentType == m_EntityComponentType) { throw new ArgumentException("Cannot add Entity as a component."); } if (componentType.IsSharedComponent && (archetype->NumSharedComponents == kMaxSharedComponentCount)) { throw new InvalidOperationException($"Cannot add more than {kMaxSharedComponentCount} SharedComponent to a single Archetype"); } var componentTypeInfo = GetTypeInfo(componentType.TypeIndex); var componentInstanceSize = GetComponentArraySize(componentTypeInfo.SizeInChunk, 1); var archetypeInstanceSize = archetype->InstanceSizeWithOverhead + componentInstanceSize; var chunkDataSize = Chunk.GetChunkBufferSize(); if (archetypeInstanceSize > chunkDataSize) { throw new ArgumentException($"Entity archetype component data is too large after adding {componentType.ToString()}. Previous archetype size per instance {archetype->InstanceSizeWithOverhead} bytes. Attempting to add component size {componentInstanceSize} bytes. Maximum chunk size {chunkDataSize}."); } }