From e313ca58a73c9143abe705e757e83bbf5d9715a5 Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Sun, 25 Aug 2024 16:25:12 +0100 Subject: [PATCH] Merge GetObjectPath implementations --- project/code/LGS/ResourcePathManager.cs | 31 +++++++++++++------------ project/code/TMV/Mission.cs | 4 +--- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/project/code/LGS/ResourcePathManager.cs b/project/code/LGS/ResourcePathManager.cs index abf253e..14ae529 100644 --- a/project/code/LGS/ResourcePathManager.cs +++ b/project/code/LGS/ResourcePathManager.cs @@ -162,27 +162,28 @@ public class ResourcePathManager return null; } - public string GetObjectPath(string objectName) - { - if (!_initialised) return null; - - objectName = objectName.ToLower(); - if (_omResources.objectPathMap.TryGetValue(objectName, out var path)) - { - return path; - } - return null; - } - public string GetObjectPath(string campaignName, string objectName) { if (!_initialised) return null; objectName = objectName.ToLower(); - if (_fmResources.TryGetValue(campaignName, out var campaign) && - campaign.objectPathMap.TryGetValue(objectName, out var path)) + if (campaignName == null || campaignName == "") { - return path; + if (_omResources.objectPathMap.TryGetValue(objectName, out var omPath)) + { + return omPath; + } + } + if (_fmResources.TryGetValue(campaignName, out var campaign)) + { + if (campaign.objectPathMap.TryGetValue(objectName, out var fmPath)) + { + return fmPath; + } + else if (_omResources.objectPathMap.TryGetValue(objectName, out var omPath)) + { + return omPath; + } } return null; } diff --git a/project/code/TMV/Mission.cs b/project/code/TMV/Mission.cs index 4b174eb..e3db0ec 100644 --- a/project/code/TMV/Mission.cs +++ b/project/code/TMV/Mission.cs @@ -164,9 +164,7 @@ public partial class Mission : Node3D // Let's try and place an object :) var modelName = modelNameProp.modelName + ".bin"; - var fmName = FileName.GetBaseDir().GetFile(); // TODO: Doesn't work for OMs - var objPath = _installPaths.GetObjectPath(fmName, modelName); - objPath ??= _installPaths.GetObjectPath(modelName); + var objPath = _installPaths.GetObjectPath(_campaignName, modelName); var pos = brush.position.ToGodotVec3(); var rawRot = brush.angle;