Beispiel #1
0
    public void NativeHashMap_ContainsKeyMultiHashMap()
    {
        var hashMap = new NativeMultiHashMap <int, int> (1, Allocator.Temp);

        hashMap.Add(5, 7);

        hashMap.Add(6, 9);
        hashMap.Add(6, 10);

        Assert.IsTrue(hashMap.ContainsKey(5));
        Assert.IsTrue(hashMap.ContainsKey(6));
        Assert.IsFalse(hashMap.ContainsKey(4));

        hashMap.Dispose();
    }
Beispiel #2
0
        internal bool GetBlobAssetsOfGameObject(GameObject gameObject, Allocator allocator, out NativeArray <Hash128> result)
        {
            var key = gameObject.GetInstanceID();

            if (!m_HashByOwner.ContainsKey(key))
            {
                result = default;
                return(false);
            }

            var count = m_HashByOwner.CountValuesForKey(key);

            result = new NativeArray <Hash128>(count, allocator);

            var index = 0;

            if (m_HashByOwner.TryGetFirstValue(key, out var hash, out var it))
            {
                result[index++] = hash;

                while (m_HashByOwner.TryGetNextValue(out hash, ref it))
                {
                    result[index++] = hash;
                }
            }

            return(true);
        }
Beispiel #3
0
    private void FindValidPoints(int index, NativeList <float> freePointList,
                                 NativeList <float> blockedPointList,
                                 NativeMultiHashMap <int, RaycastHit> hits)
    {
        if (hits.ContainsKey(index))
        {
            NativeMultiHashMap <int, RaycastHit> .Enumerator tempHits = hits.GetValuesForKey(index);
            tempHits.MoveNext();

            //The Top most point is always free
            freePointList.Add(tempHits.Current.point.y);
            Vector3 prevPoint = tempHits.Current.point;

            while (tempHits.MoveNext())
            {
                RaycastHit currentHit = tempHits.Current;

                if (currentHit.point.y + playerHeight > prevPoint.y)
                {
                    blockedPointList.Add(currentHit.point.y);
                }
                else
                {
                    freePointList.Add(currentHit.point.y);
                }

                prevPoint = currentHit.point;
            }
        }
    }
Beispiel #4
0
    public void NativeMultiHashMap_UseAfterFree_UsesCustomOwnerTypeName()
    {
        var container = new NativeMultiHashMap <int, int>(10, Allocator.TempJob);

        container.Add(0, 123);
        container.Dispose();
        Assert.That(() => container.ContainsKey(0),
                    Throws.Exception.TypeOf <ObjectDisposedException>()
                    .With.Message.Contains($"The {container.GetType()} has been deallocated"));
    }
Beispiel #5
0
        /// <summary>
        /// 查询一组node是否已存在于图中
        /// </summary>
        /// <param name="nodes"></param>
        /// <param name="allocator"></param>
        /// <returns></returns>
        public NativeArray <bool> NodesExisted(ref NativeList <Node> nodes, Allocator allocator)
        {
            var result = new NativeArray <bool>(nodes.Length, allocator);

            for (var i = 0; i < nodes.Length; i++)
            {
                result[i] = _nodeToParent.ContainsKey(nodes[i]);
            }

            return(result);
        }
Beispiel #6
0
    public void NativeHashMap_DisposeJob()
    {
        var container0 = new NativeHashMap <int, int>(1, Allocator.Persistent);

        Assert.True(container0.IsCreated);
        Assert.DoesNotThrow(() => { container0.Add(0, 1); });
        Assert.True(container0.ContainsKey(0));

        var container1 = new NativeMultiHashMap <int, int>(1, Allocator.Persistent);

        Assert.True(container1.IsCreated);
        Assert.DoesNotThrow(() => { container1.Add(1, 2); });
        Assert.True(container1.ContainsKey(1));

        var disposeJob0 = container0.Dispose(default);
        public void Add(GUID asset, T userKey, bool async)
        {
            if (GetIterator(asset, userKey, out var temp))
            {
                throw new ArgumentException("Add must not be called with an asset & userKey that has already been Added.");
            }

            LogDependencyTracker($"Add: {asset}");
            // Progress is tracked per asset (Not per asset / userKey combination)
            // So we only increase _TotalProgressAssets when we see a new asset
            if (!_AllAssets.ContainsKey(asset))
            {
                _TotalProgressAssets += 1;
                _UpdateProgressBar    = true;
            }

            var value = new ReportedValue
            {
                ReportedHash = default, UserKey = userKey, Async = async, DidReport = false