Merge GetObjectPath implementations

This commit is contained in:
Jarrod Doyle 2024-08-25 16:25:12 +01:00
parent 0d7ff677de
commit e313ca58a7
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
2 changed files with 17 additions and 18 deletions

View File

@ -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;
}

View File

@ -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;