Beispiel #1
0
        public Zone(Vector3D point1, Vector3D point2, string owner, string name, byte minimumGroup, Level level, bool skipChecks = false)
        {
            ProtectedZone = new Cuboid(point1, point2);
            Owner         = owner;
            Permission    = minimumGroup;
            Zones.Add(this);
            Level = level;
            Name  = name;

            if (skipChecks)
            {
                return;
            }
            ZoneList zones;

            if (Level.ExtraData.ContainsKey("zones"))
            {
                zones = ZoneList.FromString((string)Level.ExtraData.GetIfExist("zones"));
                zones.Add(this);
            }
            else
            {
                zones = GetAllZonesForLevel(Level);
            }
            Level.ExtraData["zones"] = zones;
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        public void Delete()
        {
            ZoneList zones;

            Zones.Remove(this);
            if (Level.ExtraData.ContainsKey("zones"))
            {
                zones = ZoneList.FromString((string)Level.ExtraData["zones"]);
                zones.Remove(this);
            }
            else
            {
                zones = GetAllZonesForLevel(Level);
            }
            Level.ExtraData["zones"] = zones;
        }
Beispiel #5
0
        public Zone(Vector3D point1, Vector3D point2, Player owner, string name, byte minimumGroup)
        {
            ProtectedZone = new Cuboid(point1, point2);
            Owner         = owner.DisplayName;
            Permission    = minimumGroup;
            Zones.Add(this);
            Level = owner.Level;
            Name  = name;

            ZoneList zones;

            if (Level.ExtraData.ContainsKey("zones"))
            {
                zones = ZoneList.FromString((string)Level.ExtraData.GetIfExist("zones"));
                zones.Add(this);
            }
            else
            {
                zones = GetAllZonesForLevel(Level);
            }
            Level.ExtraData["zones"] = zones;
        }
Beispiel #6
0
        /*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;
        }
Beispiel #7
0
        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;
        }