using System.Collections.Generic; using System.Linq; namespace _Project.Scripts.LevelGenerating { public enum FloorKind { Generated, Special } public class FloorData { public int Index; public FloorKind Kind; public int Seed; public string SpecialId; public int SizeModules; public readonly List Rooms = new List(); public readonly Dictionary Depth = new Dictionary(); // Отрезки стен и дверные проёмы (заполняет ShellBuilder.Build) public readonly List Walls = new List(); public readonly List Doorways = new List(); public Room Start; public Room Lift; // ---------- Выборки ---------- public IEnumerable Corridors => Rooms.Where(r => r.rt == RoomType.Corridor); public IEnumerable PlayableRooms => Rooms.Where(r => r.rt != RoomType.Corridor); public IEnumerable UnassignedRooms => Rooms.Where(r => r.rt == RoomType.Undefined); public IEnumerable OfType(RoomType type) => Rooms.Where(r => r.rt == type); public int GetDepth(Room room) => Depth.TryGetValue(room, out int d) ? d : -1; // ---------- Изменение ---------- public void AddRoom(Room room, int depth) { Rooms.Add(room); Depth[room] = depth; if (room.rt == RoomType.Start) Start = room; else if (room.rt == RoomType.Lift) Lift = room; } public void AddCorridor(Room corridor) => Rooms.Add(corridor); public void Remove(Room room) { Rooms.Remove(room); Depth.Remove(room); if (Start == room) Start = null; if (Lift == room) Lift = null; } public void Clear() { Rooms.Clear(); Depth.Clear(); Walls.Clear(); Doorways.Clear(); Start = null; Lift = null; } // ---------- Фабрики ---------- public static FloorData CreateGenerated(int index, int sizeModules) => new FloorData { Index = index, Kind = FloorKind.Generated, SizeModules = sizeModules }; public static FloorData CreateSpecial(int index, string specialId) => new FloorData { Index = index, Kind = FloorKind.Special, SpecialId = specialId }; } }