Esempio n. 1
0
        /// <summary>
        /// Loads tiles from given stream of a data dog file.
        /// </summary>
        /// <param name="stream"></param>
        public static void Load(Stream stream)
        {
            var dataDogFile = DataDogFile.Read(stream);

            if (!dataDogFile.Lists.TryGetValue("TileList", out var objList))
            {
                throw new ArgumentException($"DataDog object list 'TileList' not found in file.");
            }

            foreach (var obj in objList.Objects)
            {
                var entry = new TileIndexEntry();

                entry.TileID        = (int)obj.Fields["TileID"].Value;
                entry.TileName      = (string)obj.Fields["TileName"].Value;
                entry.BillBoardName = (string)obj.Fields["BillBoardName"].Value;

                // Conditional reading of Property, as it doesn't exist in
                // KR281.
                if (obj.Fields.TryGetValue("Property", out var property))
                {
                    entry.Property = (byte)property.Value;
                }

                _entries[entry.TileID] = entry;
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Returns the tile with the given id via out. Returns false if
 /// the tile id doesn't exist.
 /// </summary>
 /// <param name="tileId"></param>
 /// <param name="tileIndexEntry"></param>
 /// <returns></returns>
 public static bool TryGet(int tileId, out TileIndexEntry tileIndexEntry)
 {
     return(_entries.TryGetValue(tileId, out tileIndexEntry));
 }