Example #1
0
        public void UpdateNode(Point pos, Tile tile)
        {
            if (_nodes.ContainsKey(pos))
            {
                _nodes[pos].Tile = tile;
            }
            else
            {
                var newNode = new Node(tile);
                _nodes[pos] = newNode;
                foreach (var adjacent in NavUtils.ForEachAdjacentTile(tile.Position))
                {
                    // Do not add if non-existant
                    if (!_nodes.ContainsKey(adjacent))
                    {
                        continue;
                    }

                    _edges.Add(new Edge(newNode, _nodes[adjacent]));
                    _edges.Add(new Edge(_nodes[adjacent], newNode));
                }
            }
        }