public virtual void LongPointEqualsAndHashCodeItselfTest() { IntPoint lp = new IntPoint(1, 5); NUnit.Framework.Assert.IsTrue(lp.Equals(lp)); NUnit.Framework.Assert.AreEqual(lp.GetHashCode(), lp.GetHashCode()); }
public virtual void LongPointEqualsAndHashCodeToAnotherEqualPointTest() { IntPoint first = new IntPoint(1, 5); IntPoint second = new IntPoint(1, 5); NUnit.Framework.Assert.IsTrue(first.Equals(second)); NUnit.Framework.Assert.IsTrue(second.Equals(first)); NUnit.Framework.Assert.AreEqual(first.GetHashCode(), second.GetHashCode()); }
public override int GetHashCode() { return(roomName.GetHashCode() ^ localPosition.GetHashCode()); }
private HashSet <IntPoint> CalculateSightCircle() { CalculatedSightCircle.Clear(); if (Parent.BlockSight == 1) //Line casting { foreach (HashSet <IntPoint> ray in SightRays) { foreach (IntPoint p in ray) { if (Parent.BlocksSight(p.X + (int)Position.X, p.Y + (int)Position.Y)) { break; } CalculatedSightCircle.Add(p); foreach (IntPoint s in SurroundingPoints) { IntPoint sp = new IntPoint(p.X + s.X, p.Y + s.Y); if (SightCircle.Contains(sp)) { CalculatedSightCircle.Add(sp); } } } } } if (Parent.BlockSight == 2) //Path { Stack <IntPoint> scan = new Stack <IntPoint>(); HashSet <int> scanned = new HashSet <int>(); scan.Push(Position.ToIntPoint()); while (scan.Count != 0) { IntPoint current = scan.Pop(); if (CalculatedSightCircle.Add(new IntPoint(current.X - (int)Position.X, current.Y - (int)Position.Y))) { foreach (IntPoint s in SurroundingPoints) { IntPoint p = new IntPoint(current.X + s.X, current.Y + s.Y); IntPoint c = new IntPoint(p.X - (int)Position.X, p.Y - (int)Position.Y); if (scanned.Contains(c.GetHashCode()) || !SightCircle.Contains(c)) { continue; } scanned.Add(c.GetHashCode()); if (Parent.BlocksSight(p.X, p.Y)) { CalculatedSightCircle.Add(c); continue; } scan.Push(p); } } } } return(CalculatedSightCircle); }