| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using System.Collections.Generic;
- using System.Linq;
- using UnityEngine;
- namespace MazeGen
- {
- public enum RoomKind
- {
- Start,
- Normal,
- Hallway,
- Exit
- }
- /// <summary>
- /// A single node in the maze graph. Rooms are NOT tied to a grid - Position is a free
- /// world-space point derived from the exit direction + spacing of whichever exit spawned it.
- /// </summary>
- public class Room
- {
- public readonly int Id;
- public readonly RoomKind Kind;
- public readonly Vector2 Position;
- public readonly float Radius;
- public readonly int DepthFromStart;
- public readonly List<Exit> Exits = new List<Exit>();
- /// <summary>
- /// Set only on Hallway rooms created as a 90-degree elbow connector between two
- /// known doors (both straight extension and bend cases). World-space polyline the
- /// corridor should be rendered along - [doorA, corner, doorB] for a bend, or left
- /// null for hallway rooms whose far exit isn't resolved yet (ordinary lazy hallways).
- /// </summary>
- public Vector2[] CorridorWaypoints;
- /// <summary>
- /// Optional: monsters/encounter in this room (null if no encounter, or if the room
- /// hasn't been explored yet for encounter generation).
- /// </summary>
- public MonsterEncounter Encounter { get; set; }
- public Room(int id, RoomKind kind, Vector2 position, float radius, int depthFromStart)
- {
- Id = id;
- Kind = kind;
- Position = position;
- Radius = radius;
- DepthFromStart = depthFromStart;
- }
- public IEnumerable<Exit> UnusedExits => Exits.Where(e => !e.IsUsed);
- public bool HasUnusedExits => Exits.Any(e => !e.IsUsed);
- }
- }
|