Files
ichni_Official/Assets/Scripts/NewStorySystem/Dialogue/DialogueHistory.cs
SoulliesOfficial 810d019619 剧情+对话完善
2026-07-21 15:24:42 -04:00

57 lines
1.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Generic;
namespace Ichni.Story.Dialogue
{
/// <summary>对话记录中一条已经实际显示或采用的内容。</summary>
[Serializable]
public sealed class DialogueHistoryEntry
{
public string speakerName;
public string content;
public bool isChoice;
}
/// <summary>
/// 当前一次 TextBlock 对话专用的临时记录。
/// <para>记录不会写入 ES3开始下一次对话、正常结束或点击 Back 取消时都会清空,
/// 因而它只承担 DialogUIPage 内的“本次对话回顾”职责。</para>
/// </summary>
public static class DialogueHistory
{
private static readonly List<DialogueHistoryEntry> EntriesInternal = new();
public static IReadOnlyList<DialogueHistoryEntry> Entries => EntriesInternal;
public static void BeginSession() => EntriesInternal.Clear();
public static void AddLine(string speakerName, string content)
{
if (string.IsNullOrWhiteSpace(content))
return;
EntriesInternal.Add(new DialogueHistoryEntry
{
speakerName = speakerName ?? string.Empty,
content = content,
isChoice = false
});
}
public static void AddChoice(string content)
{
if (string.IsNullOrWhiteSpace(content))
return;
EntriesInternal.Add(new DialogueHistoryEntry
{
speakerName = string.Empty,
content = content,
isChoice = true
});
}
public static void Clear() => EntriesInternal.Clear();
}
}