/// <summary> /// Finishes a texture update by updating the lerpers. They are pretty fast as they /// are mostly implemented in Unity. /// </summary> /// <param name="instance">The property textures to finish updating.</param> internal void FinishUpdate(PropertyTextures instance) { var lerpers = instance.lerpers; if (forceLateUpdate && outstanding < 1) { StartUpdate(); forceLateUpdate = false; } // Wait out the update if (outstanding > 0 && !onComplete.WaitAndMeasure(FastTrackMod.MAX_TIMEOUT)) { PUtil.LogWarning("Property textures did not update within the timeout!"); } DisposeAll(); if (lerpers != null && !FullScreenDialogPatches.DialogVisible) { int n = lerpers.Length; for (int i = 0; i < n; i++) { var lerper = lerpers[i]; if (lerper != null) { if (Time.timeScale == 0f) { // Handle paused case lerper.LongUpdate(Time.unscaledDeltaTime); } Shader.SetGlobalTexture(allProperties[i].PropertyName, lerper. Update()); } } } }
public static void DestroyInstance() { ShaderReloader.Unregister(instance.OnShadersReloaded); externalFlowTex = IntPtr.Zero; externalLiquidTex = IntPtr.Zero; externalExposedToSunlight = IntPtr.Zero; externalSolidDigAmountTex = IntPtr.Zero; instance = null; }
/// <summary> /// Applied before LateUpdate runs. /// </summary> internal static bool Prefix(PropertyTextures __instance) { var inst = PropertyTextureUpdater.Instance; try { if (inst != null) { inst.FinishUpdate(__instance); } } catch (Exception e) { PUtil.LogError(e); } return(inst == null); }
protected override void OnPrefabInit() { instance = this; base.OnPrefabInit(); ShaderReloader.Register(OnShadersReloaded); }
/// <summary> /// Applied after OnSpawn runs. /// </summary> internal static void Postfix(PropertyTextures __instance) { PropertyTextureUpdater.CreateInstance(); }
/// <summary> /// Applied after OnReset runs. /// </summary> internal static void Postfix(PropertyTextures __instance) { PropertyTextureUpdater.Instance?.Init(__instance.allTextureProperties, __instance.externallyUpdatedTextures); }