Ejemplo n.º 1
0
    public WaterRegion GetRegionByID(int ID)
    {
        WaterRegion region = null;

        m_waterRegions.TryGetValue(ID, out region);
        return(region);
    }
Ejemplo n.º 2
0
 private void DetermineStartRegions(IntVec3 start)
 {
     this.startingRegions.Clear();
     if (this.pathGrid.WalkableFast(start))
     {
         WaterRegion validRegionAt = this.regionGrid.GetValidRegionAt(start);
         this.QueueNewOpenRegion(validRegionAt);
         this.startingRegions.Add(validRegionAt);
     }
     else
     {
         for (int i = 0; i < 8; i++)
         {
             IntVec3 c = start + GenAdj.AdjacentCells[i];
             if (c.InBoundsShip(this.map))
             {
                 if (this.pathGrid.WalkableFast(c))
                 {
                     WaterRegion validRegionAt2 = this.regionGrid.GetValidRegionAt(c);
                     if (!(validRegionAt2 is null) && validRegionAt2.reachedIndex != this.reachedIndex)
                     {
                         this.QueueNewOpenRegion(validRegionAt2);
                         this.startingRegions.Add(validRegionAt2);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
    protected override bool OnParseLine(int nLineNum)
    {
        WaterRegion wr = new WaterRegion();

        wr.ID   = GetInt("ID");
        wr.name = GetString("Name");

        int FishID = GetInt("Fish1");

        wr.FishsID.Add(FishID);

        FishID = GetInt("Fish2");
        wr.FishsID.Add(FishID);

        FishID = GetInt("Fish3");
        wr.FishsID.Add(FishID);

        FishID = GetInt("Fish4");
        wr.FishsID.Add(FishID);

        FishID = GetInt("Fish5");
        wr.FishsID.Add(FishID);

        m_waterRegions.Add(wr.ID, wr);
        return(true);
    }
Ejemplo n.º 4
0
 public RegionLinkQueueEntry(WaterRegion from, WaterRegionLink link, int cost, int estimatedPathCost)
 {
     this.from = from;
     this.link = link;
     this.cost = cost;
     this.estimatedPathCost = estimatedPathCost;
 }
Ejemplo n.º 5
0
 public bool Init()
 {
     for (int i = 0; i < regionsID.Count; i++)
     {
         int         regionID = regionsID[i];
         WaterRegion region   = FishGameSetting.Instance.regionData.GetRegionByID(regionID);
         if (region != null)
         {
             m_waterRegions.Add(region);
         }
     }
     return(true);
 }
Ejemplo n.º 6
0
        public bool CanReachUnfogged(IntVec3 c, TraverseParms traverseParms)
        {
            if (traverseParms.pawn != null)
            {
                if (!traverseParms.pawn.Spawned)
                {
                    return(false);
                }
                if (traverseParms.pawn.Map != this.map)
                {
                    Log.Error(string.Concat(new object[]
                    {
                        "Called CanReachUnfogged() with a pawn spawned not on this map. This means that we can't check his reachability here. Pawn's current map should have been used instead of this one. pawn=",
                        traverseParms.pawn,
                        " pawn.Map=",
                        traverseParms.pawn.Map,
                        " map=",
                        this.map
                    }), false);
                    return(false);
                }
            }
            if (!c.InBoundsShip(this.map))
            {
                return(false);
            }
            if (!c.Fogged(this.map))
            {
                return(true);
            }
            WaterRegion region = WaterGridsUtility.GetRegion(c, this.map, RegionType.Set_Passable);

            if (region == null)
            {
                return(false);
            }
            WaterRegionEntryPredicate entryCondition = (WaterRegion from, WaterRegion r) => r.Allows(traverseParms, false);
            bool foundReg = false;
            WaterRegionProcessor regionProcessor = delegate(WaterRegion r)
            {
                if (!r.AnyCell.Fogged(this.map))
                {
                    foundReg = true;
                    return(true);
                }
                return(false);
            };

            WaterRegionTraverser.BreadthFirstTraverse(region, entryCondition, regionProcessor, 9999, RegionType.Set_Passable);
            return(foundReg);
        }
Ejemplo n.º 7
0
 private void QueueNewOpenRegion(WaterRegion region)
 {
     if (region is null)
     {
         Log.ErrorOnce("Tried to queue null region (RimShips).", 881121, false);
         return;
     }
     if (region.reachedIndex == this.reachedIndex)
     {
         Log.ErrorOnce("WaterRegion is already reached; you can't open it. WaterRegion: " + region.ToString(), 719991, false);
         return;
     }
     this.openQueue.Enqueue(region);
     region.reachedIndex = this.reachedIndex;
     this.numRegionsOpened++;
 }
Ejemplo n.º 8
0
 public void Init(CellRect end, TraverseParms traverseParms, int moveTicksCardinal, int moveTicksDiagonal, ByteGrid avoidGrid, Area allowedArea, bool drafted, List <int> disallowedCorners)
 {
     this.moveTicksCardinal         = moveTicksCardinal;
     this.moveTicksDiagonal         = moveTicksDiagonal;
     this.endCell                   = end.CenterCell;
     this.cachedRegion              = null;
     this.cachedBestLink            = null;
     this.cachedSecondBestLink      = null;
     this.cachedBestLinkCost        = 0;
     this.cachedSecondBestLinkCost  = 0;
     this.cachedRegionIsDestination = false;
     this.regionGrid                = MapExtensionUtility.GetExtensionToMap(this.map).getWaterRegionGrid.DirectGrid;
     this.destRegions.Clear();
     if (end.Width == 1 && end.Height == 1)
     {
         WaterRegion region = WaterGridsUtility.GetRegion(this.endCell, this.map, RegionType.Set_Passable);
         if (region != null)
         {
             this.destRegions.Add(region);
         }
     }
     else
     {
         CellRect.CellRectIterator iterator = end.GetIterator();
         while (!iterator.Done())
         {
             IntVec3 intVec = iterator.Current;
             if (intVec.InBoundsShip(this.map) && !disallowedCorners.Contains(this.map.cellIndices.CellToIndex(intVec)))
             {
                 WaterRegion region2 = WaterGridsUtility.GetRegion(intVec, this.map, RegionType.Set_Passable);
                 if (region2 != null)
                 {
                     if (region2.Allows(traverseParms, true))
                     {
                         this.destRegions.Add(region2);
                     }
                 }
             }
             iterator.MoveNext();
         }
     }
     if (this.destRegions.Count == 0)
     {
         Log.Error("Couldn't find any destination regions. This shouldn't ever happen because we've checked reachability.", false);
     }
     this.regionCostCalculatorShips.Init(end, this.destRegions, traverseParms, moveTicksCardinal, moveTicksDiagonal, avoidGrid, allowedArea, drafted);
 }
Ejemplo n.º 9
0
        public int GetRegionBestDistances(WaterRegion region, out WaterRegionLink bestLink, out WaterRegionLink secondBestLink, out int secondBestCost)
        {
            int regionDistance = this.GetRegionDistance(region, out bestLink);

            secondBestLink = null;
            secondBestCost = int.MaxValue;
            foreach (WaterRegionLink regionLink in region.links)
            {
                if (regionLink != bestLink && regionLink.GetOtherRegion(region).type.Passable())
                {
                    int num;
                    if (this.distances.TryGetValue(regionLink, out num) && num < secondBestCost)
                    {
                        secondBestCost = num;
                        secondBestLink = regionLink;
                    }
                }
            }
            return(regionDistance);
        }
Ejemplo n.º 10
0
        public static void AddAllowedAdjacentRegions(LocalTargetInfo dest, TraverseParms traverseParams, Map map, List <WaterRegion> regions)
        {
            IntVec3 bl;
            IntVec3 tl;
            IntVec3 tr;
            IntVec3 br;

            GenAdj.GetAdjacentCorners(dest, out bl, out tl, out tr, out br);
            if (!dest.HasThing || (dest.Thing.def.size.x == 1 && dest.Thing.def.size.z == 1))
            {
                IntVec3 cell = dest.Cell;
                for (int i = 0; i < 8; i++)
                {
                    IntVec3 intVec = GenAdj.AdjacentCells[i] + cell;
                    if (intVec.InBoundsShip(map) && !TouchPathEndModeUtility.IsAdjacentCornerAndNotAllowed(intVec, bl, tl, tr, br, map))
                    {
                        WaterRegion region = WaterGridsUtility.GetRegion(intVec, map, RegionType.Set_Passable);
                        if (region != null && region.Allows(traverseParams, true))
                        {
                            regions.Add(region);
                        }
                    }
                }
            }
            else
            {
                List <IntVec3> list = GenAdjFast.AdjacentCells8Way(dest);
                for (int j = 0; j < list.Count; j++)
                {
                    if (list[j].InBoundsShip(map) && !TouchPathEndModeUtility.IsAdjacentCornerAndNotAllowed(list[j], bl, tl, tr, br, map))
                    {
                        WaterRegion region2 = WaterGridsUtility.GetRegion(list[j], map, RegionType.Set_Passable);
                        if (region2 != null && region2.Allows(traverseParams, true))
                        {
                            regions.Add(region2);
                        }
                    }
                }
            }
        }
Ejemplo n.º 11
0
        private void GetPreciseRegionLinkDistances(WaterRegion region, CellRect destination, List <Pair <WaterRegionLink, int> > outDistances)
        {
            outDistances.Clear();
            RegionCostCalculatorShips.tmpCellIndices.Clear();
            if (destination.Width == 1 && destination.Height == 1)
            {
                RegionCostCalculatorShips.tmpCellIndices.Add(this.map.cellIndices.CellToIndex(destination.CenterCell));
            }
            else
            {
                CellRect.CellRectIterator iterator = destination.GetIterator();
                while (!iterator.Done())
                {
                    IntVec3 c = iterator.Current;
                    if (c.InBoundsShip(this.map))
                    {
                        RegionCostCalculatorShips.tmpCellIndices.Add(this.map.cellIndices.CellToIndex(c));
                    }
                    iterator.MoveNext();
                }
            }
            Dijkstra <int> .Run(RegionCostCalculatorShips.tmpCellIndices, (int x) => this.PreciseRegionLinkDistancesNeighborsGetter(x, region),
                                this.preciseRegionLinkDistancesDistanceGetter, RegionCostCalculatorShips.tmpDistances, null);

            foreach (WaterRegionLink regionLink in region.links)
            {
                if (regionLink.GetOtherRegion(region).Allows(this.traverseParms, false))
                {
                    float num;
                    if (!RegionCostCalculatorShips.tmpDistances.TryGetValue(this.map.cellIndices.CellToIndex(this.linkTargetCells[regionLink]), out num))
                    {
                        Log.ErrorOnce("Dijkstra couldn't reach one of the cells even though they are in the same region. There is most likely something wrong with the " +
                                      "neighbor nodes getter. Error occurred in ShipPathFinder of RimShips", 1938471531, false);
                        num = 100f;
                    }
                    outDistances.Add(new Pair <WaterRegionLink, int>(regionLink, (int)num));
                }
            }
        }
Ejemplo n.º 12
0
 private bool CheckRegionBasedReachability(TraverseParms traverseParms)
 {
     while (this.openQueue.Count > 0)
     {
         WaterRegion region = this.openQueue.Dequeue();
         foreach (WaterRegionLink regionLink in region.links)
         {
             for (int i = 0; i < 2; i++)
             {
                 WaterRegion region2 = regionLink.regions[i];
                 if (!(region2 is null) && region2.reachedIndex != this.reachedIndex && region2.type.Passable())
                 {
                     if (region2.Allows(traverseParms, false))
                     {
                         if (this.destRegions.Contains(region2))
                         {
                             foreach (WaterRegion startRegion in this.startingRegions)
                             {
                                 this.cache.AddCachedResult(startRegion.Room, region2.Room, traverseParms, true);
                             }
                             return(true);
                         }
                         this.QueueNewOpenRegion(region2);
                     }
                 }
             }
         }
     }
     foreach (WaterRegion startRegion in this.startingRegions)
     {
         foreach (WaterRegion destRegion in this.destRegions)
         {
             this.cache.AddCachedResult(startRegion.Room, destRegion.Room, traverseParms, false);
         }
     }
     return(false);
 }
Ejemplo n.º 13
0
        public int RegionMedianPathCost(WaterRegion region)
        {
            int result;

            if (this.minPathCosts.TryGetValue(region, out result))
            {
                return(result);
            }
            bool        ignoreAllowedAreaCost = this.allowedArea != null && region.OverlapWith(this.allowedArea) != AreaOverlap.None;
            CellIndices cellIndices           = this.map.cellIndices;

            Rand.PushState();
            Rand.Seed = cellIndices.CellToIndex(region.extentsClose.CenterCell) * (region.links.Count + 1);
            for (int i = 0; i < SampleCount; i++)
            {
                RegionCostCalculatorShips.pathCostSamples[i] = this.GetCellCostFast(cellIndices.CellToIndex(region.RandomCell), ignoreAllowedAreaCost);
            }
            Rand.PopState();
            Array.Sort <int>(RegionCostCalculatorShips.pathCostSamples);
            int num = RegionCostCalculatorShips.pathCostSamples[4];

            this.minPathCosts[region] = num;
            return(num);
        }
Ejemplo n.º 14
0
        public int GetPathCostFromDestToRegion(int cellIndex)
        {
            WaterRegion region = this.regionGrid[cellIndex];
            IntVec3     cell   = this.map.cellIndices.IndexToCell(cellIndex);

            if (region != this.cachedRegion)
            {
                this.cachedRegionIsDestination = this.destRegions.Contains(region);
                if (this.cachedRegionIsDestination)
                {
                    return(this.OctileDistanceToEnd(cell));
                }
                this.cachedBestLinkCost = this.regionCostCalculatorShips.GetRegionBestDistances(region, out this.cachedBestLink, out this.cachedSecondBestLink, out this.cachedSecondBestLinkCost);
                this.cachedRegion       = region;
            }
            else if (this.cachedRegionIsDestination)
            {
                return(this.OctileDistanceToEnd(cell));
            }
            if (this.cachedBestLink != null)
            {
                int num = this.regionCostCalculatorShips.RegionLinkDistance(cell, this.cachedBestLink, 1);
                int num3;
                if (this.cachedSecondBestLink != null)
                {
                    int num2 = this.regionCostCalculatorShips.RegionLinkDistance(cell, this.cachedSecondBestLink, 1);
                    num3 = Mathf.Min(this.cachedSecondBestLinkCost + num2, this.cachedBestLinkCost + num);
                }
                else
                {
                    num3 = this.cachedBestLinkCost + num;
                }
                return(num3 + this.OctileDistanceToEndEps(cell));
            }
            return(10000);
        }
Ejemplo n.º 15
0
 public int GetRegionDistance(WaterRegion region, out WaterRegionLink minLink)
 {
     if (this.regionMinLink.TryGetValue(region.id, out minLink))
     {
         return(this.distances[minLink]);
     }
     while (this.queue.Count != 0)
     {
         RegionCostCalculatorShips.RegionLinkQueueEntry regionLinkQueueEntry = this.queue.Pop();
         int num = this.distances[regionLinkQueueEntry.Link];
         if (regionLinkQueueEntry.Cost == num)
         {
             WaterRegion otherRegion = regionLinkQueueEntry.Link.GetOtherRegion(regionLinkQueueEntry.From);
             if (!(otherRegion is null) && otherRegion.valid)
             {
                 int num2 = 0;
                 if (!(otherRegion.door is null))
                 {
                     num2 = ShipPathFinder.GetBuildingCost(otherRegion.door, this.traverseParms, this.traverseParms.pawn);
                     if (num2 == int.MaxValue)
                     {
                         continue;
                     }
                     num2 += this.OctileDistance(1, 0);
                 }
                 int minPathCost = this.RegionMedianPathCost(otherRegion);
                 foreach (WaterRegionLink regionLink in otherRegion.links)
                 {
                     if (regionLink != regionLinkQueueEntry.Link && regionLink.GetOtherRegion(otherRegion).type.Passable())
                     {
                         int num3 = (otherRegion.door is null) ? this.RegionLinkDistance(regionLinkQueueEntry.Link, regionLink, minPathCost) : num2;
                         num3 = Math.Max(num3, 1);
                         int num4 = num + num3;
                         int estimatedPathCost = this.MinimumRegionLinkDistance(this.destinationCell, regionLink) + num4;
                         int num5;
                         if (this.distances.TryGetValue(regionLink, out num5))
                         {
                             if (num4 < num5)
                             {
                                 this.distances[regionLink] = num4;
                                 this.queue.Push(new RegionCostCalculatorShips.RegionLinkQueueEntry(otherRegion, regionLink, num4, estimatedPathCost));
                             }
                         }
                         else
                         {
                             this.distances.Add(regionLink, num4);
                             this.queue.Push(new RegionCostCalculatorShips.RegionLinkQueueEntry(otherRegion, regionLink, num4, estimatedPathCost));
                         }
                     }
                 }
                 if (!this.regionMinLink.ContainsKey(otherRegion.id))
                 {
                     this.regionMinLink.Add(otherRegion.id, regionLinkQueueEntry.Link);
                     if (otherRegion == region)
                     {
                         minLink = regionLinkQueueEntry.Link;
                         return(regionLinkQueueEntry.Cost);
                     }
                 }
             }
         }
     }
     return(10000);
 }
Ejemplo n.º 16
0
        public bool CanReachShip(IntVec3 start, LocalTargetInfo dest, PathEndMode peMode, TraverseParms traverseParms)
        {
            if (this.working)
            {
                Log.ErrorOnce("Called CanReach() while working for Ships. This should never happen. Suppressing further errors.", 7312233, false);
                return(false);
            }
            if (!this.map.terrainGrid.TerrainAt(dest.Cell).IsWater)
            {
                return(false);
            }
            if (!(traverseParms.pawn is null))
            {
                if (!traverseParms.pawn.Spawned)
                {
                    return(false);
                }
                if (traverseParms.pawn.Map != this.map)
                {
                    Log.Error(string.Concat(new object[]
                    {
                        "Called CanReach() with a ship spawned not on this map. This means that we can't check its reachability here. Pawn's" +
                        "current map should have been used instead of this one. pawn=", traverseParms.pawn,
                        " pawn.Map=", traverseParms.pawn.Map,
                        " map=", this.map
                    }), false);
                    return(false);
                }
            }
            if (!dest.IsValid)
            {
                return(false);
            }
            if (dest.HasThing && dest.Thing.Map != this.map)
            {
                return(false);
            }
            if (!start.InBoundsShip(this.map) || !dest.Cell.InBoundsShip(this.map))
            {
                return(false);
            }
            if ((peMode == PathEndMode.OnCell || peMode == PathEndMode.Touch || peMode == PathEndMode.ClosestTouch) && traverseParms.mode != TraverseMode.NoPassClosedDoorsOrWater &&
                traverseParms.mode != TraverseMode.PassAllDestroyableThingsNotWater)
            {
                WaterRoom room = WaterRegionAndRoomQuery.RoomAtFast(start, this.map, RegionType.Set_Passable);
                if (!(room is null) && room == WaterRegionAndRoomQuery.RoomAtFast(dest.Cell, this.map, RegionType.Set_Passable))
                {
                    return(true);
                }
            }
            if (traverseParms.mode == TraverseMode.PassAllDestroyableThings)
            {
                TraverseParms traverseParms2 = traverseParms;
                traverseParms.mode = TraverseMode.PassDoors;
                if (this.CanReachShip(start, dest, peMode, traverseParms2))
                {
                    return(true);
                }
            }
            dest         = (LocalTargetInfo)GenPathShip.ResolvePathMode(traverseParms.pawn, dest.ToTargetInfo(this.map), ref peMode, this.mapExt);
            this.working = true;
            bool result;

            try
            {
                this.pathGrid      = mapExt.getShipPathGrid;
                this.regionGrid    = this.mapExt.getWaterRegionGrid;
                this.reachedIndex += 1u;
                this.destRegions.Clear();
                if (peMode == PathEndMode.OnCell)
                {
                    WaterRegion region = WaterGridsUtility.GetRegion(dest.Cell, this.map, RegionType.Set_Passable);
                    if (!(region is null) && region.Allows(traverseParms, true))
                    {
                        this.destRegions.Add(region);
                    }
                }
                else if (peMode == PathEndMode.Touch)
                {
                    TouchPathEndModeUtilityShips.AddAllowedAdjacentRegions(dest, traverseParms, this.map, this.destRegions);
                }
                if (this.destRegions.Count == 0 && traverseParms.mode != TraverseMode.PassAllDestroyableThings && traverseParms.mode !=
                    TraverseMode.PassAllDestroyableThingsNotWater)
                {
                    this.FinalizeCheck();
                    result = false;
                }
                else
                {
                    this.destRegions.RemoveDuplicates <WaterRegion>();
                    this.openQueue.Clear();
                    this.numRegionsOpened = 0;
                    this.DetermineStartRegions(start);
                    if (this.openQueue.Count == 0 && traverseParms.mode != TraverseMode.PassAllDestroyableThings && traverseParms.mode !=
                        TraverseMode.PassAllDestroyableThingsNotWater)
                    {
                        this.FinalizeCheck();
                        result = false;
                    }
                    else
                    {
                        if (this.startingRegions.Any <WaterRegion>() && this.destRegions.Any <WaterRegion>() && this.CanUseCache(traverseParms.mode))
                        {
                            BoolUnknown cachedResult = this.GetCachedResult(traverseParms);
                            if (cachedResult == BoolUnknown.True)
                            {
                                this.FinalizeCheck();
                                return(true);
                            }
                            if (cachedResult == BoolUnknown.False)
                            {
                                this.FinalizeCheck();
                                return(false);
                            }
                        }
                        if (traverseParms.mode == TraverseMode.PassAllDestroyableThings || traverseParms.mode == TraverseMode.PassAllDestroyableThingsNotWater ||
                            traverseParms.mode == TraverseMode.NoPassClosedDoorsOrWater)
                        {
                            bool flag = this.CheckCellBasedReachability(start, dest, peMode, traverseParms);
                            this.FinalizeCheck();
                            result = flag;
                        }
                        else
                        {
                            //bool flag2 = this.CheckRegionBasedReachability(traverseParms);
                            bool flag2 = this.CheckCellBasedReachability(start, dest, peMode, traverseParms); //Change back to region based later
                            this.FinalizeCheck();
                            result = flag2;
                        }
                    }
                }
            }
            finally
            {
                this.working = false;
            }
            return(result);
        }
Ejemplo n.º 17
0
 private IEnumerable <int> PreciseRegionLinkDistancesNeighborsGetter(int node, WaterRegion region)
 {
     if (this.regionGrid[node] is null || this.regionGrid[node] != region)
     {
         return(null);
     }
     return(this.PathableNeighborIndices(node));
 }
Ejemplo n.º 18
0
        private bool CheckCellBasedReachability(IntVec3 start, LocalTargetInfo dest, PathEndMode peMode, TraverseParms traverseParms)
        {
            IntVec3 foundCell = IntVec3.Invalid;

            WaterRegion[] directionRegionGrid = this.regionGrid.DirectGrid;
            ShipPathGrid  pathGrid            = mapExt.getShipPathGrid;
            CellIndices   cellIndices         = this.map.cellIndices;

            this.map.floodFiller.FloodFill(start, delegate(IntVec3 c)
            {
                int num = cellIndices.CellToIndex(c);
                if ((traverseParms.mode == TraverseMode.PassAllDestroyableThingsNotWater || traverseParms.mode == TraverseMode.NoPassClosedDoorsOrWater) &&
                    c.GetTerrain(this.map).IsWater)
                {
                    return(false);
                }
                if (traverseParms.mode == TraverseMode.PassAllDestroyableThings || traverseParms.mode == TraverseMode.PassAllDestroyableThingsNotWater)
                {
                    if (!pathGrid.WalkableFast(num))
                    {
                        Building edifice = c.GetEdifice(this.map);
                        if (edifice is null || !ShipPathFinder.IsDestroyable(edifice))
                        {
                            return(false);
                        }
                    }
                }
                else if (traverseParms.mode != TraverseMode.NoPassClosedDoorsOrWater)
                {
                    //Log.ErrorOnce("Do not use this method for non-cell based modes!", 938476762, false);
                    if (!pathGrid.WalkableFast(num))
                    {
                        return(false);
                    }
                }
                WaterRegion region = directionRegionGrid[num];
                return(region is null || region.Allows(traverseParms, false));
            }, delegate(IntVec3 c)
            {
                if (ShipReachabilityImmediate.CanReachImmediateShip(c, dest, this.map, peMode, traverseParms.pawn))
                {
                    foundCell = c;
                    return(true);
                }
                return(false);
            }, int.MaxValue, false, null);

            if (foundCell.IsValid)
            {
                if (this.CanUseCache(traverseParms.mode))
                {
                    WaterRegion validRegionAt = this.regionGrid.GetValidRegionAt(foundCell);
                    if (!(validRegionAt is null))
                    {
                        foreach (WaterRegion startRegion in this.startingRegions)
                        {
                            this.cache.AddCachedResult(startRegion.Room, validRegionAt.Room, traverseParms, true);
                        }
                    }
                }
                return(true);
            }
            if (this.CanUseCache(traverseParms.mode))
            {
                foreach (WaterRegion startRegion in this.startingRegions)
                {
                    foreach (WaterRegion destRegion in this.destRegions)
                    {
                        this.cache.AddCachedResult(startRegion.Room, destRegion.Room, traverseParms, false);
                    }
                }
            }
            return(false);
        }