CoroutineLock.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using Fort23.Core;
  2. namespace Fort23.UTool
  3. {
  4. /// <summary>
  5. /// 协程锁
  6. /// </summary>
  7. public class CoroutineLock : Entity
  8. {
  9. public long key;
  10. public int count;
  11. public bool isTimeout;
  12. public string keyName;
  13. [CustomMethod(CustomMethodType.Awake)]
  14. public void Awake( long k,string keyName, int count)
  15. {
  16. this.keyName = keyName;
  17. this.key = k;
  18. this.count = count;
  19. }
  20. [CustomMethod(CustomMethodType.Destroy)]
  21. public void Destroy()
  22. {
  23. if (!this.isTimeout)
  24. {
  25. CoroutineLockComponent.Instance.Notify(this.key, keyName,this.count + 1);
  26. }
  27. else
  28. {
  29. LogTool.Error($"coroutine lock timeout: {this.keyName} {this.count}");
  30. }
  31. this.key = 0;
  32. this.count = 0;
  33. }
  34. }
  35. public struct CoroutineLockTimer
  36. {
  37. public CTask<CoroutineLock> tcs;
  38. /// <summary>
  39. /// 持续时间
  40. /// </summary>
  41. public int duration;
  42. public string keyName;
  43. }
  44. }