diff --git a/project/code/LGS/ResourcePathManager.cs b/project/code/LGS/ResourcePathManager.cs index e78b6fc..9203cc0 100644 --- a/project/code/LGS/ResourcePathManager.cs +++ b/project/code/LGS/ResourcePathManager.cs @@ -191,7 +191,7 @@ public class ResourcePathManager } // TODO: Store these as part of the resources - public string GetObjectTexturePath(string campaignName, string textureName) + public string GetObjectTexturePath(string campaignName, string modelName, string textureName) { var options = new EnumerationOptions { @@ -211,11 +211,20 @@ public class ResourcePathManager } else if (_fmResources.TryGetValue(campaignName, out var campaign)) { - var fmDir = Path.Join(_fmsDir, campaignName); - var fmPaths = Directory.GetFiles(Path.Join(fmDir, "obj"), textureName, options); - if (fmPaths.Length > 0) + // TODO: This is a fucking mess + // Basically we need to handle when the campaign doesn't have a models folder lol + if (campaign.objectPathMap.TryGetValue(modelName, out var modelPath)) { - return fmPaths[0]; + var dir = Path.GetDirectoryName(modelPath); + var fmPaths = Directory.GetFiles(dir, textureName, options); + if (fmPaths.Length > 0) + { + return fmPaths[0]; + } + else if (omPaths.Length > 0) + { + return omPaths[0]; + } } else if (omPaths.Length > 0) { diff --git a/project/code/TMV/ModelLoader.cs b/project/code/TMV/ModelLoader.cs index afa880c..301d179 100644 --- a/project/code/TMV/ModelLoader.cs +++ b/project/code/TMV/ModelLoader.cs @@ -26,9 +26,10 @@ public static class ModelLoader { if (material.Type == 0) { - var path = pathManager.GetObjectTexturePath(campaignName, material.Name); + var path = pathManager.GetObjectTexturePath(campaignName, modelName, material.Name); if (path == null) { + // TODO: JORGE GD.Print($"Failed to load model texture: {material.Name}"); continue; }