Example #1
0
        /// <summary>
        /// Return <see cref="CLandBlockInfo"/>, if not already cached <see cref="CLandBlockInfo"/> will be constructed from the raw <see cref="File"/>.
        /// </summary>
        public CLandBlockInfo GetLandBlockInfo(ushort landBlockId)
        {
            File landBlockInfoFile = landBlockFiles[landBlockId].SingleOrDefault(f => f.Entry.Id == (((uint)landBlockId << 16) | 0xFFFE));

            if (landBlockInfoFile == null)
            {
                return(null);
            }

            CLandBlockInfo landBlockInfo = CacheObject <CLandBlockInfo>(landBlockInfoFile);

            for (uint i = 0; i < landBlockInfo.Cells.Length; i++)
            {
                File envCellFile = GetFile(((uint)landBlockId << 16) | (0x0100 + i));
                landBlockInfo.Cells[i] = CacheObject <CEnvCell>(envCellFile);
            }

            return(landBlockInfo);
        }
Example #2
0
        private static void GenerateLandBlockTiles(CLandBlockInfo landBlockInfo)
        {
            var sw = new StringWriter();

            sw.WriteLine($"INSERT INTO `dungeon` (`landBlockId`, `name`) VALUES ({landBlockInfo.LandBlockId}, 'Dungeon{landBlockInfo.LandBlockId:X4}');");
            sw.WriteLine("INSERT INTO `dungeon_tile` (`landBlockId`, `tileId`, `x`, `y`, `z`) VALUES");

            // 65 is just a place holder, need to match the cell environment with the 2D counterpart
            List <string> tiles = landBlockInfo.Cells
                                  .Select(c => $"({landBlockInfo.LandBlockId}, 65, {c.Position.Origin.X}, {c.Position.Origin.Y}, {c.Position.Origin.Z})")
                                  .Distinct()
                                  .ToList();

            sw.Write(string.Join($",{Environment.NewLine}", tiles));
            sw.WriteLine(";");

            System.IO.File.WriteAllText($"sql/{landBlockInfo.LandBlockId:X4}.sql", sw.ToString());
            log.Info($"{landBlockInfo.LandBlockId:X4}");
        }