asmrobot
2019-11-21 589ed88a5924a7494e21b95b6bbff5e46ff49ddd
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
49
50
51
52
53
54
55
56
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace RichCreator.Utility.PathFindings
{
    public class PathNode
    {
        public PathNode(bool isWall, Point2 position)
        {
            this.isWall = isWall;
            this.position = position;
        }
 
        public readonly Point2 position;
 
        public bool isWall { get; set; }
 
        public PathNode parent { get; set; }
 
        public int gCost { get; set; }
 
        public int hCost { get; set; }
 
        public int fCost
        {
            get
            {
                return gCost + hCost;
            }
        }
 
        public override bool Equals(object obj)
        {
            PathNode node = obj as PathNode;
            return node.isWall == this.isWall && node.gCost == this.gCost && node.hCost == this.hCost && node.parent == this.parent && this.position == node.position;
        }
 
        public override int GetHashCode()
        {
            return gCost ^ (hCost * 128) + position.GetHashCode();
        }
 
        public static bool operator ==(PathNode a, PathNode b)
        {
            return a.Equals(b);
        }
 
        public static bool operator !=(PathNode a, PathNode b)
        {
            return !a.Equals(b);
        }
    }
}