暂停功能
This commit is contained in:
@@ -18,6 +18,7 @@ namespace AibisDream
|
||||
private VariableStorageBehaviour _variableStorage;
|
||||
|
||||
private readonly Dictionary<string, Action<YarnOption[]>> commandMap = new();
|
||||
private readonly Dictionary<string, Action<YarnContinueStep>> _pauseCommandMap = new();
|
||||
|
||||
# region controller状态标识
|
||||
|
||||
@@ -47,9 +48,8 @@ namespace AibisDream
|
||||
public bool quickRunMode;
|
||||
|
||||
// 暂停对话
|
||||
private bool _isInPause;
|
||||
private Action _pauseNextStep;
|
||||
|
||||
public bool isInPause;
|
||||
|
||||
# endregion
|
||||
|
||||
public static UnityAction OnDialogueStart;
|
||||
@@ -112,29 +112,7 @@ namespace AibisDream
|
||||
dialogueRunner.StartDialogue("Start");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 继续对话
|
||||
/// </summary>
|
||||
public bool TryContinueTalk()
|
||||
{
|
||||
// 如果对话系统在暂停状态
|
||||
if (_isInPause)
|
||||
{
|
||||
_pauseNextStep.Invoke();
|
||||
_isInPause = false;
|
||||
_pauseNextStep = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
// 如果对话系统不在暂停状态
|
||||
return false;
|
||||
}
|
||||
|
||||
public void PauseTalk(Action pauseNextStep)
|
||||
{
|
||||
_isInPause = true;
|
||||
_pauseNextStep = pauseNextStep;
|
||||
}
|
||||
#region 选项指令
|
||||
|
||||
/// <summary>
|
||||
/// 调用命令
|
||||
@@ -190,6 +168,67 @@ namespace AibisDream
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 暂停选项指令
|
||||
|
||||
/// <summary>
|
||||
/// 执行暂停命令
|
||||
/// </summary>
|
||||
/// <param name="commandName">命令名</param>
|
||||
/// <param name="pauseCommand">参数</param>
|
||||
public void InvokePauseCommand(string commandName, YarnContinueStep pauseCommand)
|
||||
{
|
||||
if (string.IsNullOrEmpty(commandName))
|
||||
{
|
||||
Debug.Log("命令名为空");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_pauseCommandMap.TryGetValue(commandName, out var action))
|
||||
{
|
||||
action(pauseCommand);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"命令 {commandName} 不存在");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册暂停命令
|
||||
/// </summary>
|
||||
/// <param name="commandName">命令名</param>
|
||||
/// <param name="commandAction">注册命令函数</param>
|
||||
public void RegisterPauseCommand(string commandName, Action<YarnContinueStep> commandAction)
|
||||
{
|
||||
if (_pauseCommandMap.ContainsKey(commandName))
|
||||
{
|
||||
Debug.Log($"命令 {commandName} 已经存在,将被替换");
|
||||
}
|
||||
|
||||
_pauseCommandMap[commandName] = commandAction;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除命令
|
||||
/// </summary>
|
||||
/// <param name="commandName">命令名称</param>
|
||||
public void RemovePauseCommand(string commandName)
|
||||
{
|
||||
if (_pauseCommandMap.ContainsKey(commandName))
|
||||
{
|
||||
_pauseCommandMap.Remove(commandName);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"命令 {commandName} 不存在");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 命令名
|
||||
|
||||
[YarnCommand("switch_tv")]
|
||||
|
||||
Reference in New Issue
Block a user