mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
document
This commit is contained in:
parent
b1e64c1491
commit
a6c20cb231
@ -18,9 +18,12 @@ public class NHSlideCollection : SlideCollection
|
||||
public string[] slidePaths;
|
||||
public IModBehaviour mod;
|
||||
private HashSet<string> _pathsBeingLoaded = new();
|
||||
/// <summary>
|
||||
/// map of slide path to collections that have this path loaded. used to only unload slide when nothing else is using it
|
||||
/// </summary>
|
||||
public static Dictionary<string, HashSet<NHSlideCollection>> _slidesRequiringPath = new();
|
||||
|
||||
private ShipLogSlideProjector _shipLogSlideProjector;
|
||||
private static ShipLogSlideProjector _shipLogSlideProjector;
|
||||
|
||||
static NHSlideCollection()
|
||||
{
|
||||
@ -113,6 +116,7 @@ public class NHSlideCollection : SlideCollection
|
||||
// Something else has loaded this image i.e., AutoProjector or Vision torch. We want to ensure we do not delete it
|
||||
if (ImageUtilities.IsTextureLoaded(mod, path))
|
||||
{
|
||||
// null is dummy value to ensure its never empty (so its not deleted)
|
||||
_slidesRequiringPath[key] = new() { null };
|
||||
}
|
||||
else
|
||||
@ -124,17 +128,21 @@ public class NHSlideCollection : SlideCollection
|
||||
|
||||
if (ImageUtilities.IsTextureLoaded(mod, path))
|
||||
{
|
||||
// already loaded
|
||||
var texture = ImageUtilities.GetTexture(mod, path);
|
||||
slides[wrappedIndex]._image = texture;
|
||||
return texture;
|
||||
}
|
||||
else if (!_pathsBeingLoaded.Contains(path))
|
||||
{
|
||||
// not loaded yet, we need to load it
|
||||
var loader = new SlideReelAsyncImageLoader();
|
||||
loader.PathsToLoad.Add((wrappedIndex, path));
|
||||
loader.Start(true, false);
|
||||
loader.imageLoadedEvent.AddListener((Texture2D tex, int index, string originalPath) =>
|
||||
{
|
||||
// weird: sometimes we set image, sometimes we return from GetStreamingTexture. oh well
|
||||
// also somehow setting this later works and updates the cookie without having to manually tell it to do that??? idk how
|
||||
slides[wrappedIndex]._image = tex;
|
||||
_pathsBeingLoaded.Remove(path);
|
||||
if (_shipLogSlideProjector == null)
|
||||
@ -143,6 +151,7 @@ public class NHSlideCollection : SlideCollection
|
||||
}
|
||||
if (_shipLogSlideProjector != null)
|
||||
{
|
||||
// gotta tell ship log we updated the image
|
||||
_shipLogSlideProjector._slideDirty = true;
|
||||
}
|
||||
else
|
||||
|
||||
@ -10,6 +10,7 @@ public class NHSlideCollectionContainer : SlideCollectionContainer
|
||||
{
|
||||
public string[] conditionsToSet;
|
||||
public string[] persistentConditionsToSet;
|
||||
// at some point we'll do streaming on all slides. until then just have an off switch
|
||||
public bool doAsyncLoading = true;
|
||||
|
||||
[HarmonyPrefix]
|
||||
|
||||
@ -42,6 +42,11 @@ public class SlideReelAsyncImageLoader
|
||||
private bool _started;
|
||||
private bool _clamp;
|
||||
|
||||
/// <summary>
|
||||
/// start loading the images a frame later
|
||||
/// </summary>
|
||||
/// <param name="clamp">sets wrapMode</param>
|
||||
/// <param name="sequential">load all slides one at a time vs at the same time</param>
|
||||
public void Start(bool clamp, bool sequential)
|
||||
{
|
||||
if (_started) return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user