-
Notifications
You must be signed in to change notification settings - Fork 0
/
Subject.cs
78 lines (62 loc) · 1.84 KB
/
Subject.cs
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using UnityEngine;
public class Subject
{
public char ID { get; set; }
public Location Location { get; set; }
public Vector2 Direction { get; set; }
public Subject() {}
public Subject(char id)
{
ID = id;
}
public Subject(Location loc)
{
Location = loc;
Direction = Vector2.zero;
}
public Subject(char id, Location loc) : this(id)
{
Location = loc;
Direction = Vector2.zero;
}
public Subject(char id, Location loc, Vector2 dir) : this(id, loc)
{
Direction = dir;
}
public Subject(Subject s)
{
ID = s.ID;
Location = s.Location;
Direction = s.Direction;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
return false;
if (ReferenceEquals(this, obj))
return true;
if (obj.GetType() != this.GetType())
return false;
Subject other = obj as Subject;
return !System.Object.ReferenceEquals(null, Location)
&& ID == other.ID;
//&& System.Object.ReferenceEquals(Location, other.Location)
//&& System.Object.ReferenceEquals(Direction, other.Direction);
}
public static bool operator ==(Subject i1, Subject i2)
{
return i1.Equals(i2);
}
public static bool operator !=(Subject i1, Subject i2)
{
return !(i1 == i2);
}
public override int GetHashCode()
{
int hash = 13;
hash = (hash * 7) + ID.GetHashCode();
//hash = (hash * 7) + (!System.Object.ReferenceEquals(null, Location) ? Location.GetHashCode() : 0);
//hash = (hash * 7) + (!System.Object.ReferenceEquals(null, Direction) ? Direction.GetHashCode() : 0);
return hash;
}
}