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");
|
||||
PathManager = new ResourcePathManager(extractPath);
|
||||
ModelLoader = new ModelLoader(PathManager);
|
||||
ModelLoader = new ModelLoader();
|
||||
|
||||
Instance = this;
|
||||
}
|
||||
|
|
|
@ -7,14 +7,7 @@ namespace KeepersCompound.TMV;
|
|||
|
||||
public class ModelLoader
|
||||
{
|
||||
private readonly Dictionary<(string, string), MeshInstance3D> _cache;
|
||||
private readonly ResourcePathManager _pathManager;
|
||||
|
||||
public ModelLoader(ResourcePathManager pathManager)
|
||||
{
|
||||
_pathManager = pathManager;
|
||||
_cache = new Dictionary<(string, string), MeshInstance3D>();
|
||||
}
|
||||
private readonly Dictionary<(string, string), MeshInstance3D> _cache = new();
|
||||
|
||||
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
|
||||
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;
|
||||
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);
|
||||
campaignName = newCampaignName;
|
||||
if (modelPath == null)
|
||||
|
|
Loading…
Reference in New Issue