System.Collections.Generic.HashSet.Contains(TileProperty)

Here are the examples of the csharp api System.Collections.Generic.HashSet.Contains(TileProperty) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

19 Source : PathFinder.cs
with GNU General Public License v3.0
from Fy-

public static PathResult GetPath(Vector2Int startPosition, Vector2Int endPosition) {
			TileProperty start = Loki.map[startPosition];
			TileProperty end = Loki.map[endPosition];
			bool success = false;
			Vector2Int[] path = new Vector2Int[0];
			start.parent = start;

			if (!start.blockPath && !end.blockPath) {
				SimplePriorityQueue<TileProperty> openSet = new SimplePriorityQueue<TileProperty>();
				HashSet<TileProperty> closedSet = new HashSet<TileProperty>();

				openSet.Enqueue(start, start.fCost);
				while (openSet.Count > 0) {
					TileProperty current = openSet.Dequeue();
					if (current == end) {
						success = true;
						break;
					}
					closedSet.Add(current);
					for (int i = 0; i < 8; i++) {
						TileProperty neighbour = Loki.map[current.position+DirectionUtils.neighbours[i]];
						if (neighbour == null || neighbour.blockPath || closedSet.Contains(neighbour)) {
							continue;
						}
						float neighbourCost = current.gCost + Utils.Distance(current.position, neighbour.position) + neighbour.pathCost;
						if (neighbourCost > neighbour.gCost || !openSet.Contains(neighbour)) {
							neighbour.gCost = neighbourCost;
							neighbour.hCost = Utils.Distance(neighbour.position, end.position);
							neighbour.parent = current;

							if (!openSet.Contains(neighbour)) {
								openSet.Enqueue(neighbour, neighbour.fCost);
							} else {
								openSet.UpdatePriority(neighbour, neighbour.fCost);
							}
						}
					}
				}
			} 

			if (success) {
				path = PathFinder.CalcPath(start, end);
				success = path.Length > 0;
			}
			return new PathResult(path, success);
		}