/// <summary>
        /// Creates a door between the two grid points
        /// </summary>
        /// <param name="p1">The grid poition 1</param>
        /// <param name="p2">The grid poition 2</param>
        /// <param name="cellId1">Cell Id of the first adjacent cell</param>
        /// <param name="cellId2">Cell Id of the second adjacent cell</param>
        /// <returns></returns>
        public CellDoor CreateDoor(IntVector p1, IntVector p2, int cellId1, int cellId2)
        {
            var key1 = new IntVector2Key(p1, p2);

            if (doorLookupCache.ContainsKey(key1))
            {
                return(doorLookupCache[key1]);
            }
            var key2 = new IntVector2Key(p2, p1);

            if (doorLookupCache.ContainsKey(key2))
            {
                return(doorLookupCache[key2]);
            }

            // Create a new door
            var door = new CellDoor();

            door.AdjacentTiles[0] = new IntVector(p1.x, p1.y, p1.z);
            door.AdjacentTiles[1] = new IntVector(p2.x, p2.y, p2.z);

            door.AdjacentCells[0] = cellId1;
            door.AdjacentCells[1] = cellId2;

            // Add to the memo lookup
            doorLookupCache.Add(key1, door);
            doorLookupCache.Add(key2, door);

            doors.Add(door);
            return(door);
        }
        public void RemoveDoor(CellDoor door)
        {
            var keysToRemove = new List <IntVector2Key>();

            foreach (var key in doorLookupCache.Keys)
            {
                if (doorLookupCache[key] == door)
                {
                    keysToRemove.Add(key);
                }
            }

            foreach (var key in keysToRemove)
            {
                doorLookupCache.Remove(key);
            }
            doors.Remove(door);
        }