using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.Text; namespace Mapper { [DataContract] public class Area { public Area(uint entry) { Entry = entry; } [DataMember] public readonly uint Entry; [DataMember] public string Name { get; internal set; } [DataMember] public string Keyword { get; internal set; } [DataMember] public int MinLevel { get; internal set; } [DataMember] public int MaxLevel { get; internal set; } [DataMember] public int LevelLock { get; internal set; } [DataMember] public uint StartRoom { get; internal set; } [DataMember] internal List rooms = new List(); [DataMember] internal List Portals = new List(); public Room[] Rooms { get { return rooms.ToArray(); } } [DataMember] public int ExplorableRooms { get; internal set; } /// /// Get all rooms in area with this name (exact, case sensitive). /// /// Name of room. /// public List GetRooms(string Name) { List r = new List(); foreach(Room x in rooms) { if(x.Name == Name) r.Add(x); } return r; } [DataMember] internal List Flags = null; /// /// Check if area has a flag. /// /// Flag to check for. /// public bool HasFlag(string flag) { return Flags != null && Flags.Contains(flag.ToLower().Trim()); } /// /// Add a flag to area. /// /// Flag to add. public void AddFlag(string flag) { flag = flag != null ? flag.ToLower().Trim() : ""; if(Flags == null) Flags = new List(); if(!string.IsNullOrEmpty(flag) && !Flags.Contains(flag)) Flags.Add(flag); } /// /// Remove a flag from area. /// /// Flag to remove. /// public bool RemoveFlag(string flag) { flag = flag != null ? flag.ToLower().Trim() : ""; if(Flags != null && Flags.Contains(flag)) { Flags.Remove(flag); return true; } return false; } public override string ToString() { return "Area '" + (!string.IsNullOrEmpty(Name) ? Name : "NULL") + "' [" + Entry + "]"; } } }