Exemple #1
0
        private static void LoadIndex(GenericReader reader)
        {
            var version = reader.GetVersion();

            switch (version)
            {
            case 0:
            {
                reader.ReadBlockDictionary(r =>
                    {
                        var i = r.ReadInt();
                        var p = r.ReadMap();

                        var m = new InstanceMap(i, p, p.Name + "-INDEX", Season.Desolation, MapRules.None);

                        return(new KeyValuePair <InstanceMapSerial, InstanceMap>(m.Serial, m));
                    }, Maps);

                reader.ReadBlockDictionary(r =>
                    {
                        var s = r.ReadHashCode <DungeonSerial>();
                        var d = r.ReadTypeCreate <Dungeon>(s);

                        return(new KeyValuePair <DungeonSerial, Dungeon>(d.Serial, d));
                    }, Dungeons);
            }
            break;
            }
        }
 public void Kick(Mobile m)
 {
     if (m != null && InstanceMap != null)
     {
         InstanceMap.Kick(m);
     }
 }
        public InstanceRegion(string name, InstanceMap map, InstanceRegion parent, params Rectangle3D[] area)
            : base(name, map, parent, area)
        {
            Mobiles = new List <Mobile>();
            Items   = new List <Item>();

            Serial = new InstanceRegionSerial(Name, Map.MapIndex);

            OnCreated();
        }
        public override void OnRegister()
        {
            base.OnRegister();

            if (InstanceMap != null && !InstanceMap.Deleted)
            {
                InstanceMap.AddRegion(this, false);
            }

            AllRegions.AddOrReplace(this);
        }
        public override void OnUnregister()
        {
            base.OnUnregister();

            if (InstanceMap != null)
            {
                InstanceMap.RemoveRegion(this, false);
            }

            AllRegions.Remove(this);
            AllRegions.Free(false);
        }
        public InstanceRegion(string name, InstanceMap map, Rectangle3D[] area, GenericReader reader)
            : base(name, map, null, area)
        {
            Mobiles = new List <Mobile>();
            Items   = new List <Item>();

            Serial = new InstanceRegionSerial(Name, Map.MapIndex);

            Deserialize(reader);

            OnCreated();
        }
Exemple #7
0
 public static void WriteInstanceMap(this GenericWriter writer, InstanceMap map)
 {
     if (map != null)
     {
         writer.Write(true);
         writer.Write(map.Serial);
     }
     else
     {
         writer.Write(false);
     }
 }
        public static InstanceMap ResolveMap(Dungeon d, bool create)
        {
            if (d == null || d.Deleted)
            {
                return(null);
            }

            if (d.Map != null && !d.Map.Deleted)
            {
                return(d.Map);
            }

            InstanceMap map = null;

            foreach (var m in Maps.Values.Where(m => m != null && !m.Deleted && m.Parent == d.MapParent))
            {
                foreach (var zone in
                         m.InstanceRegions.OfType <DungeonZone>()
                         .Where(zone => !zone.Deleted && zone.Dungeon != null && !zone.Dungeon.Deleted))
                {
                    if (zone.Dungeon == d)
                    {
                        map = m;
                        break;
                    }

                    if (zone.Dungeon.ID == d.ID)
                    {
                        break;
                    }
                }

                if (map != null && !map.Deleted)
                {
                    break;
                }
            }

            if ((map == null || map.Deleted) && create)
            {
                map = CreateMap(d.MapParent, "Universe", (Season)Utility.Random(5), MapRules.FeluccaRules | MapRules.FreeMovement);

                if (map != null && !map.Deleted)
                {
                    map.Name = "Universe-" + map.MapID + "-" + map.MapIndex;
                }
            }

            return(map != null && !map.Deleted ? map : null);
        }
        public static InstanceMap CreateMap(Map parent, string name, Season season, MapRules rules)
        {
            // If the map is TerMur, use Spring or Summer to prevent static clouds from being hidden.
            if (season != Season.Spring && season != Season.Summer && parent.MapID == 5)
            {
                season = Utility.RandomList(Season.Spring, Season.Summer);
            }

            var map = new InstanceMap(parent, name, season, rules);

            if (!map.Deleted)
            {
                Maps.AddOrReplace(map.Serial, map);
            }

            return(map);
        }
Exemple #10
0
        private static bool SerializeMap(GenericWriter writer, InstanceMapSerial serial, InstanceMap map)
        {
            var version = writer.SetVersion(0);

            switch (version)
            {
            case 0:
            {
                writer.WriteBlock(w =>
                    {
                        WriteInstanceMap(w, map);

                        map.Serialize(w);
                    });
            }
            break;
            }

            return(true);
        }