ModelLoader uses context pathmanager
This commit is contained in:
parent
12a8b4f06d
commit
236cf3b317
|
@ -14,7 +14,7 @@ public partial class Context : Node
|
||||||
{
|
{
|
||||||
var extractPath = ProjectSettings.GlobalizePath($"user://extracted/tmp");
|
var extractPath = ProjectSettings.GlobalizePath($"user://extracted/tmp");
|
||||||
PathManager = new ResourcePathManager(extractPath);
|
PathManager = new ResourcePathManager(extractPath);
|
||||||
ModelLoader = new ModelLoader(PathManager);
|
ModelLoader = new ModelLoader();
|
||||||
|
|
||||||
Instance = this;
|
Instance = this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,7 @@ namespace KeepersCompound.TMV;
|
||||||
|
|
||||||
public class ModelLoader
|
public class ModelLoader
|
||||||
{
|
{
|
||||||
private readonly Dictionary<(string, string), MeshInstance3D> _cache;
|
private readonly Dictionary<(string, string), MeshInstance3D> _cache = new();
|
||||||
private readonly ResourcePathManager _pathManager;
|
|
||||||
|
|
||||||
public ModelLoader(ResourcePathManager pathManager)
|
|
||||||
{
|
|
||||||
_pathManager = pathManager;
|
|
||||||
_cache = new Dictionary<(string, string), MeshInstance3D>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public MeshInstance3D Load(string campaignName, string modelName, bool forceLoad = false)
|
public MeshInstance3D Load(string campaignName, string modelName, bool forceLoad = false)
|
||||||
{
|
{
|
||||||
|
@ -33,13 +26,14 @@ public class ModelLoader
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't care if this is null actually, we'll still cache that it's null lol
|
// We don't care if this is null actually, we'll still cache that it's null lol
|
||||||
var model = Timing.TimeStage("Load Models", () => { return LoadModel(_pathManager, ref campaignName, modelName); });
|
var model = Timing.TimeStage("Load Models", () => { return LoadModel(ref campaignName, modelName); });
|
||||||
_cache[(campaignName, modelName)] = model;
|
_cache[(campaignName, modelName)] = model;
|
||||||
return model?.Duplicate() as MeshInstance3D;
|
return model?.Duplicate() as MeshInstance3D;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MeshInstance3D LoadModel(ResourcePathManager pathManager, ref string campaignName, string modelName)
|
public static MeshInstance3D LoadModel(ref string campaignName, string modelName)
|
||||||
{
|
{
|
||||||
|
var pathManager = Context.Instance.PathManager;
|
||||||
var (newCampaignName, modelPath) = pathManager.GetResourcePath(ResourceType.Object, campaignName, modelName);
|
var (newCampaignName, modelPath) = pathManager.GetResourcePath(ResourceType.Object, campaignName, modelName);
|
||||||
campaignName = newCampaignName;
|
campaignName = newCampaignName;
|
||||||
if (modelPath == null)
|
if (modelPath == null)
|
||||||
|
|
Loading…
Reference in New Issue