public RoomDef()
 {
     Resets     = new List <ResetData>();
     Exits      = new ExitData[6];
     Track      = new string[5];
     TrackDir   = new short[5];
     TickTimer  = new short[MAX_RTIMER];
     ExtraDescr = new List <ExtraDescrData>();
     RoomText   = new List <RoomTextData>();
 }
        public bool TryGetExit(int index, out ExitData retVal)
        {
            if (index < 0 || index > 6)
            {
                retVal = null;
            }
            else
            {
                retVal = Exits[index];
            }

            return(retVal != null);
        }
        public static void NewLoadFromArea(StringReader sr, AreaData area)
        {
            if (area == null)
            {
                throw new Exception($"Load_resets: no #AREA seen yet.");
            }

            while (true)
            {
                var letter = sr.ReadLetter();
                if (letter != '#')
                {
                    throw new Exception("Load_rooms: # not found.");
                }

                var vnum = sr.ReadVnum();
                if (vnum == Vnum.None)
                {
                    break;
                }

                RoomDef existing;
                if (TryGetRoomDef(vnum, out existing))
                {
                    throw new Exception($"Load_rooms: vnum {vnum} duplicated.");
                }

                var rd = new RoomDef
                {
                    Area = area,
                    Vnum = vnum
                };

                rd.Name        = sr.ReadString();
                rd.Description = sr.ReadString();
                sr.ReadNumber(); // Area number
                rd.RoomFlags  = sr.ReadNumber();
                rd.SectorType = sr.ReadShort();

                while (true)
                {
                    letter = sr.ReadLetter();

                    if (letter == 'S' || letter == 's')
                    {
                        break;
                    }

                    switch (letter)
                    {
                    case 'D':
                        var door = sr.ReadNumber();
                        if (door < 0 || door > 5)
                        {
                            throw new Exception($"Fread_rooms: vnum {vnum} has bad door number.");
                        }

                        var exit = new ExitData();
                        exit.Description = sr.ReadString();
                        exit.Keyword     = sr.ReadString();
                        var locks = sr.ReadNumber();
                        exit.ExitInfo  = locks;
                        exit.RSFlags   = (ExitFlags)locks;
                        exit.Key       = sr.ReadVnum();
                        exit.Vnum      = sr.ReadVnum();
                        rd.Exits[door] = exit;
                        break;

                    case 'E':
                        var ed = new ExtraDescrData();
                        ed.Keyword     = sr.ReadString();
                        ed.Description = sr.ReadString();
                        rd.ExtraDescr.Add(ed);
                        break;

                    case 'T':
                        var rt = new RoomTextData();
                        rt.Input    = sr.ReadString();
                        rt.Output   = sr.ReadString();
                        rt.CHOutput = sr.ReadString();
                        rt.Name     = sr.ReadString();
                        rt.Type     = sr.ReadNumber();
                        rt.Power    = sr.ReadNumber();
                        rt.Mob      = sr.ReadNumber();

                        rd.RoomText.Add(rt);
                        break;

                    default:
                        throw new Exception($"Load_rooms: vnum {vnum} has flag not 'DES'.");
                    }
                }

                // TODO ?????????????????????

                //iHash = vnum % MAX_KEY_HASH;
                //pRoomIndex->next = room_index_hash[iHash];
                //room_index_hash[iHash] = pRoomIndex;
                //top_room++;
                //top_vnum_room = top_vnum_room < vnum ? vnum : top_vnum_room;
                //assign_area_vnum(vnum);
            }
        }