Skip to content

Commit

Permalink
Merge pull request #21 from ManlyMarco/master
Browse files Browse the repository at this point in the history
Fix not working after reentering a h scene
  • Loading branch information
Keelhauled committed Jan 7, 2021
2 parents 85e46a8 + 3b5b574 commit 96c4ff4
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/RealPOV.Koikatu/RealPOV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: System.Reflection.AssemblyFileVersion(RealPOV.Koikatu.RealPOV.Version)]

Expand All @@ -24,10 +25,13 @@ protected override void Awake()
{
base.Awake();
Harmony.CreateAndPatchAll(GetType());

SceneManager.activeSceneChanged += (arg0, scene) => charaQueue = null;
}

internal override void EnablePOV()
{

if(isStudio)
{
var selectedCharas = GuideObjectManager.Instance.selectObjectKey.Select(x => Studio.Studio.GetCtrlInfo(x) as OCIChar).Where(x => x != null).ToList();
Expand All @@ -38,18 +42,31 @@ internal override void EnablePOV()
}
else
{
if(charaQueue == null)
void CreateQueue()
{
charaQueue = new Queue<ChaControl>();
foreach (ChaControl chara in FindObjectsOfType<ChaControl>())
charaQueue.Enqueue(chara);
currentChara = charaQueue.Dequeue();
charaQueue.Enqueue(currentChara);
if (charaQueue.Count > 0)
{
currentChara = charaQueue.Dequeue();
charaQueue.Enqueue(currentChara);
}
}

currentChara = null;
if(charaQueue == null)
{
CreateQueue();
}
else
{
currentChara = charaQueue.Dequeue();
charaQueue.Enqueue(currentChara);
while (charaQueue.Count > 0 && (currentChara = charaQueue.Dequeue()) == null) {}

if (currentChara != null)
charaQueue.Enqueue(currentChara);
else
CreateQueue();
}
}

Expand Down

0 comments on commit 96c4ff4

Please sign in to comment.