public void NativeSortedSetTest()
 {
     using NativeSortedSet <int> set = new NativeSortedSet <int>(4);
     Assert.IsTrue(set.IsEmpty);
     Assert.IsTrue(set.IsValid);
     Assert.AreEqual(0, set.Length);
     Assert.AreEqual(4, set.Capacity);
 }
            public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
            {
                var entities         = chunk.GetNativeArray(entityType);
                var findingPathInfos = chunk.GetNativeArray(findingPathInfoType);
                var mapBodies        = chunk.GetNativeArray(mapBodyType);
                var mapElements      = chunk.GetNativeArray(mapElementType);
                NativeSortedSet <Node>      frontier = new NativeSortedSet <Node>(8);
                NativeArray <Node>          nodes    = new NativeArray <Node>(8, Allocator.Temp);
                NativeHashMap <Point, Node> nodeInfo = new NativeHashMap <Point, Node>(8, Allocator.Temp);

                for (int i = 0; i < entities.Length; i++)
                {
                    var entity         = entities[i];
                    var start          = mapBodies[i].point;
                    var mapEntity      = mapElements[i].value;
                    var mapData        = mapDataType[mapEntity];
                    var collisionState = collisionStateType[mapEntity];
                    var info           = findingPathInfos[i];
                    var destination    = info.destination;
                    frontier.Clear();
                    nodeInfo.Clear();
                    var initialNode = new Node(start, start, 0, 0);
                    frontier.Add(initialNode);
                    nodeInfo[start] = initialNode;
                    bool found = false;
                    bool canReachDestination;

                    while (frontier.Length > 0)
                    {
                        var step = frontier.Pop();
                        if (step.point.Equals(info.destination))
                        {
                            found = true;
                            break;
                        }


                        canReachDestination = ExpandNode(entity, step.point, start, destination, info, mapData, collisionState, nodes);
                        if (!canReachDestination)
                        {
                            if (info.routeClosest && !step.point.Equals(start))
                            {
                                destination = step.point;
                                found       = true;
                            }
                            break;
                        }
                        for (int j = 0; j < nodes.Length; j++)
                        {
                            var node = nodes[j];

                            if (node.Equals(default))
Exemplo n.º 3
0
 public NativeHeapDebugView(NativeSortedSet <T> heap)
 {
     m_Heap = heap;
 }