| 1234567891011121314151617181920212223242526272829 |
- using System;
- using UnityEngine;
- namespace MazeGen
- {
- /// <summary>
- /// One doorway out of a Room. Exits are grid-locked to the 4 cardinal directions
- /// (0 = +X/East, 90 = +Y/North, 180 = -X/West, 270 = -Y/South), so a room can have at
- /// most one exit per side and "the door facing room X" always has a single, exact answer.
- /// Every connection between two rooms is represented by a matched pair of Exits,
- /// one on each room, pointing at each other (directly, or via an elbow hallway room).
- /// </summary>
- [Serializable]
- public class Exit
- {
- public int Id;
- public int OwnerRoomId;
- public float DirectionDegrees;
- public bool IsUsed;
- public int? ConnectedRoomId;
- public int? ConnectedExitId;
- public bool IsBlocked; // Exit is permanently unusable (e.g., no path could be generated)
- public Vector2 Direction => new Vector2(
- Mathf.Cos(DirectionDegrees * Mathf.Deg2Rad),
- Mathf.Sin(DirectionDegrees * Mathf.Deg2Rad));
- }
- }
|