internal Unity.Entities.Hash128 GetTypeHandleCombinationHash(NativeArray <PersistableTypeHandle> typeHandles)
        {
            ulong hash1 = 0;
            ulong hash2 = 0;

            for (int i = 0; i < typeHandles.Length; i++)
            {
                PersistableTypeHandle handle = typeHandles[i];

                unchecked
                {
                    if (i % 2 == 0)
                    {
                        ulong hash = 17;
                        hash  = hash * 31 + hash1;
                        hash  = hash * 31 + (ulong)handle.Handle.GetHashCode();
                        hash1 = hash;
                    }
                    else
                    {
                        ulong hash = 17;
                        hash  = hash * 31 + hash2;
                        hash  = hash * 31 + (ulong)handle.Handle.GetHashCode();
                        hash2 = hash;
                    }
                }
            }
            return(new UnityEngine.Hash128(hash1, hash2));
        }
        private void Initialize()
        {
            var typeIndexArray = new NativeArray <int>(_allPersistableTypeInfos.Count, Allocator.Persistent);

            _typeIndexToHandle = new NativeHashMap <int, PersistableTypeHandle>(_allPersistableTypeInfos.Count, Allocator.Persistent);
            for (int i = 0; i < _allPersistableTypeInfos.Count; i++)
            {
                PersistableTypeInfo typeInfo = _allPersistableTypeInfos[i];
                typeInfo.ValidityCheck();
                int typeIndex = TypeManager.GetTypeIndexFromStableTypeHash(typeInfo.StableTypeHash);
                typeIndexArray[i]             = typeIndex;
                _typeIndexToHandle[typeIndex] = new PersistableTypeHandle {
                    Handle = (ushort)(i + 1)
                };
            }
            _typeIndexLookup = new TypeIndexLookup()
            {
                TypeIndexArray = typeIndexArray
            };
            _initialized = true;
        }
 public int GetMaxElements(PersistableTypeHandle typeHandle)
 {
     Debug.Assert(typeHandle.IsValid, "Expected a valid type handle");
     return(_allPersistableTypeInfos[typeHandle.Handle - 1].MaxElements);
 }
 public bool IsBufferType(PersistableTypeHandle typeHandle)
 {
     Debug.Assert(typeHandle.IsValid, "Expected a valid type handle");
     return(_allPersistableTypeInfos[typeHandle.Handle - 1].IsBuffer);
 }
 // fastest way to get the type index
 public int GetTypeIndex(PersistableTypeHandle typeHandle)
 {
     Debug.Assert(typeHandle.IsValid, "Expected a valid type handle");
     return(_typeIndexLookup.GetTypeIndex(typeHandle));
 }
 public int GetTypeIndex(PersistableTypeHandle typeHandle)
 {
     Debug.Assert(typeHandle.IsValid); // "Expected a valid type handle"
     return(TypeIndexArray[typeHandle.Handle - 1]);
 }