Пример #1
0
 private void SetShipDock(SCCoords coords)
 {
     if ((main.Overworld.Tiles[coords.X, coords.Y].Tile & SCBitFlags.ShipDock) > 0)
     {
         shipDockArea = main.Overworld.Areas[main.Overworld.Tiles[coords.X, coords.Y].Area];
     }
 }
Пример #2
0
        private void CrossCanal(SCOwArea currentArea, SCRequirementsSet requirements, SCOwArea area)
        {
            if ((currentArea.Tile & SCBitFlags.Ocean) == 0)
            {
                foreach (var link in area.Links)
                {
                    var area2 = main.Overworld.Areas[link];

                    if ((area2.Tile & SCBitFlags.Ocean) == 0)
                    {
                        todoset.Enqueue(new SCLogicAreaQueueEntry {
                            AreaId = link, Requirements = requirements
                        });
                    }
                }
            }
            else
            {
                var newRequirements = requirements?.Restrict(SCRequirements.Canal);

                foreach (var link in area.Links)
                {
                    var area2 = main.Overworld.Areas[link];

                    if ((area2.Tile & SCBitFlags.Ocean) > 0)
                    {
                        todoset.Enqueue(new SCLogicAreaQueueEntry {
                            AreaId = link, Requirements = newRequirements
                        });
                    }
                }
            }
        }
Пример #3
0
        private void AddToDo(SCOwArea currentArea, short areaId, SCRequirementsSet requirements)
        {
            var area = main.Overworld.Areas[areaId];

            if ((area.Tile & SCBitFlags.Ocean) > 0 && (currentArea.Tile & SCBitFlags.Ocean) == 0 && currentArea != shipDockArea)
            {
                return;
            }

            if (tunnels.TryGetValue(areaId, out var tlist))
            {
                foreach (var tunnel in tlist)
                {
                    var newRequirements = requirements?.Restrict(tunnel.Requirements);
                    todoset.Enqueue(new SCLogicAreaQueueEntry {
                        AreaId = tunnel.AreaId, Requirements = newRequirements
                    });
                }
            }

            if ((area.Tile & SCBitFlags.Bridge) > 0)
            {
                CrossBridge(currentArea, requirements, area);
            }
            else if ((area.Tile & SCBitFlags.Canal) > 0)
            {
                CrossCanal(currentArea, requirements, area);
            }
            else
            {
                todoset.Enqueue(new SCLogicAreaQueueEntry {
                    AreaId = areaId, Requirements = requirements
                });
            }
        }
Пример #4
0
        private void ProcessDeferred()
        {
            var entry = deferredqueue.Dequeue();

            var tile = Tiles[entry.Coords.X, entry.Coords.Y];

            if (tile.Area >= 0)
            {
                areadic[tile.Area].AddLink(areadic[entry.Area]);
            }
            else
            {
                var area = new SCOwArea((short)areadic.Count, tile.Tile);
                area.Start = entry.Coords;
                areadic.Add(area);
                Tiles[entry.Coords.X, entry.Coords.Y].Area = area.Index;

                area.AddLink(areadic[entry.Area]);

                CheckTile(entry.Coords.OwLeft, area.Index, tile.Tile);
                CheckTile(entry.Coords.OwRight, area.Index, tile.Tile);
                CheckTile(entry.Coords.OwUp, area.Index, tile.Tile);
                CheckTile(entry.Coords.OwDown, area.Index, tile.Tile);
            }
        }
Пример #5
0
        private void DoPathing()
        {
            areadic = new List <SCOwArea>(4096);

            var start = new SCCoords(0, 0);

            var startingarea = new SCOwArea(0, Tiles[start.X, start.Y].Tile);

            startingarea.Start = start;
            areadic.Add(startingarea);
            Tiles[start.X, start.Y].Area = startingarea.Index;

            CheckTile(start.OwLeft, startingarea.Index, startingarea.Tile);
            CheckTile(start.OwRight, startingarea.Index, startingarea.Tile);
            CheckTile(start.OwUp, startingarea.Index, startingarea.Tile);
            CheckTile(start.OwDown, startingarea.Index, startingarea.Tile);

            ProcessImmediates();

            while (deferredqueue.Count > 0)
            {
                ProcessDeferred();
                ProcessImmediates();
            }
        }
Пример #6
0
        private void DoPathing()
        {
            short    areaIndex = main.Overworld.Tiles[locations.StartingLocation.X, locations.StartingLocation.Y].Area;
            SCOwArea area      = main.Overworld.Areas[areaIndex];

            foreach (var link in area.Links)
            {
                CheckArea(link, new SCRequirementsSet(SCRequirements.None));
            }

            while (todoset.Count > 0)
            {
                var link = todoset.Dequeue();

                CheckArea(link.AreaId, link.Requirements);
            }
        }
Пример #7
0
        public void AddLink(SCOwArea area)
        {
            //One is Blocked
            if ((Tile & SCBitFlags.Blocked) > 0 || (area.Tile & SCBitFlags.Blocked) > 0)
            {
                return;
            }

            //One is Ocean
            if ((Tile & SCBitFlags.Ocean) > 0 && (area.Tile & (SCBitFlags.River | SCBitFlags.ShipDock | SCBitFlags.Canal | SCBitFlags.Bridge)) == 0)
            {
                return;
            }
            if ((area.Tile & SCBitFlags.Ocean) > 0 && (Tile & (SCBitFlags.River | SCBitFlags.ShipDock | SCBitFlags.Canal | SCBitFlags.Bridge)) == 0)
            {
                return;
            }

            area.Links.Add(Index);
            Links.Add(area.Index);
        }