FsmUpdateStaticVersion.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using Cysharp.Threading.Tasks;
  4. using ET;
  5. using UnityEngine;
  6. using YooAsset;
  7. internal class FsmUpdateStaticVersion : IFsmNode
  8. {
  9. public string Name { private set; get; } = nameof(FsmUpdateStaticVersion);
  10. void IFsmNode.OnEnter()
  11. {
  12. PatchEventDispatcher.SendPatchStepsChangeMsg(EPatchStates.UpdateStaticVersion);
  13. GetStaticVersion().Forget();
  14. }
  15. void IFsmNode.OnUpdate()
  16. {
  17. }
  18. void IFsmNode.OnExit()
  19. {
  20. }
  21. private async UniTaskVoid GetStaticVersion()
  22. {
  23. UniTaskCompletionSource uniTaskCompletionSource = new UniTaskCompletionSource();
  24. // 更新资源版本号
  25. var operation = YooAssets.UpdateStaticVersionAsync(30);
  26. operation.Completed += _ => { uniTaskCompletionSource.TrySetResult(); };
  27. await uniTaskCompletionSource.Task;
  28. if (operation.Status == EOperationStatus.Succeed)
  29. {
  30. Debug.Log($"Found static version : {operation.ResourceVersion}");
  31. PatchUpdater.ResourceVersion = operation.ResourceVersion;
  32. FsmManager.Transition(nameof(FsmUpdateManifest));
  33. }
  34. else
  35. {
  36. PatchEventDispatcher.SendStaticVersionUpdateFailedMsg();
  37. }
  38. }
  39. }