feat(open): 支持按记忆模块切换电击闪烁图

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-25 19:47:57 +08:00
co-authored by Cursor
parent 783ef340f5
commit 0d40b8db14
6 changed files with 89 additions and 21 deletions
+14 -5
View File
@@ -257,9 +257,18 @@ MonoBehaviour:
flashBackgroundSpriteRenderer: {fileID: 0}
flashSpriteRenderer: {fileID: 0}
flashHeadSprites:
- {fileID: 21300000, guid: ec352317d5419ee46bcd238c319ac018, type: 3}
- {fileID: 21300000, guid: 79aa88d0c51f4034d8366baa2ca3ee18, type: 3}
- {fileID: 21300000, guid: abf3d660f8e0cb14395c6a334574331e, type: 3}
- {fileID: 21300000, guid: b3b0f72c692a44eaadec079c1115ff50, type: 3}
- {fileID: 21300000, guid: f14d9b9712fc439299e1f9e5bfb83047, type: 3}
- {fileID: 21300000, guid: d5503b789eaa4a9aa3694f130149fcf3, type: 3}
flashHeadSpritesWithMemory:
- {fileID: 21300000, guid: b3b0f72c692a44eaadec079c1115ff50, type: 3}
- {fileID: 21300000, guid: f14d9b9712fc439299e1f9e5bfb83047, type: 3}
- {fileID: 21300000, guid: d5503b789eaa4a9aa3694f130149fcf3, type: 3}
flashHeadSpritesWithoutMemory:
- {fileID: 21300000, guid: e81833b6be9047b9b2ecfd34f1624f1c, type: 3}
- {fileID: 21300000, guid: 9a5ceb3b6cf14fa798142a62be294400, type: 3}
- {fileID: 21300000, guid: a4510a1a86a54952a1a3c1831c667638, type: 3}
useMemoryModuleFlashSprites: 1
spriteFlashSystem: {fileID: 0}
sparkEffect1: {fileID: 126183770047723201}
sparkEffect2: {fileID: 7839986575077344566}
@@ -277,8 +286,8 @@ MonoBehaviour:
maxSliderValue: 1
progressDecreaseDuration: 1
shockEffectNode: ShockEffect
flashDuration: 0.08
flashInterval: 0.08
flashDuration: 0.1
flashInterval: 0.1
flashCount: 3
strength: 0.25
vibrate: 60
+15 -15
View File
@@ -20298,9 +20298,9 @@ SpriteRenderer:
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 1016946085
m_SortingLayer: 11
m_SortingOrder: 7
m_SortingLayerID: 467777933
m_SortingLayer: 12
m_SortingOrder: 200
m_Sprite: {fileID: 21300000, guid: fab06e0be9375cc4d823efa71629885c, type: 3}
m_Color: {r: 0, g: 0, b: 0, a: 0.6666667}
m_FlipX: 0
@@ -25138,9 +25138,9 @@ SpriteRenderer:
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 1016946085
m_SortingLayer: 11
m_SortingOrder: 8
m_SortingLayerID: 467777933
m_SortingLayer: 12
m_SortingOrder: 202
m_Sprite: {fileID: 21300000, guid: b01da57c8313bd040b2c8493173aa01b, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
@@ -25161,7 +25161,7 @@ Transform:
m_GameObject: {fileID: 1954721088}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: 3.6, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@@ -26316,9 +26316,9 @@ Transform:
m_GameObject: {fileID: 2126788500}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_LocalPosition: {x: 3.6, y: 0, z: 0}
m_LocalScale: {x: 5.24, y: 5.24, z: 1}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 866752977}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -26360,15 +26360,15 @@ SpriteRenderer:
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 1016946085
m_SortingLayer: 11
m_SortingOrder: 9
m_Sprite: {fileID: 21300000, guid: ec352317d5419ee46bcd238c319ac018, type: 3}
m_SortingLayerID: 467777933
m_SortingLayer: 12
m_SortingOrder: 201
m_Sprite: {fileID: 21300000, guid: b3b0f72c692a44eaadec079c1115ff50, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 17.3, y: 21.6039}
m_Size: {x: 3.84, y: 2.16}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
@@ -39,6 +39,15 @@ namespace AibisDream.FixSystem
yield return spriteFlashSystem.TriggerEnding(imagePath, duration);
}
/// <summary>
/// 切换电击闪烁图:true=带记忆模块,false=不带(切割记忆后)。
/// </summary>
[YarnCommand("set_shock_flash_memory")]
public static void SetShockFlashMemory(bool hasMemoryModule)
{
ShockSystem.SetUseMemoryModuleFlashSprites(hasMemoryModule);
}
[YarnCommand("start_shock")]
public static IEnumerator StartShock()
{
@@ -26,7 +26,10 @@ public class ShockSystem : MonoBehaviour, IInteraction
[SerializeField] private SpriteRenderer flashHeadSpriteRenderer; // 头部闪烁精灵渲染器
[SerializeField] private SpriteRenderer flashBackgroundSpriteRenderer; // 背景闪烁精灵渲染器
[SerializeField] private SpriteRenderer flashSpriteRenderer;
[SerializeField] private List<Sprite> flashHeadSprites; // 头部闪烁精灵列表
[SerializeField] private List<Sprite> flashHeadSprites; // 当前生效的头部闪烁精灵列表(运行时由两套资源切换)
[SerializeField] private List<Sprite> flashHeadSpritesWithMemory; // 切割记忆模块前:带记忆模块
[SerializeField] private List<Sprite> flashHeadSpritesWithoutMemory; // 切割记忆模块后:不带记忆模块
[SerializeField] private bool useMemoryModuleFlashSprites = true; // 是否使用带记忆模块的电击图
[SerializeField] private SpriteFlashSystem spriteFlashSystem; // Sprite闪烁系统
[SerializeField] private GameObject sparkEffect1; // 火花特效1
[SerializeField] private GameObject sparkEffect2; // 火花特效2
@@ -202,6 +205,45 @@ public class ShockSystem : MonoBehaviour, IInteraction
// 确保火花效果初始状态为关闭
if (sparkEffect1 != null) sparkEffect1.SetActive(false);
if (sparkEffect2 != null) sparkEffect2.SetActive(false);
ApplyFlashHeadSpriteSet(useMemoryModuleFlashSprites);
}
/// <summary>
/// 切换电击闪烁用的头部图集:切割记忆模块前用带模块图,切后用不带模块图。
/// </summary>
public void SetUseMemoryModuleFlashSprites(bool useMemoryModule)
{
ApplyFlashHeadSpriteSet(useMemoryModule);
}
private void ApplyFlashHeadSpriteSet(bool useMemoryModule)
{
useMemoryModuleFlashSprites = useMemoryModule;
var source = useMemoryModule ? flashHeadSpritesWithMemory : flashHeadSpritesWithoutMemory;
if (source != null && source.Count > 0)
{
flashHeadSprites = source;
}
#if UNITY_EDITOR
else
{
Debug.LogWarning(
$"[ShockSystem] {(useMemoryModule ? "" : "")}电击闪烁图列表为空,仍使用当前 flashHeadSprites。",
this);
}
#endif
}
/// <summary>
/// 按 Yarn $gameStage 同步图集:1–2 带记忆模块,≥3(已切除)不带。兼容读档。
/// </summary>
private void SyncFlashSpritesFromYarnState()
{
var storage = YarnVariableStorage.Instance;
if (storage == null) return;
if (!storage.TryGetValue("$gameStage", out float stage)) return;
ApplyFlashHeadSpriteSet(stage < 3f);
}
private void Update()
@@ -426,6 +468,8 @@ public class ShockSystem : MonoBehaviour, IInteraction
public IEnumerator StartShock()
{
SyncFlashSpritesFromYarnState();
// 移动左右电击装置到各自的目标位置
var moveLeft = leftShockDevice.DOLocalMove(leftShockDeviceTargetPos, moveDuration);
var moveRight = rightShockDevice.DOLocalMove(rightShockDeviceTargetPos, moveDuration);
@@ -549,6 +593,8 @@ public class ShockSystem : MonoBehaviour, IInteraction
public IEnumerator PlayFlashEffect()
{
SyncFlashSpritesFromYarnState();
if (flashSequence != null)
{
flashSequence.Kill();
@@ -112,6 +112,8 @@ gts??: <speed=1><i>我要醒来…</i> #line:0657c1b
me: 出现异常状况。现在重新通电。 #line:0bb059f
<<clear_screen>>
<<detour 等待通电>>
// 记忆模块已切除:改用不带记忆模块的电击闪烁图
<<set_shock_flash_memory false>>
<<start_shock>>
===
@@ -20,6 +20,8 @@ position: 906,-585
<<play_sfx "event:/Scriptal/prologue_ending">>
<<wait 0.3>>
<<set_light_state Emergency>>
// Stage6 记忆模块已切除
<<set_shock_flash_memory false>>
<<start_shock>>
<<start_shock_abnormal>>
<<wait 1.5>>