/// <summary> /// Loads the world map informations from the WLD file. /// </summary> private WldFileInformations LoadWld(string mapPath, string mapName) { string wldFilePath = Path.Combine(mapPath, $"{mapName}.wld"); using var wldFile = new WldFile(wldFilePath); return(wldFile.WorldInformations); }
/// <summary> /// Loads the world map informations from the WLD file. /// </summary> public void LoadWld() { string wldFilePath = Path.Combine(this._mapPath, $"{this.Name}.wld"); using (var wldFile = new WldFile(wldFilePath)) { this._worldInformations = wldFile.WorldInformations; } }
/// <summary> /// Load a map. /// </summary> public void Load() { string mapPath = Path.Combine(Global.DataPath, "maps", this.Name); string wldMapPath = Path.Combine(mapPath, this.Name + ".wld"); string dyoMapPath = Path.Combine(mapPath, this.Name + ".dyo"); string rgnMapPath = Path.Combine(mapPath, this.Name + ".rgn"); // Load .wld byte[] wldFileData = File.ReadAllBytes(wldMapPath); var wld = new WldFile(wldFileData); wld.Read(); this.Width = wld.Width; this.Length = wld.Length; // Load .dyo byte[] dyoFileData = File.ReadAllBytes(dyoMapPath); var dyo = new DyoFile(dyoFileData); dyo.Read(); foreach (NpcDyoElement dyoElement in dyo.Elements.Where(d => d is NpcDyoElement)) { this.npcs.Add(Npc.CreateFromDyo(dyoElement, this.Id)); } // Load .rgn byte[] rgnFileData = File.ReadAllBytes(rgnMapPath); var rgn = new RgnFile(rgnFileData); rgn.Read(); foreach (RgnRespawn7 rgnElement in rgn.Elements.Where(r => r is RgnRespawn7)) { var respawner = new RespawnerRegion(rgnElement.Position, rgnElement.StartPosition, rgnElement.EndPosition, rgnElement.Time); if (rgnElement.Type == 5) { for (int i = 0; i < rgnElement.Count; ++i) { var monster = new Monster(rgnElement.Model, this.Id, respawner); this.monsters.Add(monster); monster.IsSpawned = true; } } this.regions.Add(respawner); } // Load .lnd }
/// <summary> /// Parses and extracts the character models from the archive /// </summary> /// <param name="shortName">The zone shortname</param> private static void ExtractCharactersFile(string shortName) { var filePath = _settings.EverQuestDirectory + shortName + "_chr" + LanternStrings.PfsFormatExtension; var charactersS3DArchive = new PfsArchive(filePath, _logger); if (!charactersS3DArchive.Initialize()) { return; } if (_settings.ExtractWld) { PfsFile charactersWldFile = charactersS3DArchive.GetFile(shortName + "_chr" + LanternStrings.WldFormatExtension); if (charactersWldFile == null) { return; } var wld = new WldFile(charactersWldFile, shortName, WldType.Characters, _logger, _settings); if (wld.Initialize()) { wld.OutputFiles(); charactersS3DArchive.WriteAllFiles(wld.GetMaterialTypes(), "Characters/", true); } else { _logger.LogError("Unable to initialize characters WLD"); } } else { charactersS3DArchive.WriteAllFiles(); } }
/// <summary> /// Initializes and extracts files from the zone objects S3D and WLD (if specified) /// </summary> /// <param name="shortName">The zone shortname</param> private static void ExtractObjectsFile(string shortName) { var filePath = _settings.EverQuestDirectory + shortName + "_obj" + LanternStrings.PfsFormatExtension; var objectsS3DArchive = new PfsArchive(filePath, _logger); if (!objectsS3DArchive.Initialize()) { return; } if (_settings.ExtractWld) { PfsFile objectsWldFile = objectsS3DArchive.GetFile(shortName + "_obj" + LanternStrings.WldFormatExtension); if (objectsWldFile == null) { return; } var wld = new WldFile(objectsWldFile, shortName, WldType.Objects, _logger, _settings); if (wld.Initialize()) { wld.OutputFiles(); objectsS3DArchive.WriteAllFiles(wld.GetMaterialTypes(), "Objects/", true); } else { _logger.LogError("Unable to initialize objects wld"); } } else { objectsS3DArchive.WriteAllFiles(); } }
/// <summary> /// Initializes and extracts files from the main zone S3D and WLD (if specified) /// </summary> /// <param name="shortName">The zone shortname</param> private static void ExtractZoneFile(string shortName) { var filePath = _settings.EverQuestDirectory + shortName + LanternStrings.PfsFormatExtension; var zoneS3DArchive = new PfsArchive(filePath, _logger); if (!zoneS3DArchive.Initialize()) { _logger.LogError("Failed to initialize zone PFS archive!"); return; } if (_settings.ExtractWld) { PfsFile zoneWldFile = zoneS3DArchive.GetFile(shortName + LanternStrings.WldFormatExtension); if (zoneWldFile != null) { var wld = new WldFile(zoneWldFile, shortName, WldType.Zone, _logger, _settings); if (wld.Initialize()) { wld.OutputFiles(); zoneS3DArchive.WriteAllFiles(wld.GetMaterialTypes(), "Zone/", true); } else { _logger.LogError("Unable to initialize objects.wld"); } } PfsFile zoneObjectsWldFile = zoneS3DArchive.GetFile("objects" + LanternStrings.WldFormatExtension); if (zoneObjectsWldFile != null) { var wld = new WldFile(zoneObjectsWldFile, shortName, WldType.ZoneObjects, _logger, _settings); if (wld.Initialize()) { wld.OutputFiles(); } else { _logger.LogError("Unable to initialize objects.wld"); } } PfsFile zoneLightsFile = zoneS3DArchive.GetFile("lights" + LanternStrings.WldFormatExtension); if (zoneLightsFile != null) { var wld = new WldFile(zoneLightsFile, shortName, WldType.Lights, _logger, _settings); if (wld.Initialize()) { wld.OutputFiles(); } else { _logger.LogError("Unable to initialize lights.wld"); } } } else { zoneS3DArchive.WriteAllFiles(); } }