private Task DoAction(MovementAction action) { var strategy = GetStrategy(action); var tcs = new TaskCompletionSource <Unit>(); strategy.Finished += () => tcs.TrySetResult(Unit.Default); _currentStrategy = strategy; return(tcs.Task); }
public async Task DoMovement(MovementCommandsQueue movementCommandsQueue) { transform.SetParent(null); foreach (var movementAction in movementCommandsQueue.Actions) { if (enabled && gameObject.activeInHierarchy) { await DoAction(movementAction); } } _currentStrategy = null; if (enabled && gameObject.activeInHierarchy) { transform.SetParent(_formationCell); transform.localRotation = Quaternion.identity; transform.localPosition = Vector3.zero; } }