chore(m2): 保存功能验收及后续清理前检查点

This commit is contained in:
Liubing\LB
2026-10-10 20:40:27 +08:00
parent d3c5394a55
commit 144e7f739f
110 changed files with 12672 additions and 7514 deletions

View File

@@ -7,7 +7,6 @@ using GameCore;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using UniRx;
using UnityEngine;
@@ -25,52 +24,6 @@ public class ShowHandEvent
[DefaultExecutionOrder(10000)]
public partial class FishingBehaviorB : MonoBehaviour
{
#if UNITY_EDITOR && !SERVICE_HOST
game.PlayerDataStorage.PlayerKVGameplayLoop.FishingAction kvFishingAction;
bool KVFishingCurrent()
{
if(!game.PlayerDataStorage.PlayerKVGameplayLoop.Enabled) return true;
return this!=null && isActiveAndEnabled && game.PlayerDataStorage.PlayerKVGameplayLoop.FishingCurrent(kvFishingAction);
}
void CancelKVFishing(string reason) => game.PlayerDataStorage.PlayerKVGameplayLoop.CancelFishing(kvFishingAction,reason);
void TrackKVCastTween(Tween tween)
{
if(!game.PlayerDataStorage.PlayerKVGameplayLoop.Enabled) return;
var action=kvFishingAction;
bool completed=false;
tween.onComplete+=()=>completed=true;
tween.onKill+=()=> { if(!completed) game.PlayerDataStorage.PlayerKVGameplayLoop.CancelFishing(action,"cast tween killed"); };
}
async Task ConsumeBaitOnKVAsync()
{
try
{
if(!KVFishingCurrent()) return;
if(!game.PlayerDataStorage.PlayerKVGameplayLoop.ClaimFishingConsumption(kvFishingAction)) return;
if(fishingData.fishItem==null || !fishingData.IsGeneralFish() || fishingData.IsFree || fishingData.IsRetry ||
fishingData.IsDuel || fishingData.IsPackItemFish() || fishingData.curFishData==null)
throw game.PlayerDataStorage.PlayerKVGameplayLoop.Stop("Only one ordinary paid fishing action is permitted. fishItem.ID="+(fishingData.fishItem==null?"null":fishingData.fishItem.ID.ToString())+", fishItem.SubType="+(fishingData.fishItem==null?"null":fishingData.fishItem.SubType.ToString())+", curFishData.ID="+(fishingData.curFishData==null?"null":fishingData.curFishData.ID.ToString())+", IsFree="+fishingData.IsFree+", IsRetry="+fishingData.IsRetry+", IsDuel="+fishingData.IsDuel);
if(Application.internetReachability==NetworkReachability.NotReachable)
throw game.PlayerDataStorage.PlayerKVGameplayLoop.Stop("Fishing stopped before consumption: offline.");
if(_tables.TbFishingEvent.DataList.Any(e=>e.ConditionList.Any(c=>c.Condition==ConditionType.ConsumeEnergy)))
throw game.PlayerDataStorage.PlayerKVGameplayLoop.Stop("ConsumeEnergy activity activation requires separate review.");
var player=GContext.container.Resolve<PlayerData>();
int mag=player.magnification;
if(mag<0 || mag>=_tables.TbEnergyDef.DataList.Count)
throw game.PlayerDataStorage.PlayerKVGameplayLoop.Stop("Invalid fishing magnification.");
int fish=fishingData.curFishData.ID, rod=fishingData.RodId, map=player.lastMapId;
int cost=_tables.TbEnergyDef.DataList[mag].Mag;
game.PlayerDataStorage.PlayerKVGameplayLoop.PrepareFishingReward(kvFishingAction,fishingData);
await player.ConsumeEnergyForKVLoopAsync(cost,kvFishingAction);
if(!KVFishingCurrent()) return;
if(fishingData.curFishData==null || fishingData.curFishData.ID!=fish || fishingData.RodId!=rod ||
player.lastMapId!=map || (int)player.magnification!=mag || fishingData.IsFree || fishingData.IsRetry || fishingData.IsDuel)
throw game.PlayerDataStorage.PlayerKVGameplayLoop.Stop("Fishing context changed during confirmation.");
game.PlayerDataStorage.PlayerKVGameplayLoop.ContinueFishing(kvFishingAction,WaitForFishBiteED);
}
catch(Exception e) { game.PlayerDataStorage.PlayerKVGameplayLoop.Fault(e.Message); }
}
#endif
IPlayerSaveStore saveStore;
Tables _tables;
[Header("RELATED OBJECT SETTINGS")]
@@ -762,25 +715,9 @@ public partial class FishingBehaviorB : MonoBehaviour
//开始抛鱼线
public async void CastLineBehavior()
{
#if UNITY_EDITOR && !SERVICE_HOST
if(game.PlayerDataStorage.PlayerKVGameplayLoop.Enabled)
{
try
{
var action=game.PlayerDataStorage.PlayerKVGameplayLoop.BeginFishing(this);
if(action==null) return;
kvFishingAction=action;
if(!KVFishingCurrent()) return;
}
catch(Exception e) { game.PlayerDataStorage.PlayerKVGameplayLoop.Fault(e.Message); return; }
}
#endif
//计算主画布分辨率下的宽高和屏幕的宽高的比列:
fishingData.mainCamera.DOLocalRotateQuaternion(Quaternion.identity, 0.1f);
await Awaiters.NextFrame;
#if UNITY_EDITOR && !SERVICE_HOST
if(!KVFishingCurrent()) return;
#endif
CastBait();
//播放抛竿动画
@@ -791,18 +728,12 @@ public partial class FishingBehaviorB : MonoBehaviour
rodHandleAni.SetBool("_idle", false);
rodHandleAni.SetTrigger("_drawing");
await Awaiters.Seconds(fishingBehaviorConf.audioDelay);
#if UNITY_EDITOR && !SERVICE_HOST
if(!KVFishingCurrent()) return;
#endif
GContext.Publish(new EventFishingSound(SoundType.ThrowingAudio));
GContext.Publish(new VibrationData(1));
}
private void ConsumeBait()
{
#if UNITY_EDITOR && !SERVICE_HOST
if(game.PlayerDataStorage.PlayerKVGameplayLoop.Enabled) { _=ConsumeBaitOnKVAsync(); return; }
#endif
if (fishingData.IsFree)
{
WaitForFishBiteED();
@@ -855,8 +786,8 @@ public partial class FishingBehaviorB : MonoBehaviour
{
GContext.Publish(new ConditionTypeEvent(ConditionType.ConsumeEnergy, energy));
}
var success = (await saveStore.WriteAndConfirmAsync("NewPlayerDataDic",
Newtonsoft.Json.JsonConvert.SerializeObject(commonDatas))).Confirmed;
var success = await saveStore.SyncDataImmidiate("NewPlayerDataDic",
Newtonsoft.Json.JsonConvert.SerializeObject(commonDatas));
Debug.Log($"[FishBehaviourB::ConsumeBaitOnPlayfab] {success}");
}
@@ -1004,9 +935,6 @@ public partial class FishingBehaviorB : MonoBehaviour
}
public void BaitMove()
{
#if UNITY_EDITOR && !SERVICE_HOST
if(!KVFishingCurrent()) return;
#endif
flyEndPosTrue = _bait.transform.position;
GContext.Publish(new EventFishingSound(SoundType.audio_fishing_throwing_baitintowater));
@@ -1017,12 +945,9 @@ public partial class FishingBehaviorB : MonoBehaviour
var fishEffect = _effectDic["fx_fishing_splashloopwaiting"];
float z = WaitingZ();
float timer = Mathf.Lerp(fishingBehaviorConf.waitingLineDrawMinTime, fishingBehaviorConf.waitingLineDrawMaxTime, Random.value);
var waitingTween=_bait.transform.DOLocalMoveZ(z, timer).OnUpdate(
_bait.transform.DOLocalMoveZ(z, timer).OnUpdate(
(() =>
{
#if UNITY_EDITOR && !SERVICE_HOST
if(!KVFishingCurrent()) return;
#endif
flyEndPosTrue = _bait.transform.position;
if (fishEffect)
{
@@ -1031,9 +956,6 @@ public partial class FishingBehaviorB : MonoBehaviour
fishEffect.transform.position = vector;
}
})); ;
#if UNITY_EDITOR && !SERVICE_HOST
TrackKVCastTween(waitingTween);
#endif
StartCoroutine(WaitForFishBite(timer));
}
IEnumerator PlayWaitingFx()
@@ -1056,9 +978,6 @@ public partial class FishingBehaviorB : MonoBehaviour
}
private IEnumerator WaitForFishBite(float timer)
{
#if UNITY_EDITOR && !SERVICE_HOST
if(!KVFishingCurrent()) yield break;
#endif
EventFishingSound eventFishingSound1 = new EventFishingSound(SoundType.audio_fishing_waiting);
EventFishingSound eventFishingSound2 = new EventFishingSound(SoundType.ReelingAudio, loop: true);
@@ -1068,9 +987,6 @@ public partial class FishingBehaviorB : MonoBehaviour
timer += Mathf.Lerp(fishingBehaviorConf.waitingMinTime, fishingBehaviorConf.waitingMaxTime, Random.value) * (1 - EnhancedWaitingTime);
yield return new WaitForSeconds(timer);
#if UNITY_EDITOR && !SERVICE_HOST
if(!KVFishingCurrent()) yield break;
#endif
if (eventFishingSound2.Sound != null)
{
@@ -1194,27 +1110,18 @@ public partial class FishingBehaviorB : MonoBehaviour
}
private async void CastBait()
{
#if UNITY_EDITOR && !SERVICE_HOST
if(!KVFishingCurrent()) return;
#endif
InitEffect();
if (fishingBehaviorConf.fishFreeControlTime > 0f)
{
await new WaitForSeconds(fishingBehaviorConf.fishFreeControlTime);
#if UNITY_EDITOR && !SERVICE_HOST
if(!KVFishingCurrent()) return;
#endif
_isCastLine = true;
_bait.transform.SetParent(transform);
var castX=_bait.transform.DOMoveX(0, fishingBehaviorConf.flyToWaterTime);
var castZ=_bait.transform.DOMoveZ(fishingBehaviorConf.flyDistance, fishingBehaviorConf.flyToWaterTime).SetEase(fishingBehaviorConf.flyForwardCurve);
_bait.transform.DOMoveX(0, fishingBehaviorConf.flyToWaterTime);
_bait.transform.DOMoveZ(fishingBehaviorConf.flyDistance, fishingBehaviorConf.flyToWaterTime).SetEase(fishingBehaviorConf.flyForwardCurve);
_cameraAnimator.SetTrigger("_waiting");
var castY=_bait.transform.DOMoveY(_waterHeight, fishingBehaviorConf.flyToWaterTime)
_bait.transform.DOMoveY(_waterHeight, fishingBehaviorConf.flyToWaterTime)
.SetEase(fishingBehaviorConf.flyDownCurve).OnComplete((() =>
{
#if UNITY_EDITOR && !SERVICE_HOST
if(!KVFishingCurrent()) return;
#endif
fishingRodAnimator.SetTrigger("_waiting");
GContext.Publish(ERightState.Waiting);
LoadEffect("fx_fishing_splashinto");
@@ -1224,25 +1131,16 @@ public partial class FishingBehaviorB : MonoBehaviour
BaitMove();
_bait.SetActive(false);
}));
#if UNITY_EDITOR && !SERVICE_HOST
TrackKVCastTween(castX); TrackKVCastTween(castZ); TrackKVCastTween(castY);
#endif
AddLinePos();
}
else
{
await new WaitForSeconds(1.15f);
#if UNITY_EDITOR && !SERVICE_HOST
if(!KVFishingCurrent()) return;
#endif
//当前动画_fishingRodAnimator播放时间
float time = fishingRodAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime;
_isCastLine = true;
_cameraAnimator.SetTrigger("_waiting");
await new WaitForSeconds(time);
#if UNITY_EDITOR && !SERVICE_HOST
if(!KVFishingCurrent()) return;
#endif
_bait.transform.SetParent(transform);
_bait.SetActive(false);
//鱼漂位置
@@ -2023,9 +1921,6 @@ public partial class FishingBehaviorB : MonoBehaviour
_cameraAnimator.SetBool("_reeling", false);
fishingRodAnimator.SetBool("_pulling", false);
CameraPullingEnd();
#if UNITY_EDITOR && !SERVICE_HOST
if(game.PlayerDataStorage.PlayerKVGameplayLoop.Enabled && (!KVFishingCurrent() || !game.PlayerDataStorage.PlayerKVGameplayLoop.RewardCanAdvance)) yield break;
#endif
fishingData.IsCaughtFish = true;
PlayCollectingEffect();
if (fx_fishing_splashwaveloop != null)
@@ -2438,9 +2333,6 @@ public partial class FishingBehaviorB : MonoBehaviour
private void OnDisable()
{
#if UNITY_EDITOR && !SERVICE_HOST
CancelKVFishing("disabled");
#endif
CloseAllEffect();
}
public void CloseAllEffect()
@@ -2464,9 +2356,6 @@ public partial class FishingBehaviorB : MonoBehaviour
}
private void OnDestroy()
{
#if UNITY_EDITOR && !SERVICE_HOST
CancelKVFishing("destroyed");
#endif
disposables?.Dispose();
disposables = null;
foreach (var o in _effectDic)