From 44fa53165b4c1ab004038c6d14e1b7521972b2bb Mon Sep 17 00:00:00 2001 From: Daniel Wilkins Date: Mon, 15 Jan 2024 14:38:55 -0800 Subject: [PATCH] Cleanup naming conventions --- LanternExtractor/EQ/Archive/ArchiveBase.cs | 26 +-- LanternExtractor/EQ/Archive/PfsArchive.cs | 28 +-- LanternExtractor/EQ/Archive/T3dArchive.cs | 12 +- LanternExtractor/EQ/Sound/EnvAudio.cs | 3 +- .../EQ/Wld/DataTypes/RegionType.cs | 2 +- .../EQ/Wld/DataTypes/RenderInfo.cs | 20 +- LanternExtractor/EQ/Wld/DataTypes/UVInfo.cs | 4 +- .../EQ/Wld/Exporters/ActorObjExporter.cs | 8 +- .../EQ/Wld/Exporters/ActorWriter.cs | 24 +-- .../EQ/Wld/Exporters/ActorWriterNew.cs | 14 +- .../EQ/Wld/Exporters/ActorWriterNewGlobal.cs | 2 +- .../Wld/Exporters/AmbientLightColorWriter.cs | 14 +- .../EQ/Wld/Exporters/AnimationWriter.cs | 52 +++--- .../EQ/Wld/Exporters/BspTreeWriter.cs | 66 +++---- .../LegacyMeshIntermediateAssetWriter.cs | 176 +++++++++--------- .../EQ/Wld/Exporters/LightInstancesWriter.cs | 32 ++-- .../Exporters/MeshIntermediateAssetWriter.cs | 140 +++++++------- .../MeshIntermediateMaterialsExporter.cs | 18 +- .../EQ/Wld/Exporters/MeshObjMtlWriter.cs | 26 +-- .../EQ/Wld/Exporters/MeshObjWriter.cs | 42 ++--- .../EQ/Wld/Exporters/ObjectInstanceWriter.cs | 48 ++--- .../EQ/Wld/Exporters/ParticleSystemWriter.cs | 4 +- .../Wld/Exporters/SkeletonHierarchyWriter.cs | 56 +++--- .../EQ/Wld/Exporters/TextAssetWriter.cs | 12 +- .../EQ/Wld/Exporters/VertexColorsWriter.cs | 20 +- .../EQ/Wld/Fragments/BspRegionType.cs | 2 +- .../EQ/Wld/Fragments/Fragment07.cs | 6 +- .../EQ/Wld/Fragments/LegacyMesh.cs | 8 +- .../EQ/Wld/Fragments/ObjectInstance.cs | 2 +- .../EQ/Wld/Fragments/ParticleCloud.cs | 44 ++--- .../EQ/Wld/Fragments/ParticleSprite.cs | 4 +- .../Wld/Fragments/ParticleSpriteReference.cs | 2 +- .../EQ/Wld/Fragments/Polyhedron.cs | 2 +- LanternExtractor/EQ/Wld/WldFile.cs | 163 ++++++++-------- LanternExtractor/EQ/Wld/WldFileCharacters.cs | 26 +-- LanternExtractor/EQ/Wld/WldFileEquipment.cs | 8 +- LanternExtractor/EQ/Wld/WldFileLights.cs | 2 +- LanternExtractor/EQ/Wld/WldFileZone.cs | 6 +- LanternExtractor/EQ/Wld/WldFileZoneObjects.cs | 6 +- LanternExtractor/Infrastructure/EqBmp.cs | 12 +- 40 files changed, 569 insertions(+), 573 deletions(-) diff --git a/LanternExtractor/EQ/Archive/ArchiveBase.cs b/LanternExtractor/EQ/Archive/ArchiveBase.cs index e558697..145ea74 100644 --- a/LanternExtractor/EQ/Archive/ArchiveBase.cs +++ b/LanternExtractor/EQ/Archive/ArchiveBase.cs @@ -9,9 +9,9 @@ public abstract class ArchiveBase { public string FilePath { get; } public string FileName { get; } - protected List _files = new List(); - protected Dictionary _fileNameReference = new Dictionary(); - protected ILogger _logger; + protected List Files = new List(); + protected Dictionary FileNameReference = new Dictionary(); + protected ILogger Logger; public bool IsWldArchive { get; set; } public Dictionary FilenameChanges = new Dictionary(); @@ -19,34 +19,34 @@ protected ArchiveBase(string filePath, ILogger logger) { FilePath = filePath; FileName = Path.GetFileName(filePath); - _logger = logger; + Logger = logger; } public abstract bool Initialize(); public ArchiveFile GetFile(string fileName) { - return !_fileNameReference.ContainsKey(fileName) ? null : _fileNameReference[fileName]; + return !FileNameReference.ContainsKey(fileName) ? null : FileNameReference[fileName]; } public ArchiveFile GetFile(int index) { - if (index < 0 || index >= _files.Count) + if (index < 0 || index >= Files.Count) { return null; } - return _files[index]; + return Files[index]; } public ArchiveFile[] GetAllFiles() { - return _files.ToArray(); + return Files.ToArray(); } public void WriteAllFiles(string folder) { - foreach (var file in _files) + foreach (var file in Files) { FileWriter.WriteBytesToDisk(file.Bytes, folder, file.Name); } @@ -54,15 +54,15 @@ public void WriteAllFiles(string folder) public void RenameFile(string originalName, string newName) { - if (!_fileNameReference.ContainsKey(originalName)) + if (!FileNameReference.ContainsKey(originalName)) { return; } - var file = _fileNameReference[originalName]; - _fileNameReference.Remove(originalName); + var file = FileNameReference[originalName]; + FileNameReference.Remove(originalName); file.Name = newName; - _fileNameReference[newName] = file; + FileNameReference[newName] = file; } } } diff --git a/LanternExtractor/EQ/Archive/PfsArchive.cs b/LanternExtractor/EQ/Archive/PfsArchive.cs index a073f00..3881792 100644 --- a/LanternExtractor/EQ/Archive/PfsArchive.cs +++ b/LanternExtractor/EQ/Archive/PfsArchive.cs @@ -17,11 +17,11 @@ public PfsArchive(string filePath, ILogger logger) : base(filePath, logger) public override bool Initialize() { - _logger.LogInfo("PfsArchive: Started initialization of archive: " + FileName); + Logger.LogInfo("PfsArchive: Started initialization of archive: " + FileName); if (!File.Exists(FilePath)) { - _logger.LogError("PfsArchive: File does not exist at: " + FilePath); + Logger.LogError("PfsArchive: File does not exist at: " + FilePath); return false; } @@ -44,7 +44,7 @@ public override bool Initialize() if (offset > reader.BaseStream.Length) { - _logger.LogError("PfsArchive: Corrupted PFS length detected!"); + Logger.LogError("PfsArchive: Corrupted PFS length detected!"); return false; } @@ -62,16 +62,16 @@ public override bool Initialize() if (deflatedLength >= reader.BaseStream.Length) { - _logger.LogError("PfsArchive: Corrupted file length detected!"); + Logger.LogError("PfsArchive: Corrupted file length detected!"); return false; } byte[] compressedBytes = reader.ReadBytes((int)deflatedLength); byte[] inflatedBytes; - if (!InflateBlock(compressedBytes, (int)inflatedLength, out inflatedBytes, _logger)) + if (!InflateBlock(compressedBytes, (int)inflatedLength, out inflatedBytes, Logger)) { - _logger.LogError("PfsArchive: Error occured inflating data"); + Logger.LogError("PfsArchive: Error occured inflating data"); return false; } @@ -99,29 +99,29 @@ public override bool Initialize() continue; } - _files.Add(new PfsFile(crc, size, offset, fileBytes)); + Files.Add(new PfsFile(crc, size, offset, fileBytes)); reader.BaseStream.Position = cachedOffset; } // Sort files by offset so we can assign names - _files.Sort((x, y) => x.Offset.CompareTo(y.Offset)); + Files.Sort((x, y) => x.Offset.CompareTo(y.Offset)); // Assign file names - for (int i = 0; i < _files.Count; ++i) + for (int i = 0; i < Files.Count; ++i) { switch(pfsVersion) { case 0x10000: // PFS version 1 files do not appear to contain the filenames - if (_files[i] is PfsFile pfsFile) + if (Files[i] is PfsFile pfsFile) { pfsFile.Name = $"{pfsFile.Crc:X8}.bin"; } break; case 0x20000: - _files[i].Name = fileNames[i]; - _fileNameReference[fileNames[i]] = _files[i]; + Files[i].Name = fileNames[i]; + FileNameReference[fileNames[i]] = Files[i]; if (!IsWldArchive && fileNames[i].EndsWith(LanternStrings.WldFormatExtension)) { @@ -129,12 +129,12 @@ public override bool Initialize() } break; default: - _logger.LogError("PfsArchive: Unexpected pfs version: " + FileName); + Logger.LogError("PfsArchive: Unexpected pfs version: " + FileName); break; } } - _logger.LogInfo("PfsArchive: Finished initialization of archive: " + FileName); + Logger.LogInfo("PfsArchive: Finished initialization of archive: " + FileName); } return true; diff --git a/LanternExtractor/EQ/Archive/T3dArchive.cs b/LanternExtractor/EQ/Archive/T3dArchive.cs index 7670825..e2143cf 100644 --- a/LanternExtractor/EQ/Archive/T3dArchive.cs +++ b/LanternExtractor/EQ/Archive/T3dArchive.cs @@ -20,11 +20,11 @@ public T3dArchive(string filePath, ILogger logger) : base(filePath, logger) public override bool Initialize() { - _logger.LogInfo("T3dArchive: Started initialization of archive: " + FileName); + Logger.LogInfo("T3dArchive: Started initialization of archive: " + FileName); if (!File.Exists(FilePath)) { - _logger.LogError("T3dArchive: File does not exist at: " + FilePath); + Logger.LogError("T3dArchive: File does not exist at: " + FilePath); return false; } @@ -35,14 +35,14 @@ public override bool Initialize() var magic = reader.ReadBytes(4); if (!magic.SequenceEqual(T3dMagic)) { - _logger.LogError("T3dArchive: Incorrect file magic"); + Logger.LogError("T3dArchive: Incorrect file magic"); return false; } var version = reader.ReadBytes(4); if (!version.SequenceEqual(T3dVersion)) { - _logger.LogError("T3dArchive: Incorrect file version"); + Logger.LogError("T3dArchive: Incorrect file version"); return false; } @@ -79,8 +79,8 @@ public override bool Initialize() IsWldArchive = true; } - _files.Add(file); - _fileNameReference[file.Name] = file; + Files.Add(file); + FileNameReference[file.Name] = file; } } diff --git a/LanternExtractor/EQ/Sound/EnvAudio.cs b/LanternExtractor/EQ/Sound/EnvAudio.cs index a058fbc..52667c5 100644 --- a/LanternExtractor/EQ/Sound/EnvAudio.cs +++ b/LanternExtractor/EQ/Sound/EnvAudio.cs @@ -8,8 +8,7 @@ namespace LanternExtractor.EQ.Sound { public class EnvAudio { - public static EnvAudio Instance => _instance; - private static readonly EnvAudio _instance = new EnvAudio(); + public static EnvAudio Instance { get; } = new EnvAudio(); public EalData Data { get; private set; } diff --git a/LanternExtractor/EQ/Wld/DataTypes/RegionType.cs b/LanternExtractor/EQ/Wld/DataTypes/RegionType.cs index d0217de..41f7186 100644 --- a/LanternExtractor/EQ/Wld/DataTypes/RegionType.cs +++ b/LanternExtractor/EQ/Wld/DataTypes/RegionType.cs @@ -7,7 +7,7 @@ public enum RegionType Lava = 2, Pvp = 3, Zoneline = 4, - WaterBlockLOS = 5, + WaterBlockLos = 5, FreezingWater = 6, Slippery = 7, Unknown = 8, diff --git a/LanternExtractor/EQ/Wld/DataTypes/RenderInfo.cs b/LanternExtractor/EQ/Wld/DataTypes/RenderInfo.cs index c063cc0..0c0c340 100644 --- a/LanternExtractor/EQ/Wld/DataTypes/RenderInfo.cs +++ b/LanternExtractor/EQ/Wld/DataTypes/RenderInfo.cs @@ -13,8 +13,8 @@ public class RenderInfo public float Brightness { get; set; } public float ScaledAmbient { get; set; } public BitmapInfoReference SimpleSpriteReference { get; set; } - public UVInfo UVInfo { get; set; } - public List UVMap { get; set; } + public UvInfo UvInfo { get; set; } + public List UvMap { get; set; } public static RenderInfo Parse(BinaryReader reader, List fragments) { @@ -29,8 +29,8 @@ public static RenderInfo Parse(BinaryReader reader, List fragments) var hasBrightness = ba.IsBitSet(1); var hasScaledAmbient = ba.IsBitSet(2); var hasSimpleSprite = ba.IsBitSet(3); - var hasUVInfo = ba.IsBitSet(4); - var hasUVMap = ba.IsBitSet(5); + var hasUvInfo = ba.IsBitSet(4); + var hasUvMap = ba.IsBitSet(5); var isTwoSided = ba.IsBitSet(6); if (hasPen) @@ -54,23 +54,23 @@ public static RenderInfo Parse(BinaryReader reader, List fragments) renderInfo.SimpleSpriteReference = fragments[fragmentRef - 1] as BitmapInfoReference; } - if (hasUVInfo) + if (hasUvInfo) { - renderInfo.UVInfo = new UVInfo + renderInfo.UvInfo = new UvInfo { - UVOrigin = new vec3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()), + UvOrigin = new vec3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()), UAxis = new vec3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()), VAxis = new vec3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()) }; } - if (hasUVMap) + if (hasUvMap) { var uvMapCount = reader.ReadInt32(); - renderInfo.UVMap = new List(); + renderInfo.UvMap = new List(); for (var i = 0; i < uvMapCount; i++) { - renderInfo.UVMap.Add(new vec2(reader.ReadSingle(), reader.ReadSingle())); + renderInfo.UvMap.Add(new vec2(reader.ReadSingle(), reader.ReadSingle())); } } diff --git a/LanternExtractor/EQ/Wld/DataTypes/UVInfo.cs b/LanternExtractor/EQ/Wld/DataTypes/UVInfo.cs index 3a690c0..28cc45d 100644 --- a/LanternExtractor/EQ/Wld/DataTypes/UVInfo.cs +++ b/LanternExtractor/EQ/Wld/DataTypes/UVInfo.cs @@ -2,9 +2,9 @@ namespace LanternExtractor.EQ.Wld.DataTypes { - public class UVInfo + public class UvInfo { - public vec3 UVOrigin { get; set; } + public vec3 UvOrigin { get; set; } public vec3 UAxis { get; set; } public vec3 VAxis { get; set; } } diff --git a/LanternExtractor/EQ/Wld/Exporters/ActorObjExporter.cs b/LanternExtractor/EQ/Wld/Exporters/ActorObjExporter.cs index e881edf..80b264b 100644 --- a/LanternExtractor/EQ/Wld/Exporters/ActorObjExporter.cs +++ b/LanternExtractor/EQ/Wld/Exporters/ActorObjExporter.cs @@ -12,7 +12,7 @@ namespace LanternExtractor.EQ.Wld.Exporters { public static class ActorObjExporter { - public static Dictionary> _backupVertices = new Dictionary>(); + public static Dictionary> BackupVertices = new Dictionary>(); public static void ExportActors(WldFile wldFile, Settings settings, ILogger logger) { @@ -254,7 +254,7 @@ private static void WriteAnimationFrame(SkeletonHierarchy skeleton, string anima { foreach (var mesh in skeleton.Meshes) { - _backupVertices[mesh] = MeshExportHelper.ShiftMeshVertices(mesh, skeleton, + BackupVertices[mesh] = MeshExportHelper.ShiftMeshVertices(mesh, skeleton, wldFile.WldType == WldType.Characters, animation, frameIndex); meshWriter.AddFragmentData(mesh); } @@ -266,7 +266,7 @@ private static void WriteAnimationFrame(SkeletonHierarchy skeleton, string anima settings.ExportZoneMeshGroups, wldFile.ZoneShortname); meshWriter2.SetIsCharacterModel(true); meshWriter2.AddFragmentData(skeleton.Meshes[0]); - _backupVertices[m2] = MeshExportHelper.ShiftMeshVertices(m2, skeleton, + BackupVertices[m2] = MeshExportHelper.ShiftMeshVertices(m2, skeleton, wldFile.WldType == WldType.Characters, animation, frameIndex); meshWriter2.AddFragmentData(m2); meshWriter2.WriteAssetToFile(GetMeshPath(wldFile, FragmentNameCleaner.CleanName(skeleton), i + 1)); @@ -290,7 +290,7 @@ private static void WriteAnimationFrame(SkeletonHierarchy skeleton, string anima private static void RestoreVertices() { - foreach (var shiftedMesh in _backupVertices) + foreach (var shiftedMesh in BackupVertices) { shiftedMesh.Key.Vertices = shiftedMesh.Value; } diff --git a/LanternExtractor/EQ/Wld/Exporters/ActorWriter.cs b/LanternExtractor/EQ/Wld/Exporters/ActorWriter.cs index e673959..3e9dc83 100644 --- a/LanternExtractor/EQ/Wld/Exporters/ActorWriter.cs +++ b/LanternExtractor/EQ/Wld/Exporters/ActorWriter.cs @@ -30,30 +30,30 @@ public override void AddFragmentData(WldFragment data) if (_actorType == ActorType.Skeletal) { - _export.Append(FragmentNameCleaner.CleanName(actor)); - _export.Append(","); - _export.Append(FragmentNameCleaner.CleanName(actor.SkeletonReference.SkeletonHierarchy)); - _export.AppendLine(); + Export.Append(FragmentNameCleaner.CleanName(actor)); + Export.Append(","); + Export.Append(FragmentNameCleaner.CleanName(actor.SkeletonReference.SkeletonHierarchy)); + Export.AppendLine(); } else if (_actorType == ActorType.Static) { - _export.Append(FragmentNameCleaner.CleanName(actor)); - _export.Append(","); + Export.Append(FragmentNameCleaner.CleanName(actor)); + Export.Append(","); if (actor.MeshReference.Mesh != null) { - _export.Append(FragmentNameCleaner.CleanName(actor.MeshReference.Mesh)); + Export.Append(FragmentNameCleaner.CleanName(actor.MeshReference.Mesh)); } else if (actor.MeshReference.LegacyMesh != null) { - _export.Append(FragmentNameCleaner.CleanName(actor.MeshReference.LegacyMesh)); + Export.Append(FragmentNameCleaner.CleanName(actor.MeshReference.LegacyMesh)); } - _export.AppendLine(); + Export.AppendLine(); } else { - _export.AppendLine(FragmentNameCleaner.CleanName(actor)); + Export.AppendLine(FragmentNameCleaner.CleanName(actor)); } _actorCount++; @@ -61,7 +61,7 @@ public override void AddFragmentData(WldFragment data) public override void WriteAssetToFile(string fileName) { - if (_export.Length == 0) + if (Export.Length == 0) { return; } @@ -70,7 +70,7 @@ public override void WriteAssetToFile(string fileName) headerBuilder.AppendLine(LanternStrings.ExportHeaderTitle + "Actor List"); headerBuilder.AppendLine("# Total models: " + _actorCount); - _export.Insert(0, headerBuilder.ToString()); + Export.Insert(0, headerBuilder.ToString()); base.WriteAssetToFile(fileName); } diff --git a/LanternExtractor/EQ/Wld/Exporters/ActorWriterNew.cs b/LanternExtractor/EQ/Wld/Exporters/ActorWriterNew.cs index 095ca6b..4b2993f 100644 --- a/LanternExtractor/EQ/Wld/Exporters/ActorWriterNew.cs +++ b/LanternExtractor/EQ/Wld/Exporters/ActorWriterNew.cs @@ -15,24 +15,24 @@ public override void AddFragmentData(WldFragment data) return; } - _export.Append(actor.ActorType.ToString()); - _export.Append(","); - _export.Append(actor.ReferenceName); + Export.Append(actor.ActorType.ToString()); + Export.Append(","); + Export.Append(actor.ReferenceName); - _export.Append(FragmentNameCleaner.CleanName(actor)); - _export.AppendLine(); + Export.Append(FragmentNameCleaner.CleanName(actor)); + Export.AppendLine(); } public override void WriteAssetToFile(string fileName) { - if (_export.Length == 0) + if (Export.Length == 0) { return; } StringBuilder headerBuilder = new StringBuilder(); headerBuilder.AppendLine(LanternStrings.ExportHeaderTitle + "Actor"); - _export.Insert(0, headerBuilder.ToString()); + Export.Insert(0, headerBuilder.ToString()); base.WriteAssetToFile(fileName); } } diff --git a/LanternExtractor/EQ/Wld/Exporters/ActorWriterNewGlobal.cs b/LanternExtractor/EQ/Wld/Exporters/ActorWriterNewGlobal.cs index 8d0ba0d..38a3425 100644 --- a/LanternExtractor/EQ/Wld/Exporters/ActorWriterNewGlobal.cs +++ b/LanternExtractor/EQ/Wld/Exporters/ActorWriterNewGlobal.cs @@ -88,7 +88,7 @@ public override void WriteAssetToFile(string fileName) foreach (var o in _objects) { - _export.AppendLine(o); + Export.AppendLine(o); } //StringBuilder headerBuilder = new StringBuilder(); diff --git a/LanternExtractor/EQ/Wld/Exporters/AmbientLightColorWriter.cs b/LanternExtractor/EQ/Wld/Exporters/AmbientLightColorWriter.cs index f0d75af..22cd4c0 100644 --- a/LanternExtractor/EQ/Wld/Exporters/AmbientLightColorWriter.cs +++ b/LanternExtractor/EQ/Wld/Exporters/AmbientLightColorWriter.cs @@ -6,8 +6,8 @@ public class AmbientLightColorWriter : TextAssetWriter { public AmbientLightColorWriter() { - _export.AppendLine(LanternStrings.ExportHeaderTitle + "Ambient Light Color"); - _export.AppendLine(LanternStrings.ExportHeaderFormat + "R, G, B"); + Export.AppendLine(LanternStrings.ExportHeaderTitle + "Ambient Light Color"); + Export.AppendLine(LanternStrings.ExportHeaderFormat + "R, G, B"); } public override void AddFragmentData(WldFragment data) @@ -19,11 +19,11 @@ public override void AddFragmentData(WldFragment data) return; } - _export.Append(globalAmbientLight.Color.R.ToString()); - _export.Append(","); - _export.Append(globalAmbientLight.Color.G.ToString()); - _export.Append(","); - _export.Append(globalAmbientLight.Color.B.ToString()); + Export.Append(globalAmbientLight.Color.R.ToString()); + Export.Append(","); + Export.Append(globalAmbientLight.Color.G.ToString()); + Export.Append(","); + Export.Append(globalAmbientLight.Color.B.ToString()); } } } \ No newline at end of file diff --git a/LanternExtractor/EQ/Wld/Exporters/AnimationWriter.cs b/LanternExtractor/EQ/Wld/Exporters/AnimationWriter.cs index 6023733..019d1cb 100644 --- a/LanternExtractor/EQ/Wld/Exporters/AnimationWriter.cs +++ b/LanternExtractor/EQ/Wld/Exporters/AnimationWriter.cs @@ -10,7 +10,7 @@ public class AnimationWriter : TextAssetWriter public AnimationWriter(bool isCharacterAnimation) { - _export.AppendLine(LanternStrings.ExportHeaderTitle + "Animation"); + Export.AppendLine(LanternStrings.ExportHeaderTitle + "Animation"); _isCharacterAnimation = isCharacterAnimation; } @@ -38,9 +38,9 @@ public override void AddFragmentData(WldFragment data) Animation anim = skeleton.Animations[_targetAnimation]; - _export.AppendLine("# Animation: " + _targetAnimation); - _export.AppendLine("framecount," + anim.FrameCount); - _export.AppendLine("totalTimeMs," + anim.AnimationTimeMs); + Export.AppendLine("# Animation: " + _targetAnimation); + Export.AppendLine("framecount," + anim.FrameCount); + Export.AppendLine("totalTimeMs," + anim.AnimationTimeMs); for (int i = 0; i < skeleton.Skeleton.Count; ++i) { @@ -87,39 +87,39 @@ public override void AddFragmentData(WldFragment data) private void CreateTrackString(string fullPath, int frame, BoneTransform boneTransform, int delay) { - _export.Append(fullPath); - _export.Append(","); + Export.Append(fullPath); + Export.Append(","); - _export.Append(frame); - _export.Append(","); + Export.Append(frame); + Export.Append(","); - _export.Append(boneTransform.Translation.x); - _export.Append(","); + Export.Append(boneTransform.Translation.x); + Export.Append(","); - _export.Append(boneTransform.Translation.z); - _export.Append(","); + Export.Append(boneTransform.Translation.z); + Export.Append(","); - _export.Append(boneTransform.Translation.y); - _export.Append(","); + Export.Append(boneTransform.Translation.y); + Export.Append(","); - _export.Append(-boneTransform.Rotation.x); - _export.Append(","); + Export.Append(-boneTransform.Rotation.x); + Export.Append(","); - _export.Append(-boneTransform.Rotation.z); - _export.Append(","); + Export.Append(-boneTransform.Rotation.z); + Export.Append(","); - _export.Append(-boneTransform.Rotation.y); - _export.Append(","); + Export.Append(-boneTransform.Rotation.y); + Export.Append(","); - _export.Append(boneTransform.Rotation.w); - _export.Append(","); + Export.Append(boneTransform.Rotation.w); + Export.Append(","); - _export.Append(boneTransform.Scale); - _export.Append(","); + Export.Append(boneTransform.Scale); + Export.Append(","); - _export.Append(delay.ToString()); + Export.Append(delay.ToString()); - _export.AppendLine(); + Export.AppendLine(); } diff --git a/LanternExtractor/EQ/Wld/Exporters/BspTreeWriter.cs b/LanternExtractor/EQ/Wld/Exporters/BspTreeWriter.cs index 3446750..729c6ca 100644 --- a/LanternExtractor/EQ/Wld/Exporters/BspTreeWriter.cs +++ b/LanternExtractor/EQ/Wld/Exporters/BspTreeWriter.cs @@ -8,10 +8,10 @@ public class BspTreeWriter : TextAssetWriter { public BspTreeWriter() { - _export.AppendLine(LanternStrings.ExportHeaderTitle + "BSP Tree"); - _export.AppendLine(LanternStrings.ExportHeaderFormat + + Export.AppendLine(LanternStrings.ExportHeaderTitle + "BSP Tree"); + Export.AppendLine(LanternStrings.ExportHeaderFormat + "Normal nodes: NormalX, NormalY, NormalZ, SplitDistance, LeftNodeId, RightNodeId"); - _export.AppendLine(LanternStrings.ExportHeaderFormat + + Export.AppendLine(LanternStrings.ExportHeaderFormat + "Leaf nodes: BSPRegionId, RegionType"); } @@ -29,24 +29,24 @@ public override void AddFragmentData(WldFragment data) // Normal node if (node.Region == null) { - _export.Append(node.NormalX.ToString(_numberFormat)); - _export.Append(","); - _export.Append(node.NormalZ.ToString(_numberFormat)); - _export.Append(","); - _export.Append(node.NormalY.ToString(_numberFormat)); - _export.Append(","); - _export.Append(node.SplitDistance.ToString(_numberFormat)); - _export.Append(","); - _export.Append(node.LeftNode.ToString(_numberFormat)); - _export.Append(","); - _export.Append(node.RightNode.ToString(_numberFormat)); - _export.AppendLine(); + Export.Append(node.NormalX.ToString(NumberFormat)); + Export.Append(","); + Export.Append(node.NormalZ.ToString(NumberFormat)); + Export.Append(","); + Export.Append(node.NormalY.ToString(NumberFormat)); + Export.Append(","); + Export.Append(node.SplitDistance.ToString(NumberFormat)); + Export.Append(","); + Export.Append(node.LeftNode.ToString(NumberFormat)); + Export.Append(","); + Export.Append(node.RightNode.ToString(NumberFormat)); + Export.AppendLine(); } else // Leaf node { - _export.Append(node.RegionId.ToString(_numberFormat)); - _export.Append(","); + Export.Append(node.RegionId.ToString(NumberFormat)); + Export.Append(","); string types = string.Empty; @@ -67,11 +67,11 @@ public override void AddFragmentData(WldFragment data) types = RegionType.Normal.ToString(); } - _export.Append(types); + Export.Append(types); if (node.Region.RegionType == null) { - _export.AppendLine(); + Export.AppendLine(); continue; } @@ -81,30 +81,30 @@ public override void AddFragmentData(WldFragment data) if (zoneline != null) { - _export.Append(","); - _export.Append(zoneline.Type.ToString()); - _export.Append(","); + Export.Append(","); + Export.Append(zoneline.Type.ToString()); + Export.Append(","); if (zoneline.Type == ZonelineType.Reference) { - _export.Append(zoneline.Index); + Export.Append(zoneline.Index); } else { - _export.Append(zoneline.ZoneIndex); - _export.Append(","); - _export.Append(zoneline.Position.x); - _export.Append(","); - _export.Append(zoneline.Position.y); - _export.Append(","); - _export.Append(zoneline.Position.z); - _export.Append(","); - _export.Append(zoneline.Heading); + Export.Append(zoneline.ZoneIndex); + Export.Append(","); + Export.Append(zoneline.Position.x); + Export.Append(","); + Export.Append(zoneline.Position.y); + Export.Append(","); + Export.Append(zoneline.Position.z); + Export.Append(","); + Export.Append(zoneline.Heading); } } } - _export.AppendLine(); + Export.AppendLine(); } } } diff --git a/LanternExtractor/EQ/Wld/Exporters/LegacyMeshIntermediateAssetWriter.cs b/LanternExtractor/EQ/Wld/Exporters/LegacyMeshIntermediateAssetWriter.cs index f449624..ccdc0db 100644 --- a/LanternExtractor/EQ/Wld/Exporters/LegacyMeshIntermediateAssetWriter.cs +++ b/LanternExtractor/EQ/Wld/Exporters/LegacyMeshIntermediateAssetWriter.cs @@ -43,28 +43,28 @@ public override void AddFragmentData(WldFragment data) // TODO: polyhedron scale factor foreach(var vertex in polyhedron.Vertices) { - _export.Append("v"); - _export.Append(","); - _export.Append(vertex.x + lm.Center.x); - _export.Append(","); - _export.Append(vertex.z + lm.Center.z); - _export.Append(","); - _export.Append(vertex.y + lm.Center.y); - _export.AppendLine(); + Export.Append("v"); + Export.Append(","); + Export.Append(vertex.x + lm.Center.x); + Export.Append(","); + Export.Append(vertex.z + lm.Center.z); + Export.Append(","); + Export.Append(vertex.y + lm.Center.y); + Export.AppendLine(); } foreach(var polygon in polyhedron.Faces) { - _export.Append("i"); - _export.Append(","); - _export.Append(0); - _export.Append(","); - _export.Append(_currentBaseIndex + polygon.Vertex1); - _export.Append(","); - _export.Append(_currentBaseIndex + polygon.Vertex2); - _export.Append(","); - _export.Append(_currentBaseIndex + polygon.Vertex3); - _export.AppendLine(); + Export.Append("i"); + Export.Append(","); + Export.Append(0); + Export.Append(","); + Export.Append(_currentBaseIndex + polygon.Vertex1); + Export.Append(","); + Export.Append(_currentBaseIndex + polygon.Vertex2); + Export.Append(","); + Export.Append(_currentBaseIndex + polygon.Vertex3); + Export.AppendLine(); } return; @@ -72,45 +72,45 @@ public override void AddFragmentData(WldFragment data) if (!_isCollisionMesh && (_isFirstMesh || _useGroups)) { - _export.Append("ml"); - _export.Append(","); - _export.Append(FragmentNameCleaner.CleanName(lm.MaterialList)); - _export.AppendLine(); + Export.Append("ml"); + Export.Append(","); + Export.Append(FragmentNameCleaner.CleanName(lm.MaterialList)); + Export.AppendLine(); _isFirstMesh = false; } foreach (var vertex in lm.Vertices) { - _export.Append("v"); - _export.Append(","); - _export.Append(vertex.x + lm.Center.x); - _export.Append(","); - _export.Append(vertex.z + lm.Center.z); - _export.Append(","); - _export.Append(vertex.y + lm.Center.y); - _export.AppendLine(); + Export.Append("v"); + Export.Append(","); + Export.Append(vertex.x + lm.Center.x); + Export.Append(","); + Export.Append(vertex.z + lm.Center.z); + Export.Append(","); + Export.Append(vertex.y + lm.Center.y); + Export.AppendLine(); } foreach (var uv in lm.TexCoords) { - _export.Append("uv"); - _export.Append(","); - _export.Append(uv.x); - _export.Append(","); - _export.Append(uv.y); - _export.AppendLine(); + Export.Append("uv"); + Export.Append(","); + Export.Append(uv.x); + Export.Append(","); + Export.Append(uv.y); + Export.AppendLine(); } foreach (var normal in lm.Normals) { - _export.Append("n"); - _export.Append(","); - _export.Append(normal.x); - _export.Append(","); - _export.Append(normal.y); - _export.Append(","); - _export.Append(normal.z); - _export.AppendLine(); + Export.Append("n"); + Export.Append(","); + Export.Append(normal.x); + Export.Append(","); + Export.Append(normal.y); + Export.Append(","); + Export.Append(normal.z); + Export.AppendLine(); } int currentPolygon = 0; @@ -122,16 +122,16 @@ public override void AddFragmentData(WldFragment data) Polygon polygon = lm.Polygons[currentPolygon]; currentPolygon++; - _export.Append("i"); - _export.Append(","); - _export.Append(renderGroup.MaterialIndex); - _export.Append(","); - _export.Append(_currentBaseIndex + polygon.Vertex1); - _export.Append(","); - _export.Append(_currentBaseIndex + polygon.Vertex2); - _export.Append(","); - _export.Append(_currentBaseIndex + polygon.Vertex3); - _export.AppendLine(); + Export.Append("i"); + Export.Append(","); + Export.Append(renderGroup.MaterialIndex); + Export.Append(","); + Export.Append(_currentBaseIndex + polygon.Vertex1); + Export.Append(","); + Export.Append(_currentBaseIndex + polygon.Vertex2); + Export.Append(","); + Export.Append(_currentBaseIndex + polygon.Vertex3); + Export.AppendLine(); } } @@ -139,53 +139,53 @@ public override void AddFragmentData(WldFragment data) { foreach (var polygon in lm.Polygons) { - _export.Append("i"); - _export.Append(","); - _export.Append(polygon.MaterialIndex); - _export.Append(","); - _export.Append(_currentBaseIndex + polygon.Vertex1); - _export.Append(","); - _export.Append(_currentBaseIndex + polygon.Vertex2); - _export.Append(","); - _export.Append(_currentBaseIndex + polygon.Vertex3); - _export.AppendLine(); + Export.Append("i"); + Export.Append(","); + Export.Append(polygon.MaterialIndex); + Export.Append(","); + Export.Append(_currentBaseIndex + polygon.Vertex1); + Export.Append(","); + Export.Append(_currentBaseIndex + polygon.Vertex2); + Export.Append(","); + Export.Append(_currentBaseIndex + polygon.Vertex3); + Export.AppendLine(); } } foreach (var bone in lm.MobPieces) { - _export.Append("b"); - _export.Append(","); - _export.Append(bone.Key); - _export.Append(","); - _export.Append(bone.Value.Start); - _export.Append(","); - _export.Append(bone.Value.Count); - _export.AppendLine(); + Export.Append("b"); + Export.Append(","); + Export.Append(bone.Key); + Export.Append(","); + Export.Append(bone.Value.Start); + Export.Append(","); + Export.Append(bone.Value.Count); + Export.AppendLine(); } var animatedVertices = lm.AnimatedVerticesReference?.GetAnimatedVertices(); if (animatedVertices != null && !_isCollisionMesh) { - _export.Append("ad"); - _export.Append(","); - _export.Append(animatedVertices.Delay); - _export.AppendLine(); + Export.Append("ad"); + Export.Append(","); + Export.Append(animatedVertices.Delay); + Export.AppendLine(); for (var i = 0; i < animatedVertices.Frames.Count; i++) { foreach (vec3 position in animatedVertices.Frames[i]) { - _export.Append("av"); - _export.Append(","); - _export.Append(i); - _export.Append(","); - _export.Append(position.x + lm.Center.x); - _export.Append(","); - _export.Append(position.z + lm.Center.z); - _export.Append(","); - _export.Append(position.y + lm.Center.y); - _export.AppendLine(); + Export.Append("av"); + Export.Append(","); + Export.Append(i); + Export.Append(","); + Export.Append(position.x + lm.Center.x); + Export.Append(","); + Export.Append(position.z + lm.Center.z); + Export.Append(","); + Export.Append(position.y + lm.Center.y); + Export.AppendLine(); } } } @@ -198,12 +198,12 @@ public override void AddFragmentData(WldFragment data) public override void WriteAssetToFile(string fileName) { - if (_export.Length == 0) + if (Export.Length == 0) { return; } - _export.Insert(0, LanternStrings.ExportHeaderTitle + "Alternate Mesh Intermediate Format" + Environment.NewLine); + Export.Insert(0, LanternStrings.ExportHeaderTitle + "Alternate Mesh Intermediate Format" + Environment.NewLine); base.WriteAssetToFile(fileName); } diff --git a/LanternExtractor/EQ/Wld/Exporters/LightInstancesWriter.cs b/LanternExtractor/EQ/Wld/Exporters/LightInstancesWriter.cs index 2e23340..37a6999 100644 --- a/LanternExtractor/EQ/Wld/Exporters/LightInstancesWriter.cs +++ b/LanternExtractor/EQ/Wld/Exporters/LightInstancesWriter.cs @@ -6,8 +6,8 @@ public class LightInstancesWriter : TextAssetWriter { public LightInstancesWriter() { - _export.AppendLine(LanternStrings.ExportHeaderTitle + "Light Instances"); - _export.AppendLine(LanternStrings.ExportHeaderFormat + + Export.AppendLine(LanternStrings.ExportHeaderTitle + "Light Instances"); + Export.AppendLine(LanternStrings.ExportHeaderFormat + "PosX, PosY, PosZ, Radius, ColorR, ColorG, ColorB"); } @@ -20,20 +20,20 @@ public override void AddFragmentData(WldFragment data) return; } - _export.Append(light.Position.x.ToString(_numberFormat)); - _export.Append(","); - _export.Append(light.Position.z.ToString(_numberFormat)); - _export.Append(","); - _export.Append(light.Position.y.ToString(_numberFormat)); - _export.Append(","); - _export.Append(light.Radius.ToString(_numberFormat)); - _export.Append(","); - _export.Append(light.LightReference.LightSource.Color.r.ToString(_numberFormat)); - _export.Append(","); - _export.Append(light.LightReference.LightSource.Color.g.ToString(_numberFormat)); - _export.Append(","); - _export.Append(light.LightReference.LightSource.Color.b.ToString(_numberFormat)); - _export.AppendLine(); + Export.Append(light.Position.x.ToString(NumberFormat)); + Export.Append(","); + Export.Append(light.Position.z.ToString(NumberFormat)); + Export.Append(","); + Export.Append(light.Position.y.ToString(NumberFormat)); + Export.Append(","); + Export.Append(light.Radius.ToString(NumberFormat)); + Export.Append(","); + Export.Append(light.LightReference.LightSource.Color.r.ToString(NumberFormat)); + Export.Append(","); + Export.Append(light.LightReference.LightSource.Color.g.ToString(NumberFormat)); + Export.Append(","); + Export.Append(light.LightReference.LightSource.Color.b.ToString(NumberFormat)); + Export.AppendLine(); } } } \ No newline at end of file diff --git a/LanternExtractor/EQ/Wld/Exporters/MeshIntermediateAssetWriter.cs b/LanternExtractor/EQ/Wld/Exporters/MeshIntermediateAssetWriter.cs index 9129351..950edee 100644 --- a/LanternExtractor/EQ/Wld/Exporters/MeshIntermediateAssetWriter.cs +++ b/LanternExtractor/EQ/Wld/Exporters/MeshIntermediateAssetWriter.cs @@ -101,10 +101,10 @@ public override void AddFragmentData(WldFragment data) if (!_isCollisionMesh && (_isFirstMesh || _useGroups)) { - _export.Append("ml"); - _export.Append(","); - _export.Append(FragmentNameCleaner.CleanName(mesh.MaterialList)); - _export.AppendLine(); + Export.Append("ml"); + Export.Append(","); + Export.Append(FragmentNameCleaner.CleanName(mesh.MaterialList)); + Export.AppendLine(); _isFirstMesh = false; } @@ -116,14 +116,14 @@ public override void AddFragmentData(WldFragment data) } var vertex = mesh.Vertices[i]; - _export.Append("v"); - _export.Append(","); - _export.Append(vertex.x + mesh.Center.x); - _export.Append(","); - _export.Append(vertex.z + mesh.Center.z); - _export.Append(","); - _export.Append(vertex.y + mesh.Center.y); - _export.AppendLine(); + Export.Append("v"); + Export.Append(","); + Export.Append(vertex.x + mesh.Center.x); + Export.Append(","); + Export.Append(vertex.z + mesh.Center.z); + Export.Append(","); + Export.Append(vertex.y + mesh.Center.y); + Export.AppendLine(); } for (var i = 0; i < mesh.TextureUvCoordinates.Count; i++) @@ -134,12 +134,12 @@ public override void AddFragmentData(WldFragment data) } var textureUv = mesh.TextureUvCoordinates[i]; - _export.Append("uv"); - _export.Append(","); - _export.Append(textureUv.x); - _export.Append(","); - _export.Append(textureUv.y); - _export.AppendLine(); + Export.Append("uv"); + Export.Append(","); + Export.Append(textureUv.x); + Export.Append(","); + Export.Append(textureUv.y); + Export.AppendLine(); } for (var i = 0; i < mesh.Normals.Count; i++) @@ -150,14 +150,14 @@ public override void AddFragmentData(WldFragment data) } var normal = mesh.Normals[i]; - _export.Append("n"); - _export.Append(","); - _export.Append(normal.x); - _export.Append(","); - _export.Append(normal.y); - _export.Append(","); - _export.Append(normal.z); - _export.AppendLine(); + Export.Append("n"); + Export.Append(","); + Export.Append(normal.x); + Export.Append(","); + Export.Append(normal.y); + Export.Append(","); + Export.Append(normal.z); + Export.AppendLine(); } for (var i = 0; i < mesh.Colors.Count; i++) @@ -168,16 +168,16 @@ public override void AddFragmentData(WldFragment data) } var vertexColor = mesh.Colors[i]; - _export.Append("c"); - _export.Append(","); - _export.Append(vertexColor.B); - _export.Append(","); - _export.Append(vertexColor.G); - _export.Append(","); - _export.Append(vertexColor.R); - _export.Append(","); - _export.Append(vertexColor.A); - _export.AppendLine(); + Export.Append("c"); + Export.Append(","); + Export.Append(vertexColor.B); + Export.Append(","); + Export.Append(vertexColor.G); + Export.Append(","); + Export.Append(vertexColor.R); + Export.Append(","); + Export.Append(vertexColor.A); + Export.AppendLine(); } currentPolygon = 0; @@ -200,54 +200,54 @@ public override void AddFragmentData(WldFragment data) currentPolygon++; - _export.Append("i"); - _export.Append(","); - _export.Append(group.MaterialIndex); - _export.Append(","); - _export.Append(_currentBaseIndex + polygon.Vertex1); - _export.Append(","); - _export.Append(_currentBaseIndex + polygon.Vertex2); - _export.Append(","); - _export.Append(_currentBaseIndex + polygon.Vertex3); - _export.AppendLine(); + Export.Append("i"); + Export.Append(","); + Export.Append(group.MaterialIndex); + Export.Append(","); + Export.Append(_currentBaseIndex + polygon.Vertex1); + Export.Append(","); + Export.Append(_currentBaseIndex + polygon.Vertex2); + Export.Append(","); + Export.Append(_currentBaseIndex + polygon.Vertex3); + Export.AppendLine(); } } foreach (var bone in mesh.MobPieces) { - _export.Append("b"); - _export.Append(","); - _export.Append(bone.Key); - _export.Append(","); - _export.Append(bone.Value.Start); - _export.Append(","); - _export.Append(bone.Value.Count); - _export.AppendLine(); + Export.Append("b"); + Export.Append(","); + Export.Append(bone.Key); + Export.Append(","); + Export.Append(bone.Value.Start); + Export.Append(","); + Export.Append(bone.Value.Count); + Export.AppendLine(); } var animatedVertices = mesh.AnimatedVerticesReference?.GetAnimatedVertices(); if (animatedVertices != null && !_isCollisionMesh) { - _export.Append("ad"); - _export.Append(","); - _export.Append(animatedVertices.Delay); - _export.AppendLine(); + Export.Append("ad"); + Export.Append(","); + Export.Append(animatedVertices.Delay); + Export.AppendLine(); for (var i = 0; i < animatedVertices.Frames.Count; i++) { List frame = animatedVertices.Frames[i]; foreach (vec3 position in frame) { - _export.Append("av"); - _export.Append(","); - _export.Append(i); - _export.Append(","); - _export.Append(position.x + mesh.Center.x); - _export.Append(","); - _export.Append(position.z + mesh.Center.z); - _export.Append(","); - _export.Append(position.y + mesh.Center.y); - _export.AppendLine(); + Export.Append("av"); + Export.Append(","); + Export.Append(i); + Export.Append(","); + Export.Append(position.x + mesh.Center.x); + Export.Append(","); + Export.Append(position.z + mesh.Center.z); + Export.Append(","); + Export.Append(position.y + mesh.Center.y); + Export.AppendLine(); } } } @@ -260,12 +260,12 @@ public override void AddFragmentData(WldFragment data) public override void WriteAssetToFile(string fileName) { - if (_export.Length == 0) + if (Export.Length == 0) { return; } - _export.Insert(0, LanternStrings.ExportHeaderTitle + "Mesh Intermediate Format" + Environment.NewLine); + Export.Insert(0, LanternStrings.ExportHeaderTitle + "Mesh Intermediate Format" + Environment.NewLine); base.WriteAssetToFile(fileName); } diff --git a/LanternExtractor/EQ/Wld/Exporters/MeshIntermediateMaterialsExporter.cs b/LanternExtractor/EQ/Wld/Exporters/MeshIntermediateMaterialsExporter.cs index 12e7e4f..e894dc4 100644 --- a/LanternExtractor/EQ/Wld/Exporters/MeshIntermediateMaterialsExporter.cs +++ b/LanternExtractor/EQ/Wld/Exporters/MeshIntermediateMaterialsExporter.cs @@ -14,14 +14,14 @@ public override void AddFragmentData(WldFragment data) return; } - _export.AppendLine(LanternStrings.ExportHeaderTitle + "Material List Intermediate Format"); - _export.AppendLine(LanternStrings.ExportHeaderFormat + "Index, MaterialName, AnimationTextures, AnimationDelayMs, SkinTextures"); + Export.AppendLine(LanternStrings.ExportHeaderTitle + "Material List Intermediate Format"); + Export.AppendLine(LanternStrings.ExportHeaderFormat + "Index, MaterialName, AnimationTextures, AnimationDelayMs, SkinTextures"); for (int i = 0; i < list.Materials.Count; i++) { Material material = list.Materials[i]; - _export.Append(i); - _export.Append(","); + Export.Append(i); + Export.Append(","); List allMaterials = new List {material}; allMaterials.AddRange(list.GetMaterialVariants(material, null)); @@ -35,17 +35,17 @@ public override void AddFragmentData(WldFragment data) currentMaterial = allMaterials.First(); } - _export.Append(GetMaterialString(currentMaterial)); + Export.Append(GetMaterialString(currentMaterial)); if (j < list.VariantCount) { - _export.Append(";"); + Export.Append(";"); } } - _export.Append(","); - _export.Append(material.BitmapInfoReference?.BitmapInfo.AnimationDelayMs ?? 0); - _export.AppendLine(); + Export.Append(","); + Export.Append(material.BitmapInfoReference?.BitmapInfo.AnimationDelayMs ?? 0); + Export.AppendLine(); } } diff --git a/LanternExtractor/EQ/Wld/Exporters/MeshObjMtlWriter.cs b/LanternExtractor/EQ/Wld/Exporters/MeshObjMtlWriter.cs index c152d64..ee56690 100644 --- a/LanternExtractor/EQ/Wld/Exporters/MeshObjMtlWriter.cs +++ b/LanternExtractor/EQ/Wld/Exporters/MeshObjMtlWriter.cs @@ -52,12 +52,12 @@ public override void AddFragmentData(WldFragment data) { if(!createdNullMaterial) { - _export.AppendLine(LanternStrings.ObjNewMaterialPrefix + " " + "null"); - _export.AppendLine("Ka 1.000 1.000 1.000"); - _export.AppendLine("Kd 1.000 1.000 1.000"); - _export.AppendLine("Ks 0.000 0.000 0.000"); - _export.AppendLine("d 1.0 "); - _export.AppendLine("illum 2"); + Export.AppendLine(LanternStrings.ObjNewMaterialPrefix + " " + "null"); + Export.AppendLine("Ka 1.000 1.000 1.000"); + Export.AppendLine("Kd 1.000 1.000 1.000"); + Export.AppendLine("Ks 0.000 0.000 0.000"); + Export.AppendLine("d 1.0 "); + Export.AppendLine("illum 2"); createdNullMaterial = true; } @@ -70,13 +70,13 @@ public override void AddFragmentData(WldFragment data) continue; } - _export.AppendLine(LanternStrings.ObjNewMaterialPrefix + " " + MaterialList.GetMaterialPrefix(material.ShaderType) + material.GetFirstBitmapNameWithoutExtension()); - _export.AppendLine("Ka 1.000 1.000 1.000"); - _export.AppendLine("Kd 1.000 1.000 1.000"); - _export.AppendLine("Ks 0.000 0.000 0.000"); - _export.AppendLine("d 1.0 "); - _export.AppendLine("illum 2"); - _export.AppendLine("map_Kd " + "Textures/" + skinMaterial.GetFirstBitmapExportFilename()); + Export.AppendLine(LanternStrings.ObjNewMaterialPrefix + " " + MaterialList.GetMaterialPrefix(material.ShaderType) + material.GetFirstBitmapNameWithoutExtension()); + Export.AppendLine("Ka 1.000 1.000 1.000"); + Export.AppendLine("Kd 1.000 1.000 1.000"); + Export.AppendLine("Ks 0.000 0.000 0.000"); + Export.AppendLine("d 1.0 "); + Export.AppendLine("illum 2"); + Export.AppendLine("map_Kd " + "Textures/" + skinMaterial.GetFirstBitmapExportFilename()); } } } diff --git a/LanternExtractor/EQ/Wld/Exporters/MeshObjWriter.cs b/LanternExtractor/EQ/Wld/Exporters/MeshObjWriter.cs index 2c5cf2c..669ab95 100644 --- a/LanternExtractor/EQ/Wld/Exporters/MeshObjWriter.cs +++ b/LanternExtractor/EQ/Wld/Exporters/MeshObjWriter.cs @@ -95,17 +95,17 @@ public void AddFragmentData(WldFragment fragment, ObjectInstance associatedObjec var cosc = Math.Cos(roll); var sinc = Math.Sin(roll); - var Axx = cosa * cosb; - var Axy = cosa * sinb * sinc - sina * cosc; - var Axz = cosa * sinb * cosc + sina * sinc; + var axx = cosa * cosb; + var axy = cosa * sinb * sinc - sina * cosc; + var axz = cosa * sinb * cosc + sina * sinc; - var Ayx = sina * cosb; - var Ayy = sina * sinb * sinc + cosa * cosc; - var Ayz = sina * sinb * cosc - cosa * sinc; + var ayx = sina * cosb; + var ayy = sina * sinb * sinc + cosa * cosc; + var ayz = sina * sinb * cosc - cosa * sinc; - var Azx = -sinb; - var Azy = cosb * sinc; - var Azz = cosb * cosc; + var azx = -sinb; + var azy = cosb * sinc; + var azz = cosb * cosc; if (mesh == null) { @@ -125,13 +125,13 @@ public void AddFragmentData(WldFragment fragment, ObjectInstance associatedObjec name = LanternStrings.ObjMaterialHeader + _forcedMeshList + ".mtl"; } - _export.AppendLine(name); + Export.AppendLine(name); _isFirstMesh = false; } if (_exportGroups) { - _export.AppendLine("g " + FragmentNameCleaner.CleanName(mesh)); + Export.AppendLine("g " + FragmentNameCleaner.CleanName(mesh)); } if (mesh.ExportSeparateCollision) @@ -317,14 +317,14 @@ public void AddFragmentData(WldFragment fragment, ObjectInstance associatedObjec var py = vertex.y; var pz = vertex.z; - float x = (float)(Axx * px + Axy * py + Axz * pz); - float y = (float)(Ayx * px + Ayy * py + Ayz * pz); - float z = (float)(Azx * px + Azy * py + Azz * pz); + float x = (float)(axx * px + axy * py + axz * pz); + float y = (float)(ayx * px + ayy * py + ayz * pz); + float z = (float)(azx * px + azy * py + azz * pz); vertex = new vec3(x, y, z); } - vertexOutput.AppendLine("v " + (-(vertex.x + mesh.Center.x + offset.x)).ToString(_numberFormat) + " " + - (vertex.z + mesh.Center.z + offset.z).ToString(_numberFormat) + " " + - (vertex.y + mesh.Center.y + offset.y).ToString(_numberFormat)); + vertexOutput.AppendLine("v " + (-(vertex.x + mesh.Center.x + offset.x)).ToString(NumberFormat) + " " + + (vertex.z + mesh.Center.z + offset.z).ToString(NumberFormat) + " " + + (vertex.y + mesh.Center.y + offset.y).ToString(NumberFormat)); if (_objExportType == ObjExportType.Collision) { @@ -339,8 +339,8 @@ public void AddFragmentData(WldFragment fragment, ObjectInstance associatedObjec } vec2 vertexUvs = mesh.TextureUvCoordinates[usedVertex]; - vertexOutput.AppendLine("vt " + vertexUvs.x.ToString(_numberFormat) + " " + - vertexUvs.y.ToString(_numberFormat)); + vertexOutput.AppendLine("vt " + vertexUvs.x.ToString(NumberFormat) + " " + + vertexUvs.y.ToString(NumberFormat)); } frames.Add(vertexOutput.ToString() + faceOutput); @@ -351,7 +351,7 @@ public void AddFragmentData(WldFragment fragment, ObjectInstance associatedObjec { if (i == 0) { - _export.Append(frames[i]); + Export.Append(frames[i]); } else { @@ -382,7 +382,7 @@ public void WriteAllFrames(string fileName) for (int i = 1; i < _frames.Count; ++i) { - _export = _frames[i]; + Export = _frames[i]; WriteAssetToFile(fileName.Replace(".obj", "") + "_frame" + i + ".obj"); } } diff --git a/LanternExtractor/EQ/Wld/Exporters/ObjectInstanceWriter.cs b/LanternExtractor/EQ/Wld/Exporters/ObjectInstanceWriter.cs index 881f461..8fc4942 100644 --- a/LanternExtractor/EQ/Wld/Exporters/ObjectInstanceWriter.cs +++ b/LanternExtractor/EQ/Wld/Exporters/ObjectInstanceWriter.cs @@ -7,8 +7,8 @@ public class ObjectInstanceWriter : TextAssetWriter public ObjectInstanceWriter() { - _export.AppendLine(LanternStrings.ExportHeaderTitle + "Object Instances"); - _export.AppendLine(LanternStrings.ExportHeaderFormat + + Export.AppendLine(LanternStrings.ExportHeaderTitle + "Object Instances"); + Export.AppendLine(LanternStrings.ExportHeaderFormat + "ModelName, PosX, PosY, PosZ, RotX, RotY, RotZ, ScaleX, ScaleY, ScaleZ, ColorIndex"); } @@ -21,29 +21,29 @@ public override void AddFragmentData(WldFragment data) return; } - _export.Append(instance.ObjectName); - _export.Append(","); - _export.Append(instance.Position.x.ToString(_numberFormat)); - _export.Append(","); - _export.Append(instance.Position.z.ToString(_numberFormat)); - _export.Append(","); - _export.Append(instance.Position.y.ToString(_numberFormat)); - _export.Append(","); - _export.Append(instance.Rotation.x.ToString(_numberFormat)); - _export.Append(","); - _export.Append(instance.Rotation.z.ToString(_numberFormat)); - _export.Append(","); - _export.Append(instance.Rotation.y.ToString(_numberFormat)); - _export.Append(","); - _export.Append(instance.Scale.x.ToString(_numberFormat)); - _export.Append(","); - _export.Append(instance.Scale.y.ToString(_numberFormat)); - _export.Append(","); - _export.Append(instance.Scale.z.ToString(_numberFormat)); - _export.Append(","); - _export.Append(instance.Colors == null ? -1 :instance.Colors.Index); + Export.Append(instance.ObjectName); + Export.Append(","); + Export.Append(instance.Position.x.ToString(NumberFormat)); + Export.Append(","); + Export.Append(instance.Position.z.ToString(NumberFormat)); + Export.Append(","); + Export.Append(instance.Position.y.ToString(NumberFormat)); + Export.Append(","); + Export.Append(instance.Rotation.x.ToString(NumberFormat)); + Export.Append(","); + Export.Append(instance.Rotation.z.ToString(NumberFormat)); + Export.Append(","); + Export.Append(instance.Rotation.y.ToString(NumberFormat)); + Export.Append(","); + Export.Append(instance.Scale.x.ToString(NumberFormat)); + Export.Append(","); + Export.Append(instance.Scale.y.ToString(NumberFormat)); + Export.Append(","); + Export.Append(instance.Scale.z.ToString(NumberFormat)); + Export.Append(","); + Export.Append(instance.Colors == null ? -1 :instance.Colors.Index); - _export.AppendLine(); + Export.AppendLine(); } } } \ No newline at end of file diff --git a/LanternExtractor/EQ/Wld/Exporters/ParticleSystemWriter.cs b/LanternExtractor/EQ/Wld/Exporters/ParticleSystemWriter.cs index 75f30a9..afb5f68 100644 --- a/LanternExtractor/EQ/Wld/Exporters/ParticleSystemWriter.cs +++ b/LanternExtractor/EQ/Wld/Exporters/ParticleSystemWriter.cs @@ -7,7 +7,7 @@ public class ParticleSystemWriter : TextAssetWriter { public ParticleSystemWriter() { - _export.AppendLine(LanternStrings.ExportHeaderTitle + "Particle System"); + Export.AppendLine(LanternStrings.ExportHeaderTitle + "Particle System"); } public override void AddFragmentData(WldFragment data) @@ -17,7 +17,7 @@ public override void AddFragmentData(WldFragment data) return; } - _export.AppendLine(FragmentNameCleaner.CleanName(data)); + Export.AppendLine(FragmentNameCleaner.CleanName(data)); } } } \ No newline at end of file diff --git a/LanternExtractor/EQ/Wld/Exporters/SkeletonHierarchyWriter.cs b/LanternExtractor/EQ/Wld/Exporters/SkeletonHierarchyWriter.cs index d178b24..29d4527 100644 --- a/LanternExtractor/EQ/Wld/Exporters/SkeletonHierarchyWriter.cs +++ b/LanternExtractor/EQ/Wld/Exporters/SkeletonHierarchyWriter.cs @@ -15,8 +15,8 @@ public SkeletonHierarchyWriter(bool stripModelBase) public override void AddFragmentData(WldFragment data) { - _export.AppendLine(LanternStrings.ExportHeaderTitle + "Skeleton Hierarchy"); - _export.AppendLine(LanternStrings.ExportHeaderFormat + "BoneName, Children, Mesh, AlternateMesh, ParticleCloud"); + Export.AppendLine(LanternStrings.ExportHeaderTitle + "Skeleton Hierarchy"); + Export.AppendLine(LanternStrings.ExportHeaderFormat + "BoneName, Children, Mesh, AlternateMesh, ParticleCloud"); SkeletonHierarchy skeleton = data as SkeletonHierarchy; @@ -27,42 +27,42 @@ public override void AddFragmentData(WldFragment data) if (skeleton.Meshes != null && skeleton.Meshes.Count != 0) { - _export.Append("meshes"); + Export.Append("meshes"); foreach (var mesh in skeleton.Meshes) { - _export.Append(","); - _export.Append(FragmentNameCleaner.CleanName(mesh)); + Export.Append(","); + Export.Append(FragmentNameCleaner.CleanName(mesh)); } - _export.AppendLine(); + Export.AppendLine(); - _export.Append("secondary_meshes"); + Export.Append("secondary_meshes"); foreach (var mesh in skeleton.SecondaryMeshes) { - _export.Append(","); - _export.Append(FragmentNameCleaner.CleanName(mesh)); + Export.Append(","); + Export.Append(FragmentNameCleaner.CleanName(mesh)); } - _export.AppendLine(); + Export.AppendLine(); } if (skeleton.AlternateMeshes != null && skeleton.AlternateMeshes.Count != 0) { - _export.Append("meshes"); + Export.Append("meshes"); foreach (var mesh in skeleton.AlternateMeshes) { - _export.Append(","); - _export.Append(FragmentNameCleaner.CleanName(mesh)); + Export.Append(","); + Export.Append(FragmentNameCleaner.CleanName(mesh)); } - _export.AppendLine(); + Export.AppendLine(); - _export.Append("secondary_meshes"); + Export.Append("secondary_meshes"); foreach (var mesh in skeleton.SecondaryAlternateMeshes) { - _export.Append(","); - _export.Append(FragmentNameCleaner.CleanName(mesh)); + Export.Append(","); + Export.Append(FragmentNameCleaner.CleanName(mesh)); } - _export.AppendLine(); + Export.AppendLine(); } foreach (var node in skeleton.Skeleton) @@ -86,32 +86,32 @@ public override void AddFragmentData(WldFragment data) boneName = StripModelBase(boneName, skeleton.ModelBase); } - _export.Append(CleanSkeletonNodeName(boneName)); - _export.Append(","); - _export.Append(childrenList); + Export.Append(CleanSkeletonNodeName(boneName)); + Export.Append(","); + Export.Append(childrenList); - _export.Append(","); + Export.Append(","); if (node.MeshReference?.Mesh != null) { - _export.Append(FragmentNameCleaner.CleanName(node.MeshReference.Mesh)); + Export.Append(FragmentNameCleaner.CleanName(node.MeshReference.Mesh)); } - _export.Append(","); + Export.Append(","); if (node.MeshReference?.LegacyMesh != null) { - _export.Append(FragmentNameCleaner.CleanName(node.MeshReference.LegacyMesh)); + Export.Append(FragmentNameCleaner.CleanName(node.MeshReference.LegacyMesh)); } - _export.Append(","); + Export.Append(","); if (node.ParticleCloud != null) { - _export.Append(FragmentNameCleaner.CleanName(node.ParticleCloud)); + Export.Append(FragmentNameCleaner.CleanName(node.ParticleCloud)); } - _export.AppendLine(); + Export.AppendLine(); } } diff --git a/LanternExtractor/EQ/Wld/Exporters/TextAssetWriter.cs b/LanternExtractor/EQ/Wld/Exporters/TextAssetWriter.cs index c313af8..225753e 100644 --- a/LanternExtractor/EQ/Wld/Exporters/TextAssetWriter.cs +++ b/LanternExtractor/EQ/Wld/Exporters/TextAssetWriter.cs @@ -7,8 +7,8 @@ namespace LanternExtractor.EQ.Wld.Exporters { public abstract class TextAssetWriter { - protected StringBuilder _export = new StringBuilder(); - protected NumberFormatInfo _numberFormat = new NumberFormatInfo {NumberDecimalSeparator = "."}; + protected StringBuilder Export = new StringBuilder(); + protected NumberFormatInfo NumberFormat = new NumberFormatInfo {NumberDecimalSeparator = "."}; public abstract void AddFragmentData(WldFragment data); @@ -21,24 +21,24 @@ public virtual void WriteAssetToFile(string fileName) return; } - if (_export.Length == 0) + if (Export.Length == 0) { return; } Directory.CreateDirectory(directory); - File.WriteAllText(fileName, _export.ToString()); + File.WriteAllText(fileName, Export.ToString()); } public virtual void ClearExportData() { - _export.Clear(); + Export.Clear(); } public int GetExportByteCount() { - return _export.ToString().Length; + return Export.ToString().Length; } } } \ No newline at end of file diff --git a/LanternExtractor/EQ/Wld/Exporters/VertexColorsWriter.cs b/LanternExtractor/EQ/Wld/Exporters/VertexColorsWriter.cs index 4b04041..a1646f4 100644 --- a/LanternExtractor/EQ/Wld/Exporters/VertexColorsWriter.cs +++ b/LanternExtractor/EQ/Wld/Exporters/VertexColorsWriter.cs @@ -12,8 +12,8 @@ public VertexColorsWriter() private void AddHeader() { - _export.AppendLine(LanternStrings.ExportHeaderTitle + "Vertex Colors"); - _export.AppendLine(LanternStrings.ExportHeaderFormat + + Export.AppendLine(LanternStrings.ExportHeaderTitle + "Vertex Colors"); + Export.AppendLine(LanternStrings.ExportHeaderFormat + "Red, Green, Blue, Sunlight"); } @@ -28,14 +28,14 @@ public override void AddFragmentData(WldFragment data) foreach (Color color in instance.Colors) { - _export.Append(color.R); - _export.Append(","); - _export.Append(color.G); - _export.Append(","); - _export.Append(color.B); - _export.Append(","); - _export.Append(color.A); - _export.AppendLine(); + Export.Append(color.R); + Export.Append(","); + Export.Append(color.G); + Export.Append(","); + Export.Append(color.B); + Export.Append(","); + Export.Append(color.A); + Export.AppendLine(); } } diff --git a/LanternExtractor/EQ/Wld/Fragments/BspRegionType.cs b/LanternExtractor/EQ/Wld/Fragments/BspRegionType.cs index efeed23..4cb3ab8 100644 --- a/LanternExtractor/EQ/Wld/Fragments/BspRegionType.cs +++ b/LanternExtractor/EQ/Wld/Fragments/BspRegionType.cs @@ -94,7 +94,7 @@ public override void Initialize(int index, int size, byte[] data, else if (regionTypeString.StartsWith("sln_")) { // gukbottom, cazicthule (gumdrop), runnyeye, velketor - RegionTypes.Add(RegionType.WaterBlockLOS); + RegionTypes.Add(RegionType.WaterBlockLos); } else if (regionTypeString.StartsWith("vwn_")) { diff --git a/LanternExtractor/EQ/Wld/Fragments/Fragment07.cs b/LanternExtractor/EQ/Wld/Fragments/Fragment07.cs index fcb3cde..7a98e7b 100644 --- a/LanternExtractor/EQ/Wld/Fragments/Fragment07.cs +++ b/LanternExtractor/EQ/Wld/Fragments/Fragment07.cs @@ -11,15 +11,15 @@ namespace LanternExtractor.EQ.Wld.Fragments /// public class Fragment07 : WldFragment { - private Fragment06 Fragment06; + private Fragment06 _fragment06; public override void Initialize(int index, int size, byte[] data, List fragments, Dictionary stringHash, bool isNewWldFormat, ILogger logger) { base.Initialize(index, size, data, fragments, stringHash, isNewWldFormat, logger); Name = stringHash[-Reader.ReadInt32()]; - Fragment06 = fragments[Reader.ReadInt32() - 1] as Fragment06; - int value_08 = Reader.ReadInt32(); // always 0 + _fragment06 = fragments[Reader.ReadInt32() - 1] as Fragment06; + int value08 = Reader.ReadInt32(); // always 0 } } } \ No newline at end of file diff --git a/LanternExtractor/EQ/Wld/Fragments/LegacyMesh.cs b/LanternExtractor/EQ/Wld/Fragments/LegacyMesh.cs index 43f8aca..afd736b 100644 --- a/LanternExtractor/EQ/Wld/Fragments/LegacyMesh.cs +++ b/LanternExtractor/EQ/Wld/Fragments/LegacyMesh.cs @@ -63,7 +63,7 @@ public override void Initialize(int index, int size, byte[] data, List _zoneName; + public string ZoneShortname => ZoneName; - - public WldType WldType => _wldType; + /// + /// The type of WLD file this is + /// + public WldType WldType { get; } /// /// A link of indices to fragments /// - protected List _fragments; + protected List Fragments; /// /// The string has containing the index in the hash and the decoded string that is there @@ -37,29 +39,24 @@ public abstract class WldFile /// A collection of fragment lists that can be referenced by a fragment type /// //protected Dictionary> _fragmentTypeDictionary; - protected Dictionary> _fragmentTypeDictionary; + protected Dictionary> FragmentTypeDictionary; /// /// A collection of fragment lists that can be referenced by a fragment type /// - protected Dictionary _fragmentNameDictionary; + protected Dictionary FragmentNameDictionary; - protected List _bspRegions; + protected List BspRegions; /// /// The shortname of the zone this WLD is from /// - protected readonly string _zoneName; + protected readonly string ZoneName; /// /// The logger to use to output WLD information /// - protected readonly ILogger _logger; - - /// - /// The type of WLD file this is - /// - protected readonly WldType _wldType; + protected readonly ILogger Logger; /// /// The WLD file found in the archive @@ -69,14 +66,14 @@ public abstract class WldFile /// /// Cached settings /// - protected readonly Settings _settings; + protected readonly Settings Settings; /// /// Is this the new WLD format? Some data types are different /// private bool _isNewWldFormat; - protected readonly WldFile _wldToInject; + protected readonly WldFile WldToInject; public Dictionary FilenameChanges = new Dictionary(); @@ -92,11 +89,11 @@ protected WldFile(ArchiveFile wldFile, string zoneName, WldType type, ILogger lo WldFile fileToInject) { _wldFile = wldFile; - _zoneName = zoneName.ToLower(); - _wldType = type; - _logger = logger; - _settings = settings; - _wldToInject = fileToInject; + ZoneName = zoneName.ToLower(); + WldType = type; + Logger = logger; + Settings = settings; + WldToInject = fileToInject; } /// @@ -105,14 +102,14 @@ protected WldFile(ArchiveFile wldFile, string zoneName, WldType type, ILogger lo public virtual bool Initialize(string rootFolder, bool exportData = true) { RootExportFolder = rootFolder; - _logger.LogInfo("Extracting WLD archive: " + _wldFile.Name); - _logger.LogInfo("-----------------------------------"); - _logger.LogInfo("WLD type: " + _wldType); + Logger.LogInfo("Extracting WLD archive: " + _wldFile.Name); + Logger.LogInfo("-----------------------------------"); + Logger.LogInfo("WLD type: " + WldType); - _fragments = new List(); - _fragmentTypeDictionary = new Dictionary>(); - _fragmentNameDictionary = new Dictionary(); - _bspRegions = new List(); + Fragments = new List(); + FragmentTypeDictionary = new Dictionary>(); + FragmentNameDictionary = new Dictionary(); + BspRegions = new List(); var reader = new BinaryReader(new MemoryStream(_wldFile.Bytes)); @@ -124,7 +121,7 @@ public virtual bool Initialize(string rootFolder, bool exportData = true) if (identifier != WldIdentifier.WldFileIdentifier) { - _logger.LogError("Not a valid WLD file!"); + Logger.LogError("Not a valid WLD file!"); return false; } @@ -136,10 +133,10 @@ public virtual bool Initialize(string rootFolder, bool exportData = true) break; case WldIdentifier.WldFormatNewIdentifier: _isNewWldFormat = true; - _logger.LogWarning("New WLD format not fully supported."); + Logger.LogWarning("New WLD format not fully supported."); break; default: - _logger.LogError("Unrecognized WLD format."); + Logger.LogError("Unrecognized WLD format."); return false; } @@ -165,31 +162,31 @@ public virtual bool Initialize(string rootFolder, bool exportData = true) if (newFragment is Generic) { - _logger.LogWarning($"WldFile: Unhandled fragment type: {fragId:x}"); + Logger.LogWarning($"WldFile: Unhandled fragment type: {fragId:x}"); } - newFragment.Initialize(i, (int)fragSize, reader.ReadBytes((int)fragSize), _fragments, _stringHash, + newFragment.Initialize(i, (int)fragSize, reader.ReadBytes((int)fragSize), Fragments, _stringHash, _isNewWldFormat, - _logger); - newFragment.OutputInfo(_logger); + Logger); + newFragment.OutputInfo(Logger); - _fragments.Add(newFragment); + Fragments.Add(newFragment); - if (!_fragmentTypeDictionary.ContainsKey(newFragment.GetType())) + if (!FragmentTypeDictionary.ContainsKey(newFragment.GetType())) { - _fragmentTypeDictionary[newFragment.GetType()] = new List(); + FragmentTypeDictionary[newFragment.GetType()] = new List(); } - if (!string.IsNullOrEmpty(newFragment.Name) && !_fragmentNameDictionary.ContainsKey(newFragment.Name)) + if (!string.IsNullOrEmpty(newFragment.Name) && !FragmentNameDictionary.ContainsKey(newFragment.Name)) { - _fragmentNameDictionary[newFragment.Name] = newFragment; + FragmentNameDictionary[newFragment.Name] = newFragment; } - _fragmentTypeDictionary[newFragment.GetType()].Add(newFragment); + FragmentTypeDictionary[newFragment.GetType()].Add(newFragment); } - _logger.LogInfo("-----------------------------------"); - _logger.LogInfo("WLD extraction complete"); + Logger.LogInfo("-----------------------------------"); + Logger.LogInfo("WLD extraction complete"); ProcessData(); @@ -203,22 +200,22 @@ public virtual bool Initialize(string rootFolder, bool exportData = true) public List GetFragmentsOfType() where T : WldFragment { - if (!_fragmentTypeDictionary.ContainsKey(typeof(T))) + if (!FragmentTypeDictionary.ContainsKey(typeof(T))) { return new List(); } - return _fragmentTypeDictionary[typeof(T)].Cast().ToList(); + return FragmentTypeDictionary[typeof(T)].Cast().ToList(); } public T GetFragmentByName(string fragmentName) where T : WldFragment { - if (!_fragmentNameDictionary.ContainsKey(fragmentName)) + if (!FragmentNameDictionary.ContainsKey(fragmentName)) { return default(T); } - return _fragmentNameDictionary[fragmentName] as T; + return FragmentNameDictionary[fragmentName] as T; } protected virtual void ProcessData() @@ -250,7 +247,7 @@ public virtual void ExportData() { ExportMeshes(); - if (_settings.ModelExportFormat == ModelExportFormat.Intermediate) + if (Settings.ModelExportFormat == ModelExportFormat.Intermediate) { ExportActors(); ExportSkeletonAndAnimations(); @@ -267,7 +264,7 @@ public List GetMaskedBitmaps() if (materialLists.Count == 0) { - _logger.LogWarning("Cannot get material types. No texture list found."); + Logger.LogWarning("Cannot get material types. No texture list found."); return null; } @@ -304,37 +301,37 @@ public List GetMaskedBitmaps() private void ExportMeshes() { - if (_settings.ModelExportFormat == ModelExportFormat.Intermediate) + if (Settings.ModelExportFormat == ModelExportFormat.Intermediate) { - MeshExporter.ExportMeshes(this, _settings, _logger); + MeshExporter.ExportMeshes(this, Settings, Logger); } - else if (_settings.ModelExportFormat == ModelExportFormat.Obj) + else if (Settings.ModelExportFormat == ModelExportFormat.Obj) { - ActorObjExporter.ExportActors(this, _settings, _logger); + ActorObjExporter.ExportActors(this, Settings, Logger); } else { - ActorGltfExporter.ExportActors(this, _settings, _logger); + ActorGltfExporter.ExportActors(this, Settings, Logger); } } public string GetExportFolderForWldType() { - switch (_wldType) + switch (WldType) { - case WldType.Zone: - case WldType.Lights: - case WldType.ZoneObjects: + case Wld.WldType.Zone: + case Wld.WldType.Lights: + case Wld.WldType.ZoneObjects: return GetRootExportFolder() + "/Zone/"; - case WldType.Equipment: + case Wld.WldType.Equipment: return GetRootExportFolder(); - case WldType.Objects: + case Wld.WldType.Objects: return GetRootExportFolder() + "Objects/"; - case WldType.Sky: + case Wld.WldType.Sky: return GetRootExportFolder(); - case WldType.Characters: - if (_settings.ExportCharactersToSingleFolder && - _settings.ModelExportFormat == ModelExportFormat.Intermediate) + case Wld.WldType.Characters: + if (Settings.ExportCharactersToSingleFolder && + Settings.ModelExportFormat == ModelExportFormat.Intermediate) { return GetRootExportFolder(); } @@ -349,16 +346,16 @@ public string GetExportFolderForWldType() protected string GetRootExportFolder() { - switch (_wldType) + switch (WldType) { - case WldType.Equipment when _settings.ExportEquipmentToSingleFolder && - _settings.ModelExportFormat == ModelExportFormat.Intermediate: + case Wld.WldType.Equipment when Settings.ExportEquipmentToSingleFolder && + Settings.ModelExportFormat == ModelExportFormat.Intermediate: return RootExportFolder + "equipment/"; - case WldType.Characters when (_settings.ExportCharactersToSingleFolder && - _settings.ModelExportFormat == ModelExportFormat.Intermediate): + case Wld.WldType.Characters when (Settings.ExportCharactersToSingleFolder && + Settings.ModelExportFormat == ModelExportFormat.Intermediate): return RootExportFolder + "characters/"; default: - return RootExportFolder + ShortnameHelper.GetCorrectZoneShortname(_zoneName) + "/"; + return RootExportFolder + ShortnameHelper.GetCorrectZoneShortname(ZoneName) + "/"; } } @@ -366,9 +363,9 @@ private void ExportActors() { var actors = GetFragmentsOfType(); - if (_wldToInject != null) + if (WldToInject != null) { - actors.AddRange(_wldToInject.GetFragmentsOfType()); + actors.AddRange(WldToInject.GetFragmentsOfType()); } if (actors.Count == 0) @@ -378,9 +375,9 @@ private void ExportActors() TextAssetWriter actorWriterStatic, actorWriterSkeletal, actorWriterParticle, actorWriterSprite2d; - if (_wldType == WldType.Equipment && _settings.ExportEquipmentToSingleFolder || _wldType == WldType.Characters) + if (WldType == Wld.WldType.Equipment && Settings.ExportEquipmentToSingleFolder || WldType == Wld.WldType.Characters) { - bool isCharacters = _wldType == WldType.Characters; + bool isCharacters = WldType == Wld.WldType.Characters; actorWriterStatic = new ActorWriterNewGlobal(ActorType.Static, GetExportFolderForWldType()); actorWriterSkeletal = new ActorWriterNewGlobal(ActorType.Skeletal, GetExportFolderForWldType()); actorWriterParticle = new ActorWriterNewGlobal(ActorType.Particle, GetExportFolderForWldType()); @@ -418,23 +415,23 @@ protected void ExportSkeletonAndAnimations() if (skeletons.Count == 0) { - if (_wldToInject == null) + if (WldToInject == null) { - _logger.LogWarning("Cannot export animations. No model references."); + Logger.LogWarning("Cannot export animations. No model references."); return; } - skeletons = _wldToInject.GetFragmentsOfType(); + skeletons = WldToInject.GetFragmentsOfType(); if (skeletons == null) { - _logger.LogWarning("Cannot export animations 2. No model references."); + Logger.LogWarning("Cannot export animations 2. No model references."); return; } } - SkeletonHierarchyWriter skeletonWriter = new SkeletonHierarchyWriter(_wldType == WldType.Characters); - AnimationWriter animationWriter = new AnimationWriter(_wldType == WldType.Characters); + SkeletonHierarchyWriter skeletonWriter = new SkeletonHierarchyWriter(WldType == Wld.WldType.Characters); + AnimationWriter animationWriter = new AnimationWriter(WldType == Wld.WldType.Characters); foreach (var skeleton in skeletons) { @@ -443,7 +440,7 @@ protected void ExportSkeletonAndAnimations() skeletonWriter.AddFragmentData(skeleton); // TODO: Put this elsewhere - what does this even do? - if (_wldType == WldType.Characters && _settings.ExportCharactersToSingleFolder) + if (WldType == Wld.WldType.Characters && Settings.ExportCharactersToSingleFolder) { if (File.Exists(filePath)) { @@ -503,10 +500,10 @@ private void BuildSkeletonData() foreach (var skeleton in skeletons) { - skeleton.BuildSkeletonData(_wldType == WldType.Characters || _settings.ModelExportFormat == ModelExportFormat.Intermediate); + skeleton.BuildSkeletonData(WldType == Wld.WldType.Characters || Settings.ModelExportFormat == ModelExportFormat.Intermediate); } - (_wldToInject as WldFileCharacters)?.BuildSkeletonData(); + (WldToInject as WldFileCharacters)?.BuildSkeletonData(); } } } diff --git a/LanternExtractor/EQ/Wld/WldFileCharacters.cs b/LanternExtractor/EQ/Wld/WldFileCharacters.cs index b705460..e7c8b28 100644 --- a/LanternExtractor/EQ/Wld/WldFileCharacters.cs +++ b/LanternExtractor/EQ/Wld/WldFileCharacters.cs @@ -11,7 +11,7 @@ namespace LanternExtractor.EQ.Wld { public class WldFileCharacters : WldFile { - public Dictionary AnimationSources = new Dictionary(); + private readonly Dictionary _animationSources = new Dictionary(); public WldFileCharacters(ArchiveFile wldFile, string zoneName, WldType type, ILogger logger, Settings settings, WldFile wldToInject = null) : base(wldFile, zoneName, type, logger, settings, wldToInject) @@ -24,7 +24,7 @@ private void ParseAnimationSources() string filename = "ClientData/animationsources.txt"; if (!File.Exists(filename)) { - _logger.LogError("WldFileCharacters: No animationsources.txt file found."); + Logger.LogError("WldFileCharacters: No animationsources.txt file found."); return; } @@ -38,13 +38,13 @@ private void ParseAnimationSources() continue; } - AnimationSources[line[0].ToLower()] = line[1].ToLower(); + _animationSources[line[0].ToLower()] = line[1].ToLower(); } } private string GetAnimationModelLink(string modelName) { - return !AnimationSources.ContainsKey(modelName) ? modelName : AnimationSources[modelName]; + return !_animationSources.ContainsKey(modelName) ? modelName : _animationSources[modelName]; } protected override void ProcessData() @@ -54,7 +54,7 @@ protected override void ProcessData() BuildSlotMapping(); FindMaterialVariants(); - if (_settings.ExportCharactersToSingleFolder) + if (Settings.ExportCharactersToSingleFolder) { var characterFixer = new CharacterFixer(); characterFixer.Fix(this); @@ -62,7 +62,7 @@ protected override void ProcessData() foreach (var skeleton in GetFragmentsOfType()) { - skeleton.BuildSkeletonData(_wldType == WldType.Characters); + skeleton.BuildSkeletonData(WldType == Wld.WldType.Characters); } } @@ -72,7 +72,7 @@ private void BuildSlotMapping() foreach (var list in materialLists) { - list.BuildSlotMapping(_logger); + list.BuildSlotMapping(Logger); } } @@ -95,7 +95,7 @@ private void FindMaterialVariants() if (materialName.StartsWith(materialListModelName)) { - list.AddVariant(material, _logger); + list.AddVariant(material, Logger); } } } @@ -107,7 +107,7 @@ private void FindMaterialVariants() continue; } - _logger.LogWarning("WldFileCharacters: Material not assigned: " + material.Name); + Logger.LogWarning("WldFileCharacters: Material not assigned: " + material.Name); } } @@ -122,12 +122,12 @@ private void FindAdditionalAnimationsAndMeshes() if (skeletons.Count == 0) { - if (_wldToInject == null) + if (WldToInject == null) { return; } - skeletons = _wldToInject.GetFragmentsOfType(); + skeletons = WldToInject.GetFragmentsOfType(); } if (skeletons.Count == 0) @@ -157,7 +157,7 @@ private void FindAdditionalAnimationsAndMeshes() if (!track.IsNameParsed) { - track.ParseTrackData(_logger); + track.ParseTrackData(Logger); } string trackModelBase = track.ModelName; @@ -215,7 +215,7 @@ private void FindAdditionalAnimationsAndMeshes() continue; } - _logger.LogWarning("WldFileCharacters: Track not assigned: " + track.Name); + Logger.LogWarning("WldFileCharacters: Track not assigned: " + track.Name); } } } diff --git a/LanternExtractor/EQ/Wld/WldFileEquipment.cs b/LanternExtractor/EQ/Wld/WldFileEquipment.cs index e999201..db9ec11 100644 --- a/LanternExtractor/EQ/Wld/WldFileEquipment.cs +++ b/LanternExtractor/EQ/Wld/WldFileEquipment.cs @@ -57,12 +57,12 @@ private void FindUnhandledSkeletons() string cleanedName = FragmentNameCleaner.CleanName(skeleton, false); string actorName = cleanedName + "_ACTORDEF"; - if (!_fragmentNameDictionary.ContainsKey(actorName)) + if (!FragmentNameDictionary.ContainsKey(actorName)) { continue; } - (_fragmentNameDictionary[actorName] as Actor)?.AssignSkeletonReference(skeleton, _logger); + (FragmentNameDictionary[actorName] as Actor)?.AssignSkeletonReference(skeleton, Logger); } } @@ -93,7 +93,7 @@ private void FindAdditionalAnimations() string boneName = string.Empty; if (skeleton.IsValidSkeleton(FragmentNameCleaner.CleanName(track), out boneName)) { - _logger.LogError($"Assigning {track.Name} to {skeleton.Name}"); + Logger.LogError($"Assigning {track.Name} to {skeleton.Name}"); track.IsProcessed = true; skeleton.AddTrackDataEquipment(track, boneName.ToLower()); } @@ -107,7 +107,7 @@ private void FindAdditionalAnimations() continue; } - _logger.LogError("WldFileCharacters: Track not assigned: " + track.Name); + Logger.LogError("WldFileCharacters: Track not assigned: " + track.Name); } } } diff --git a/LanternExtractor/EQ/Wld/WldFileLights.cs b/LanternExtractor/EQ/Wld/WldFileLights.cs index a7bd712..5da2775 100644 --- a/LanternExtractor/EQ/Wld/WldFileLights.cs +++ b/LanternExtractor/EQ/Wld/WldFileLights.cs @@ -29,7 +29,7 @@ private void ExportLightInstanceList() if (lightInstances.Count == 0) { - _logger.LogWarning("Unable to export light instance list. No instances found."); + Logger.LogWarning("Unable to export light instance list. No instances found."); return; } diff --git a/LanternExtractor/EQ/Wld/WldFileZone.cs b/LanternExtractor/EQ/Wld/WldFileZone.cs index d762b4a..95cecf4 100644 --- a/LanternExtractor/EQ/Wld/WldFileZone.cs +++ b/LanternExtractor/EQ/Wld/WldFileZone.cs @@ -31,12 +31,12 @@ protected override void ProcessData() base.ProcessData(); LinkBspReferences(); - if (_wldToInject != null) + if (WldToInject != null) { ImportVertexColors(); } - if (_wldType == WldType.Objects) + if (WldType == Wld.WldType.Objects) { FixSkeletalObjectCollision(); } @@ -67,7 +67,7 @@ private void FixSkeletalObjectCollision() private void ImportVertexColors() { - var colors = _wldToInject.GetFragmentsOfType(); + var colors = WldToInject.GetFragmentsOfType(); if (colors.Count == 0) { diff --git a/LanternExtractor/EQ/Wld/WldFileZoneObjects.cs b/LanternExtractor/EQ/Wld/WldFileZoneObjects.cs index 0be4dc9..742ce28 100644 --- a/LanternExtractor/EQ/Wld/WldFileZoneObjects.cs +++ b/LanternExtractor/EQ/Wld/WldFileZoneObjects.cs @@ -26,7 +26,7 @@ private void ExportObjectInstanceAndVertexColorList() if (instanceList.Count == 0) { - _logger.LogWarning("Cannot export object instance list. No object instances found."); + Logger.LogWarning("Cannot export object instance list. No object instances found."); return; } @@ -49,9 +49,9 @@ private void ExportObjectInstanceAndVertexColorList() colorWriter.ClearExportData(); } - if (_wldToInject != null) + if (WldToInject != null) { - instanceList = _wldToInject.GetFragmentsOfType(); + instanceList = WldToInject.GetFragmentsOfType(); foreach (var instance in instanceList) { diff --git a/LanternExtractor/Infrastructure/EqBmp.cs b/LanternExtractor/Infrastructure/EqBmp.cs index cc043ae..8f04b43 100644 --- a/LanternExtractor/Infrastructure/EqBmp.cs +++ b/LanternExtractor/Infrastructure/EqBmp.cs @@ -12,7 +12,7 @@ namespace LanternExtractor.Infrastructure /// public class EqBmp { - private static readonly bool _needsGdipHacks = Environment.OSVersion.Platform == PlatformID.MacOSX || + private static readonly bool NeedsGdipHacks = Environment.OSVersion.Platform == PlatformID.MacOSX || Environment.OSVersion.Platform == PlatformID.Unix; private static bool _hasCheckedForPaletteFlagsField; private static System.Reflection.FieldInfo _paletteFlagsField = null; @@ -38,7 +38,7 @@ public void WritePng(string outputFilePath) public void MakeMagentaTransparent() { _bitmap.MakeTransparent(Color.Magenta); - if (_needsGdipHacks) + if (NeedsGdipHacks) { // https://github.com/ mono/libgdiplus/commit/bf9a1440b7bfea704bf2cb771f5c2b5c09e7bcfa _bitmap.MakeTransparent(Color.FromArgb(0, Color.Magenta)); @@ -47,7 +47,7 @@ public void MakeMagentaTransparent() public void MakePaletteTransparent(int transparentIndex) { - if (_needsGdipHacks) + if (NeedsGdipHacks) { // https://github.com/mono/libgdiplus/issues/702 _paletteFlagsField?.SetValue(_palette, _palette.Flags | (int)PaletteFlags.HasAlpha); @@ -57,7 +57,7 @@ public void MakePaletteTransparent(int transparentIndex) _palette.Entries[transparentIndex] = transparentColor; _bitmap.Palette = _palette; - if (_needsGdipHacks) + if (NeedsGdipHacks) { // Due to a bug with the libgdiplus implementation of System.Drawing, setting a color palette // entry to transparent does not work. The workaround is to ensure that the transparent @@ -70,7 +70,7 @@ private Color GetTransparentPaletteColor() { var transparencyColor = Color.FromArgb(0, 0, 0, 0); - if (!_needsGdipHacks) + if (!NeedsGdipHacks) { return transparencyColor; } @@ -91,7 +91,7 @@ private Color GetTransparentPaletteColor() // https://github.com/Robmaister/SharpFont/pull/136 private static void SetPaletteFlagsField() { - if (!_needsGdipHacks || _hasCheckedForPaletteFlagsField) + if (!NeedsGdipHacks || _hasCheckedForPaletteFlagsField) { return; }