45 lines
1.0 KiB
C#
45 lines
1.0 KiB
C#
using UnityEngine;
|
|
using Yarn.Unity;
|
|
|
|
namespace NightclubArcadia.Skills
|
|
{
|
|
public sealed class CommentaryIdleTimer : MonoBehaviour
|
|
{
|
|
[SerializeField] DialogueRunner dialogueRunner;
|
|
[SerializeField] string contextId = "Entrance_Queue";
|
|
[SerializeField] float idleSeconds = 45f;
|
|
|
|
float _idleAccum;
|
|
|
|
void Update()
|
|
{
|
|
if (string.IsNullOrEmpty(contextId))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (dialogueRunner != null && dialogueRunner.IsDialogueRunning)
|
|
{
|
|
_idleAccum = 0f;
|
|
return;
|
|
}
|
|
|
|
_idleAccum += Time.deltaTime;
|
|
if (_idleAccum < idleSeconds)
|
|
{
|
|
return;
|
|
}
|
|
|
|
_idleAccum = 0f;
|
|
|
|
var runtime = SkillRuntime.Instance;
|
|
if (runtime == null || runtime.Commentary == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
runtime.Commentary.RequestCommentary(contextId, repeatable: true);
|
|
}
|
|
}
|
|
}
|