Exemplo n.º 1
0
 public static int2 stepAlong(SavedPath path, int2 currentLocation)
 {
     if (path.currentIdx >= path.pathSteps.Length) return currentLocation;
     var result = path.pathSteps[path.currentIdx];
     path.currentIdx++;
     return result;
 }
Exemplo n.º 2
0
            // Convert a fully-defined Path into a struct Path which is easily usable by DOTS code
            public SavedPath toSavedPath()
            {
                var result = new SavedPath();
                var step = this;
                var length = 0;
                while (step.Parent != null)
                {
                    length++;
                    step = step.Parent;
                }

                var steps = new NativeArray<int2>(length, Allocator.Persistent);
                step = this;
                for(var i = length - 1; i >= 0; i--)
                {
                    steps[i] = step.location;
                    step = step.Parent;
                }
                result.pathSteps = steps;
                
                // We don't actually use the first step since it should be the current position
                result.currentIdx = 1;
                return result;
            }