66 lines
2.7 KiB
C#
66 lines
2.7 KiB
C#
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;
|
||
}
|
||
}
|
||
}
|