ITargetSelector.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace FL.Battle
  5. {
  6. /// <summary>
  7. /// 目标查找方式
  8. /// </summary>
  9. public enum ETargetFindType
  10. {
  11. /// <summary>
  12. /// 找最近的
  13. /// 过滤移动和受保护的
  14. /// </summary>
  15. Nearest = 0,
  16. /// <summary>
  17. /// 找最近的
  18. /// 只过滤死亡,其他状态都可选
  19. /// </summary>
  20. NearestAlive,
  21. /// <summary>
  22. /// 找范围内的
  23. /// 过滤移动和受保护的
  24. /// </summary>
  25. InRange,
  26. /// <summary>
  27. /// 找范围内的
  28. /// 只过滤死亡,其他状态都可选
  29. /// </summary>
  30. InRangeAlive,
  31. }
  32. public struct FinderInfo
  33. {
  34. public long uid;
  35. /// <summary>
  36. /// 世界坐标
  37. /// </summary>
  38. public Vector3 position;
  39. /// <summary>
  40. /// 半径
  41. /// </summary>
  42. public float radius;
  43. }
  44. /// <summary>
  45. /// 目标选择器
  46. /// </summary>
  47. public interface ITargetSelector
  48. {
  49. ITarget GetTarget(long entityId);
  50. ITarget GetPlayer();
  51. /// <summary>
  52. /// 同步查找目标
  53. /// </summary>
  54. /// <param name="finder"></param>
  55. /// <param name="targetType"></param>
  56. /// <param name="findType"></param>
  57. /// <param name="customFilter">自定义过滤器,不能选择时返回true</param>
  58. /// <returns></returns>
  59. ITarget FindSync(ITarget finder, EEntityType targetType, ETargetFindType findType = ETargetFindType.Nearest, Func<ITarget, bool> customFilter = null);
  60. /// <summary>
  61. /// 同步查找目标
  62. /// </summary>
  63. /// <param name="finder"></param>
  64. /// <param name="targetType"></param>
  65. /// <param name="findType"></param>
  66. /// <param name="customFilter">自定义过滤器,不能选择时返回true</param>
  67. /// <returns></returns>
  68. ITarget FindSync(FinderInfo finder, EEntityType targetType, ETargetFindType findType = ETargetFindType.Nearest, Func<ITarget, bool> customFilter = null);
  69. /// <summary>
  70. /// 查找范围内所有目标
  71. /// ETargetFindType.Nearest和NearestAlive无效
  72. /// </summary>
  73. /// <param name="finder"></param>
  74. /// <param name="targetType"></param>
  75. /// <param name="findType"></param>
  76. /// <param name="customFilter"></param>
  77. /// <param name="targets"></param>
  78. /// <returns></returns>
  79. bool FindTargets(FinderInfo finder, EEntityType targetType, ETargetFindType findType, Func<ITarget, bool> customFilter, ref List<ITarget> targets);
  80. /// <summary>
  81. /// 查找范围内所有目标
  82. /// ETargetFindType.Nearest和NearestAlive无效
  83. /// </summary>
  84. /// <param name="rect"></param>
  85. /// <param name="targetType"></param>
  86. /// <param name="findType"></param>
  87. /// <param name="customFilter"></param>
  88. /// <param name="targets"></param>
  89. /// <returns></returns>
  90. bool FindTargets(Rect rect, EEntityType targetType, ETargetFindType findType, Func<ITarget, bool> customFilter, ref List<ITarget> targets);
  91. /// <summary>
  92. /// 异步查找目标
  93. /// </summary>
  94. /// <param name="finder"></param>
  95. /// <param name="targetType"></param>
  96. /// <param name="findType"></param>
  97. /// <param name="onSelected"></param>
  98. void FindAsync(ITarget finder, EEntityType targetType, ETargetFindType findType, Action<ITarget> onSelected);
  99. /// <summary>
  100. /// 随机一个目标类型的坐标
  101. /// </summary>
  102. /// <param name="targetType"></param>
  103. /// <param name="isCloseToTarget">是否要靠近目标类型</param>
  104. /// <param name="customFilter">自定义过滤器,不能选择时返回true</param>
  105. /// <returns></returns>
  106. Vector3 RandomPosition(EEntityType targetType, bool isCloseToTarget, Func<ITarget, bool> customFilter = null);
  107. }
  108. }