mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Fix race conditions with slide textures loading
This commit is contained in:
parent
073892c008
commit
5aba437596
@ -4,8 +4,8 @@ using NewHorizons.Utility;
|
||||
using OWML.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using static NewHorizons.External.Modules.PropModule;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
namespace NewHorizons.Builder.Props
|
||||
{
|
||||
@ -113,13 +113,10 @@ namespace NewHorizons.Builder.Props
|
||||
slideCollection.slides[index]._image = ImageUtilities.Invert(tex);
|
||||
|
||||
// Track the first 15 to put on the slide reel object
|
||||
if (index < 15)
|
||||
if (index < textures.Length)
|
||||
{
|
||||
textures[index] = tex;
|
||||
displaySlidesLoaded++; // threading moment
|
||||
}
|
||||
|
||||
if (displaySlidesLoaded >= textures.Length)
|
||||
if (Interlocked.Increment(ref displaySlidesLoaded) == textures.Length)
|
||||
{
|
||||
// all textures required to build the reel's textures have been loaded
|
||||
var slidesBack = slideReelObj.transform.Find("Props_IP_SlideReel_7/Slides_Back").GetComponent<MeshRenderer>();
|
||||
@ -133,6 +130,7 @@ namespace NewHorizons.Builder.Props
|
||||
slidesFront.material.SetTexture(EmissionMap, reelTexture);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Else when you put them down you can't pick them back up
|
||||
@ -352,9 +350,8 @@ namespace NewHorizons.Builder.Props
|
||||
(Texture2D tex, int index) =>
|
||||
{
|
||||
slideCollection.slides[index]._image = tex;
|
||||
displaySlidesLoaded++; // threading moment
|
||||
|
||||
if (displaySlidesLoaded >= slides.Length)
|
||||
if (Interlocked.Increment(ref displaySlidesLoaded) == slides.Length)
|
||||
{
|
||||
mindSlideProjector.enabled = true;
|
||||
visionBeamEffect.SetActive(true);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user