Example #1
0
        private int sectorWidth = 800; //default

        #endregion Fields

        #region Constructors

        public Map(MapInfo info, BlockInfo block, short instanceID)
        {
            this.MapInfo = info;
            this.Block = block;
            this.InstanceID = instanceID;
            this.Objects = new ConcurrentDictionary<ushort, MapObject>();
            this.Drops = new ConcurrentDictionary<ushort, Drop>();
            Load();
        }
Example #2
0
 public Map GetMap(MapInfo info, short instance = 0)
 {
     //lazy loading
     if (!Maps.ContainsKey(info))
     {
         Maps.Add(info, new List<Map>());
     }
     BlockInfo block;
     DataProvider.Instance.Blocks.TryGetValue(info.ID, out block);
     Map toret;
     List<Map> maps = Maps[info];
     if (maps.Count == 0)
     {
         //we load the first map instance
         maps.Add(toret = new Map(info, block, (short)maps.Count));
     }
     else
     {
         if (maps.Count < instance) // Check if instance exists, else, add another
         {
             if (maps.Count - 1 < instance)
             {
                 // ohnoes
                 Log.WriteLine(LogLevel.Info, "Couldn't find instance for map {0}", info.ID);
                 instance = 0;
             }
             else
             {
                 // Add another instance of map
                 maps.Add(toret = new Map(info, block, (short)maps.Count));
             }
         }
         toret = Maps[info][instance];
     }
     return toret;
 }
Example #3
0
 public static MapInfo Load(DataTableReaderEx reader)
 {
     MapInfo info = new MapInfo
     {
         ID = reader.GetUInt16("ID"),
         ShortName = reader.GetString("MapName"),
         FullName = reader.GetString("Name"),
         RegenX = (int)reader.GetUInt32("RegenX"),
         RegenY = (int)reader.GetUInt16("RegenY"),
         Kingdom = reader.GetByte("KingdomMap"),
         ViewRange = (ushort)reader.GetUInt32("Sight"),
     };
     return info;
 }
Example #4
0
 public static MapInfo Load(DataRow row)
 {
     MapInfo info = new MapInfo
     {
         ID = GetDataTypes.GetUshort(row["ID"]),
         ShortName = (string)row["MapName"],
         FullName = (string)row["Name"],
         RegenX = GetDataTypes.GetInt(row["RegenX"]),
         RegenY = GetDataTypes.GetInt(row["RegenY"]),
         Kingdom = GetDataTypes.GetByte(row["KingdomMap"]),
         ViewRange = GetDataTypes.GetUshort(row["Sight"]),
     };
     return info;
 }