Exemplo n.º 1
0
        protected void TurnClockwise()
        {
            //Always turn clock-wise
            switch (Direction)
            {
            case PathingDirection.NORTH:
                Direction = PathingDirection.EAST;
                break;

            case PathingDirection.EAST:
                Direction = PathingDirection.SOUTH;

                //If we're going EAST, this means next we have to move further to go around
                stepAmount++;
                break;

            case PathingDirection.SOUTH:
                Direction = PathingDirection.WEST;
                break;

            case PathingDirection.WEST:
                Direction = PathingDirection.NORTH;

                //If we're going SOUTH, this means next we have to move further to go around
                stepAmount++;
                break;
            }
        }
Exemplo n.º 2
0
        public bool findClosestUnscoutedChunk(out Vector3Int checkedPosition)
        {
            Vector3Int output = KeyLocation;

            int y = 64;

            if (PathState == PathingState.Started)
            {
                this.pathingX = GetScoutBanner().KeyLocation.x;
                this.pathingZ = GetScoutBanner().KeyLocation.z;
            }

            xStart = pathingX;
            zStart = pathingZ;

            checkedPosition = new Vector3Int(this.pathingX, y, this.pathingZ);

            if (!AIManager.TryGetClosestAIPosition(checkedPosition, AIManager.EAIClosestPositionSearchType.ChunkAndDirectNeighbours,
                                                   out checkedPosition))
            {
                return(false);
            }

            if (!ChunkManagerHasChunkAt(pathingX, y, pathingZ, out checkedPosition) &&
                IsOutsideMinimumRange(new Vector3Int(pathingX, y, pathingZ), GetScoutBanner()))
            {
                return(true);
            }

            bool foundChunk = false;

            while (CoordWithinBounds(pathingX, pathingZ, GetScoutBanner().KeyLocation.x, GetScoutBanner().KeyLocation.z, MaxChunkScoutRange * 16))
            {
                switch (PathState)
                {
                case PathingState.Started:
                    stepAmount = 1;
                    Direction  = PathingDirection.NORTH;
                    PathState  = PathingState.Stepping;
                    break;

                case PathingState.Stepping:
                    for (var steps = steppingProgress; steps < stepAmount; steps++)
                    {
                        if (!ChunkManagerHasChunkAt(pathingX, y, pathingZ, out checkedPosition) &&
                            IsOutsideMinimumRange(checkedPosition, GetScoutBanner()))
                        {
                            foundChunk = true;
                            steppingProgress++;

                            PerformStep();

                            break;
                        }

                        steppingProgress++;

                        PerformStep();
                    }

                    PathState = PathingState.Turning;
                    break;

                case PathingState.Turning:
                    TurnClockwise();
                    StartMoving();
                    break;
                }

                if (!IsOutsideMinimumRange(checkedPosition, GetScoutBanner()))
                {
                    continue;
                }

                if (foundChunk)
                {
                    WriteLog(checkedPosition.ToString());
                    return(true);
                }
            }

            output = Vector3Int.invalidPos;
            return(false);
        }
Exemplo n.º 3
0
 internal static Vector3 GetPathingDirection(int networkId)
 {
     return(PathingDirection.ContainsKey(networkId) ? PathingDirection[networkId] : default(Vector3));
 }