public void CalculateEntityOffsetsReturns0IfEntity()
        {
            var offsets = EntityRemapUtility.CalculateEntityOffsets(typeof(Entity));

            Assert.AreEqual(1, offsets.Length);
            Assert.AreEqual(0, offsets[0].Offset);
        }
        public void CalculateEntityOffsetsReturnsOffsetsOfEmbeddedEntities()
        {
            var offsets = EntityRemapUtility.CalculateEntityOffsets(typeof(EmbeddedEntityStruct));

            Assert.AreEqual(2, offsets.Length);
            Assert.AreEqual(4, offsets[0].Offset);
            Assert.AreEqual(16, offsets[1].Offset);
        }
        static TypeManager.EntityOffsetInfo[] GetEntityOffsets(System.Type type)
        {
#if !UNITY_DOTSPLAYER
            return(EntityRemapUtility.CalculateEntityOffsets(type));
#else
            unsafe {
                var info = TypeManager.GetTypeInfo(TypeManager.GetTypeIndex(type));
                if (info.EntityOffsetCount > 0)
                {
                    TypeManager.EntityOffsetInfo[] ei = new TypeManager.EntityOffsetInfo[info.EntityOffsetCount];
                    for (var i = 0; i < info.EntityOffsetCount; ++i)
                    {
                        ei[i] = TypeManager.GetEntityOffsets(info)[i];
                    }
                    return(ei);
                }
                return(null);
            }
#endif
        }
        static TypeManager.EntityOffsetInfo[] GetEntityOffsets(System.Type type)
        {
#if !UNITY_DOTSRUNTIME // Work needed to make CalculateEntityOffsets compatible with DOTS Runtime (comment with explanation at that code)
            return(EntityRemapUtility.CalculateEntityOffsets(type));
#else
            unsafe {
                var info = TypeManager.GetTypeInfo(TypeManager.GetTypeIndex(type));
                if (info.EntityOffsetCount > 0)
                {
                    TypeManager.EntityOffsetInfo[] ei = new TypeManager.EntityOffsetInfo[info.EntityOffsetCount];
                    for (var i = 0; i < info.EntityOffsetCount; ++i)
                    {
                        ei[i] = TypeManager.GetEntityOffsets(info)[i];
                    }
                    return(ei);
                }
                return(null);
            }
#endif
        }
        public void CalculateEntityOffsetsReturnsNullIfNoEntities()
        {
            var offsets = EntityRemapUtility.CalculateEntityOffsets(typeof(EmptyStruct));

            Assert.AreEqual(null, offsets);
        }