private static ObjModel loadModelFile(ModAsset asset, string path) { if (ObjModelCache.TryGetValue(path, out ObjModel cached)) { return(cached); } ObjModel loaded = ObjModelExt.CreateFromStream(asset.Stream, path); ObjModelCache[path] = loaded; return(loaded); }
/// <summary> /// Load the custom mountain models for mods. /// </summary> public static void LoadModData() { if (!ModsDataLoaded) { Stopwatch stopwatch = Stopwatch.StartNew(); lock (Everest.Content.Map) { foreach (KeyValuePair <string, ModAsset> kvp in Everest.Content.Map) { MapMeta meta; // Check if the meta for this asset exists and if it has a MountainModelDirectory specified if (kvp.Value != null && (meta = kvp.Value.GetMeta <MapMeta>()) != null && meta.Mountain != null && !string.IsNullOrEmpty(meta.Mountain.MountainModelDirectory)) { // Create the mountain resources for this map if they don't exist already if (!MountainMappings.TryGetValue(kvp.Key, out MountainResources resources)) { resources = new MountainResources(); MountainMappings.Add(kvp.Key, resources); } if (Everest.Content.TryGet(Path.Combine(meta.Mountain.MountainModelDirectory, "mountain"), out ModAsset mountain)) { resources.MountainTerrain = ObjModelExt.CreateFromStream(mountain.Stream, Path.Combine(meta.Mountain.MountainModelDirectory, "mountain.obj")); } if (Everest.Content.TryGet(Path.Combine(meta.Mountain.MountainModelDirectory, "buildings"), out ModAsset buildings)) { resources.MountainBuildings = ObjModelExt.CreateFromStream(buildings.Stream, Path.Combine(meta.Mountain.MountainModelDirectory, "buildings.obj")); } if (Everest.Content.TryGet(Path.Combine(meta.Mountain.MountainModelDirectory, "mountain_wall"), out ModAsset coreWall)) { resources.MountainCoreWall = ObjModelExt.CreateFromStream(coreWall.Stream, Path.Combine(meta.Mountain.MountainModelDirectory, "mountain_wall.obj")); } if (Everest.Content.TryGet(Path.Combine(meta.Mountain.MountainModelDirectory, "bird"), out ModAsset bird)) { resources.MountainBird = ObjModelExt.CreateFromStream(bird.Stream, Path.Combine(meta.Mountain.MountainModelDirectory, "bird.obj")); } if (Everest.Content.TryGet(Path.Combine(meta.Mountain.MountainModelDirectory, "moon"), out ModAsset moon)) { resources.MountainMoon = ObjModelExt.CreateFromStream(moon.Stream, Path.Combine(meta.Mountain.MountainModelDirectory, "moon.obj")); } } } } Console.WriteLine(" - MODDED MTN DATA LOAD: " + stopwatch.ElapsedMilliseconds + "ms"); } ModsDataLoaded = true; }