|
|
@@ -14,7 +14,7 @@ namespace ET
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- self.MoveForward(false);
|
|
|
+ self.MoveForward(true);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
@@ -70,7 +70,7 @@ namespace ET
|
|
|
|
|
|
using ListComponent<float3> path = ListComponent<float3>.Create();
|
|
|
|
|
|
- self.MoveForward(true);
|
|
|
+ self.MoveForward(false);
|
|
|
|
|
|
path.Add(unit.Position); // 第一个是Unit的pos
|
|
|
for (int i = self.N; i < self.Targets.Count; ++i)
|
|
|
@@ -84,7 +84,7 @@ namespace ET
|
|
|
// 该方法不需要用cancelToken的方式取消,因为即使不传入cancelToken,多次调用该方法也要取消之前的移动协程,上层可以stop取消
|
|
|
public static async ETTask<bool> MoveToAsync(this MoveComponent self, List<float3> target, float speed, int turnTime = 100)
|
|
|
{
|
|
|
- self.Stop();
|
|
|
+ self.Stop(false);
|
|
|
|
|
|
foreach (float3 v in target)
|
|
|
{
|
|
|
@@ -109,7 +109,8 @@ namespace ET
|
|
|
return moveRet;
|
|
|
}
|
|
|
|
|
|
- private static void MoveForward(this MoveComponent self, bool needCancel)
|
|
|
+ // ret: 停止的时候,移动协程的返回值
|
|
|
+ private static void MoveForward(this MoveComponent self, bool ret)
|
|
|
{
|
|
|
Unit unit = self.GetParent<Unit>();
|
|
|
|
|
|
@@ -174,7 +175,7 @@ namespace ET
|
|
|
var tcs = self.tcs;
|
|
|
self.tcs = null;
|
|
|
self.Clear();
|
|
|
- tcs?.SetResult(!needCancel);
|
|
|
+ tcs?.SetResult(ret);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -260,11 +261,12 @@ namespace ET
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public static void Stop(this MoveComponent self)
|
|
|
+ // ret: 停止的时候,移动协程的返回值
|
|
|
+ public static void Stop(this MoveComponent self, bool ret)
|
|
|
{
|
|
|
if (self.Targets.Count > 0)
|
|
|
{
|
|
|
- self.MoveForward(true);
|
|
|
+ self.MoveForward(ret);
|
|
|
}
|
|
|
|
|
|
self.Clear();
|