-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBreadcrumb.cs
More file actions
48 lines (41 loc) · 1.18 KB
/
Breadcrumb.cs
File metadata and controls
48 lines (41 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using UnityEngine;
using System;
public class BreadCrumb : IComparable<BreadCrumb>
{
public Vector2 position;
public BreadCrumb prev;
public BreadCrumb next;
public int cost = Int32.MaxValue;
public bool onClosedList = false;
public bool onOpenList = false;
public BreadCrumb(Vector2 position)
{
this.position = position;
}
public BreadCrumb(Vector2 position, BreadCrumb parent)
{
this.position = position;
this.next = parent;
parent.prev = this;
}
//Overrides default Equals so we check on position instead of object memory location
public override bool Equals(object obj)
{
return (obj is BreadCrumb) && this.Equals((BreadCrumb)obj);
}
//Faster Equals for if we know something is a BreadCrumb
public bool Equals(BreadCrumb breadcrumb)
{
return breadcrumb.position.x == this.position.x && breadcrumb.position.y == this.position.y;
}
public override int GetHashCode()
{
return position.GetHashCode();
}
#region IComparable<> interface
public int CompareTo(BreadCrumb other)
{
return cost.CompareTo(other.cost);
}
#endregion
}