public static ZoneList FromString(string list, Level lvl = null) { var strings = list.Split(';'); if (strings.Length == 0) { return(null); } var zoneList = new ZoneList(); foreach (var s in strings) { var str = s.Split(':'); if (str.Length != 6) { continue; } var name = str[0]; var owner = str[1]; var pos1 = str[2].Split(','); var pos2 = str[3].Split(','); var perm = byte.Parse(str[4]); var level = lvl ?? Level.FindLevel(str[5]); zoneList.Add(new Zone( new Vector3D(int.Parse(pos1[0]), int.Parse(pos1[1]), int.Parse(pos1[2])), new Vector3D(int.Parse(pos2[0]), int.Parse(pos2[1]), int.Parse(pos2[2])), owner, name, perm, level, true)); } return(zoneList); }
public static ZoneList GetAllZonesForLevel(Level level) { ZoneList zonelist = null; if (level.ExtraData.ContainsKey("zones")) { zonelist = ZoneList.FromString((string)level.ExtraData.GetIfExist("zones"), level); } if (zonelist != null) { foreach (var zone in zonelist.ToArray()) { if (!Zones.Contains(zone)) { Zones.Add(zone); } } } var zones = new ZoneList(); foreach (var zone in Zones) { if (zone.Level == level) { zones.Add(zone); } } return(zones); }
/*public static implicit operator ZoneList(string list) { var strings = list.Split(';'); if (strings.Length == 0) return null; var zoneList = new ZoneList(); foreach (var s in strings) { var str = s.Split(':'); if (str.Length != 6) continue; var name = str[0]; var owner = str[1]; var pos1 = str[2].Split(','); var pos2 = str[3].Split(','); var perm = byte.Parse(str[4]); var level = Level.FindLevel(str[5]); zoneList.Add(new Zone( new Vector3D(int.Parse(pos1[0]),int.Parse(pos1[1]),int.Parse(pos1[2])), new Vector3D(int.Parse(pos2[0]),int.Parse(pos2[1]),int.Parse(pos2[2])), owner, name, perm, level)); } return zoneList; }*/ public static ZoneList FromString(string list, Level lvl) { var strings = list.Split(';'); if (strings.Length == 0) return null; var zoneList = new ZoneList(); foreach (var s in strings) { var str = s.Split(':'); if (str.Length != 6) continue; var name = str[0]; var owner = str[1]; var pos1 = str[2].Split(','); var pos2 = str[3].Split(','); var perm = byte.Parse(str[4]); var level = lvl; zoneList.Add(new Zone( new Vector3D(int.Parse(pos1[0]), int.Parse(pos1[1]), int.Parse(pos1[2])), new Vector3D(int.Parse(pos2[0]), int.Parse(pos2[1]), int.Parse(pos2[2])), owner, name, perm, level, true)); } return zoneList; }
public static ZoneList GetAllZonesForLevel(Level level) { ZoneList zonelist = null; if (level.ExtraData.ContainsKey("zones")) { zonelist = ZoneList.FromString((string)level.ExtraData.GetIfExist("zones"), level); } if (zonelist != null) foreach (var zone in zonelist.ToArray()) { if (!Zones.Contains(zone)) Zones.Add(zone); } var zones = new ZoneList(); foreach (var zone in Zones) { if (zone.Level == level) zones.Add(zone); } return zones; }