コード例 #1
0
        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));
        }
コード例 #2
0
        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;
        }
コード例 #3
0
 public int GetMaxElements(PersistableTypeHandle typeHandle)
 {
     Debug.Assert(typeHandle.IsValid, "Expected a valid type handle");
     return(_allPersistableTypeInfos[typeHandle.Handle - 1].MaxElements);
 }
コード例 #4
0
 public bool IsBufferType(PersistableTypeHandle typeHandle)
 {
     Debug.Assert(typeHandle.IsValid, "Expected a valid type handle");
     return(_allPersistableTypeInfos[typeHandle.Handle - 1].IsBuffer);
 }
コード例 #5
0
 // 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));
 }
コード例 #6
0
 public int GetTypeIndex(PersistableTypeHandle typeHandle)
 {
     Debug.Assert(typeHandle.IsValid); // "Expected a valid type handle"
     return(TypeIndexArray[typeHandle.Handle - 1]);
 }