Skip to content

Commit

Permalink
Invalidate lipsync cache after loading a save
Browse files Browse the repository at this point in the history
  • Loading branch information
drojf committed Mar 23, 2024
1 parent 859de75 commit 2834db7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Assets.Scripts.Core.Buriko/BurikoScriptSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Assets.Scripts.Core.Audio;
using Assets.Scripts.Core.Interfaces;
using MOD.Scripts.Core.Audio;
using MOD.Scripts.Core.Scene;
using MOD.Scripts.UI;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -419,6 +420,7 @@ public void LoadGame(int slotnum)
AudioController.Instance.DeSerializeCurrentAudio(memoryStream);
// Restoring mod audio state done here to avoid changes being overwritten by above DeSerializeCurrentAudio() call
MODAudioTracking.Instance.RestoreState();
MODLipsyncCache.InvalidateLipsyncCache();
GameSystem.Instance.SceneController.DeSerializeScene(memoryStream);
GameSystem.Instance.ForceReturnNormalState();
GameSystem.Instance.CloseChoiceIfExists();
Expand Down
10 changes: 10 additions & 0 deletions MOD.Scripts.Core.Scene/MODLipsyncCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,16 @@ public static void MODLipsyncCacheUpdate(int character)
LoadOrUseCache(character, out TextureGroup _);
}

public static void InvalidateLipsyncCache()
{
List<string> texturesToRemove = cache.Keys.ToList();
foreach (string textureKey in texturesToRemove)
{
cache[textureKey].DestroyTextures();
cache.Remove(textureKey);
}
}

/// <summary>
/// Loads the mouth textures, attempting to load from the given layer OR cache if possible
///
Expand Down

0 comments on commit 2834db7

Please sign in to comment.