Loosely handle campaigns not having an obj folder when trying to get obj texture path
This commit is contained in:
parent
05e90c1a30
commit
1cfbd498c7
|
@ -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,8 +211,12 @@ 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);
|
||||
// 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))
|
||||
{
|
||||
var dir = Path.GetDirectoryName(modelPath);
|
||||
var fmPaths = Directory.GetFiles(dir, textureName, options);
|
||||
if (fmPaths.Length > 0)
|
||||
{
|
||||
return fmPaths[0];
|
||||
|
@ -222,6 +226,11 @@ public class ResourcePathManager
|
|||
return omPaths[0];
|
||||
}
|
||||
}
|
||||
else if (omPaths.Length > 0)
|
||||
{
|
||||
return omPaths[0];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue