refactor(save): 移除 Showcase 快照持久化
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
using System.Collections;
|
||||
|
||||
namespace AibisDream.SaveSystem
|
||||
{
|
||||
/// <summary>sections["showcase"]:梦境普通小图或大图。RestoreOrder=69。</summary>
|
||||
public sealed class ShowcaseSnapshotProvider : IAsyncSnapshotProvider
|
||||
{
|
||||
public string SaveId => SnapshotProviderIds.Showcase;
|
||||
public int RestoreOrder => 69;
|
||||
|
||||
public object Capture()
|
||||
{
|
||||
return SpriteShowcase.Instance != null
|
||||
? SpriteShowcase.Instance.CaptureSnapshot()
|
||||
: null;
|
||||
}
|
||||
|
||||
public IEnumerator RestoreAsync(object dto, SnapshotRestoreContext context)
|
||||
{
|
||||
if (dto is not ShowcaseSnapshotDto snapshot)
|
||||
{
|
||||
context.Warn("[ShowcaseSnapshotProvider] DTO 类型不匹配,跳过还原。");
|
||||
yield break;
|
||||
}
|
||||
|
||||
var showcase = SpriteShowcase.Instance;
|
||||
if (showcase == null)
|
||||
{
|
||||
context.Warn("[ShowcaseSnapshotProvider] SpriteShowcase 未初始化,跳过还原。");
|
||||
yield break;
|
||||
}
|
||||
|
||||
yield return showcase.RestoreSnapshotAsync(snapshot, context.Warn);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83cccdfaca2a42a89ed515c16c6adfad
|
||||
@@ -190,26 +190,6 @@ namespace AibisDream.SaveSystem
|
||||
public string fullScreenPicName;
|
||||
}
|
||||
|
||||
/// <summary>Showcase 当前持久化的图片类型;不包含风筝及其他瞬时演出。</summary>
|
||||
public enum ShowcaseDisplayMode
|
||||
{
|
||||
None,
|
||||
Small,
|
||||
Large
|
||||
}
|
||||
|
||||
/// <summary>sections["showcase"]:梦境 Showcase 普通小图或大图终态。</summary>
|
||||
[Serializable]
|
||||
public class ShowcaseSnapshotDto
|
||||
{
|
||||
/// <summary><see cref="ShowcaseDisplayMode"/> 枚举名。</summary>
|
||||
public string displayMode;
|
||||
public string picName;
|
||||
|
||||
/// <summary>小图是否由分层资源组成;只恢复静止画面,不恢复运动。</summary>
|
||||
public bool usesSplitLayers;
|
||||
}
|
||||
|
||||
/// <summary>sections["subway"]:地铁场景宏观状态(SubwayCenter / OutSideState)。</summary>
|
||||
[Serializable]
|
||||
public class SubwaySnapshotDto
|
||||
|
||||
@@ -16,7 +16,6 @@ namespace AibisDream.SaveSystem
|
||||
public const string Timeline = "timeline";
|
||||
public const string Screen = "screen";
|
||||
public const string PlayTool = "playTool";
|
||||
public const string Showcase = "showcase";
|
||||
public const string Subway = "subway";
|
||||
public const string PunchTape = "punchTape";
|
||||
public const string Fix = "fix";
|
||||
@@ -31,7 +30,7 @@ namespace AibisDream.SaveSystem
|
||||
/// </summary>
|
||||
public static readonly string[] RequiredForCapture =
|
||||
{
|
||||
Environment, Actor, Audio, Timeline, Subway, Fix, Showcase, PlayTool, Screen
|
||||
Environment, Actor, Audio, Timeline, Subway, Fix, PlayTool, Screen
|
||||
};
|
||||
}
|
||||
|
||||
@@ -61,7 +60,6 @@ namespace AibisDream.SaveSystem
|
||||
Register(new FixPanelSnapshotProvider());
|
||||
Register(new BodyModuleSnapshotProvider());
|
||||
Register(new EyeSnapshotProvider());
|
||||
Register(new ShowcaseSnapshotProvider());
|
||||
Register(new PlayToolSnapshotProvider());
|
||||
Register(new ScreenSnapshotProvider());
|
||||
}
|
||||
|
||||
@@ -257,7 +257,6 @@ namespace AibisDream.SaveSystem
|
||||
SnapshotProviderIds.FixPanel => jobj.ToObject<FixPanelSnapshotDto>(),
|
||||
SnapshotProviderIds.BodyModule => jobj.ToObject<BodyModuleSnapshotDto>(),
|
||||
SnapshotProviderIds.Eye => jobj.ToObject<EyeSnapshotDto>(),
|
||||
SnapshotProviderIds.Showcase => jobj.ToObject<ShowcaseSnapshotDto>(),
|
||||
SnapshotProviderIds.PlayTool => jobj.ToObject<PlayToolSnapshotDto>(),
|
||||
SnapshotProviderIds.Screen => jobj.ToObject<ScreenSnapshotDto>(),
|
||||
_ => jobj
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
using System.Collections;
|
||||
using AibisDream.Framework;
|
||||
using AibisDream.Kit;
|
||||
using AibisDream.SaveSystem;
|
||||
using AibisDream.Utility;
|
||||
using DG.Tweening;
|
||||
using AibisDream.Utility;using DG.Tweening;
|
||||
using UnityEngine;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
|
||||
@@ -1013,171 +1011,6 @@ namespace AibisDream
|
||||
yield return HideLargeObj(duration);
|
||||
}
|
||||
|
||||
public ShowcaseSnapshotDto CaptureSnapshot()
|
||||
{
|
||||
if (IsKiteShowing)
|
||||
{
|
||||
return HiddenShowcaseSnapshot();
|
||||
}
|
||||
|
||||
if (IsSmallShowing && !string.IsNullOrEmpty(_currentSmallPicName))
|
||||
{
|
||||
return new ShowcaseSnapshotDto
|
||||
{
|
||||
displayMode = nameof(ShowcaseDisplayMode.Small),
|
||||
picName = _currentSmallPicName,
|
||||
usesSplitLayers = _currentSmallUsesSplitLayers
|
||||
};
|
||||
}
|
||||
|
||||
if (IsLargeShowing && !string.IsNullOrEmpty(_currentLargePicName))
|
||||
{
|
||||
return new ShowcaseSnapshotDto
|
||||
{
|
||||
displayMode = nameof(ShowcaseDisplayMode.Large),
|
||||
picName = _currentLargePicName
|
||||
};
|
||||
}
|
||||
|
||||
return HiddenShowcaseSnapshot();
|
||||
}
|
||||
|
||||
private static ShowcaseSnapshotDto HiddenShowcaseSnapshot()
|
||||
{
|
||||
return new ShowcaseSnapshotDto
|
||||
{
|
||||
displayMode = nameof(ShowcaseDisplayMode.None)
|
||||
};
|
||||
}
|
||||
|
||||
public IEnumerator RestoreSnapshotAsync(ShowcaseSnapshotDto snapshot, Action<string> warning = null)
|
||||
{
|
||||
ClearPresentationEffects();
|
||||
if (snapshot == null) yield break;
|
||||
|
||||
if (!Enum.TryParse(snapshot.displayMode, true, out ShowcaseDisplayMode mode))
|
||||
{
|
||||
warning?.Invoke($"[SpriteShowcase] Unknown display mode: {snapshot.displayMode}");
|
||||
yield break;
|
||||
}
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case ShowcaseDisplayMode.None:
|
||||
yield break;
|
||||
|
||||
case ShowcaseDisplayMode.Small:
|
||||
if (string.IsNullOrWhiteSpace(snapshot.picName))
|
||||
{
|
||||
warning?.Invoke("[SpriteShowcase] Small snapshot is missing picName.");
|
||||
yield break;
|
||||
}
|
||||
|
||||
yield return RestoreSmallImmediate(snapshot.picName, snapshot.usesSplitLayers, warning);
|
||||
yield break;
|
||||
|
||||
case ShowcaseDisplayMode.Large:
|
||||
if (string.IsNullOrWhiteSpace(snapshot.picName))
|
||||
{
|
||||
warning?.Invoke("[SpriteShowcase] Large snapshot is missing picName.");
|
||||
yield break;
|
||||
}
|
||||
|
||||
yield return RestoreLargeImmediate(snapshot.picName, warning);
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator RestoreSmallImmediate(string picName, bool usesSplitLayers, Action<string> warning)
|
||||
{
|
||||
if (_spriteRenderer == null) yield break;
|
||||
|
||||
var normalizedName = NormalizeDreamPicName(picName);
|
||||
_smallMotionBaseOffset = IsReelPic(normalizedName) ? new Vector3(0f, -0.32f, 0f) : Vector3.zero;
|
||||
_spriteRenderer.gameObject.SetActive(true);
|
||||
|
||||
if (usesSplitLayers)
|
||||
{
|
||||
if (!TryGetSplitMotionPicNames(picName, out var basePicName, out var motionPicName))
|
||||
{
|
||||
warning?.Invoke($"[SpriteShowcase] Split-layer snapshot is unsupported: {picName}");
|
||||
ClearSmallImmediate();
|
||||
yield break;
|
||||
}
|
||||
|
||||
var baseLoaded = false;
|
||||
yield return LoadDreamSpriteInto(
|
||||
_spriteRenderer,
|
||||
basePicName,
|
||||
value => baseLoaded = value,
|
||||
warning);
|
||||
if (!baseLoaded)
|
||||
{
|
||||
ClearSmallImmediate();
|
||||
yield break;
|
||||
}
|
||||
|
||||
EnsureSmallMotionRenderer();
|
||||
_smallMotionRenderer.gameObject.SetActive(true);
|
||||
CopySmallRendererSettings(_smallMotionRenderer, 1, SpriteMaskInteraction.VisibleInsideMask);
|
||||
ConfigureSmallMotionMask();
|
||||
ResetSmallTransform();
|
||||
|
||||
var motionLoaded = false;
|
||||
yield return LoadDreamSpriteInto(
|
||||
_smallMotionRenderer,
|
||||
motionPicName,
|
||||
value => motionLoaded = value,
|
||||
warning);
|
||||
if (!motionLoaded)
|
||||
{
|
||||
ClearSmallImmediate();
|
||||
yield break;
|
||||
}
|
||||
|
||||
_smallMotionRenderer.SetAlpha(1f);
|
||||
}
|
||||
else
|
||||
{
|
||||
var loaded = false;
|
||||
yield return LoadDreamSpriteInto(
|
||||
_spriteRenderer,
|
||||
picName,
|
||||
value => loaded = value,
|
||||
warning);
|
||||
if (!loaded)
|
||||
{
|
||||
ClearSmallImmediate();
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
_spriteRenderer.SetAlpha(1f);
|
||||
_currentSmallPicName = normalizedName;
|
||||
_currentSmallUsesSplitLayers = usesSplitLayers;
|
||||
}
|
||||
|
||||
private IEnumerator RestoreLargeImmediate(string picName, Action<string> warning)
|
||||
{
|
||||
if (_largeSpriteRenderer == null) yield break;
|
||||
|
||||
_largeSpriteRenderer.gameObject.SetActive(true);
|
||||
var loaded = false;
|
||||
yield return LoadDreamSpriteInto(
|
||||
_largeSpriteRenderer,
|
||||
picName,
|
||||
value => loaded = value,
|
||||
warning);
|
||||
if (!loaded)
|
||||
{
|
||||
ClearLargeImmediate();
|
||||
yield break;
|
||||
}
|
||||
|
||||
_largeSpriteRenderer.SetAlpha(1f);
|
||||
_currentLargePicName = NormalizeDreamPicName(picName);
|
||||
}
|
||||
|
||||
public void ClearPresentationEffects()
|
||||
{
|
||||
ClearSmallImmediate();
|
||||
|
||||
Reference in New Issue
Block a user