Exit.cs 1.0 KB

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