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

66 lines
2.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 Ichni.Menu;
using UnityEngine;
namespace Ichni.Story
{
/// <summary>
/// 从剧情 SongBlock 进入选曲时携带的临时上下文。
/// 它只存在于 DontDestroyOnLoad 的 InformationTransistor 中,不写入存档:歌曲完成与
/// 剧情 Block 完成仍由各自正式存档负责;本类仅用于一次页面往返的目标校验与视口恢复。
/// </summary>
[Serializable]
public class StorySongEntryContext
{
/// <summary>是否正处于一次由剧情 SongBlock 发起、尚未结束的选曲流程。</summary>
public bool isActive;
/// <summary>发起入口的章节 ID用于防止跨章节同名歌曲被误判为目标歌曲。</summary>
public string chapterIndex;
/// <summary>发起本次选曲的 SongBlock ID目标歌曲确认后会完成此 Block。</summary>
public string sourceBlockId;
/// <summary>SongItemData.songName对应 StoryBlockDefinition.songName 的稳定歌曲 ID。</summary>
public string targetSongId;
/// <summary>离开剧情页时 StoryTree Content 的位置,用于返回后还原浏览位置。</summary>
public Vector2 storyTreeContentPosition;
/// <summary>仅在确认进入目标歌曲后设为 true决定 GameScene 返回剧情页而非普通选曲页。</summary>
public bool returnToStoryAfterGame;
/// <summary>开始一次新的剧情歌曲入口,覆盖任何未完成的旧运行时上下文。</summary>
public void Begin(string chapterId, string blockId, string songId, Vector2 contentPosition)
{
isActive = true;
chapterIndex = chapterId;
sourceBlockId = blockId;
targetSongId = songId;
storyTreeContentPosition = contentPosition;
returnToStoryAfterGame = false;
}
/// <summary>
/// 判断玩家当前确认进入的歌曲是否正是剧情入口指定的目标。
/// 必须同时比对章节与稳定歌曲 ID不能仅使用显示名或对象引用。
/// </summary>
public bool IsTargetSong(ChapterSelectionUnit chapter, SongItemData song)
{
return isActive && chapter != null && song != null &&
chapter.chapterIndex == chapterIndex && song.songName == targetSongId;
}
/// <summary>结束本次页面往返并清除所有瞬时数据,避免影响后续普通选曲。</summary>
public void Clear()
{
isActive = false;
chapterIndex = null;
sourceBlockId = null;
targetSongId = null;
storyTreeContentPosition = Vector2.zero;
returnToStoryAfterGame = false;
}
}
}