/// <summary> /// Called after <see cref="IUtilityAIClient.Stop"/>. /// </summary> protected override void OnStop() { if (_lbHandle != null) { _lbHandle.Stop(); _lbHandle = null; } }
/// <summary> /// Called after <see cref="M:Apex.AI.Components.IUtilityAIClient.Stop" />. /// </summary> protected override void OnStop() { if (_lbHandle == null) { return; } _lbHandle.Stop(); _lbHandle = null; }
private void Update() { if (Input.GetKeyUp(KeyCode.Alpha1)) { _counter = 0; //Here we schedule some work to repeat 4 times, i.e. it will execute a total of 5 times. var action = new RepeatableAction(DoWork, 4); //Here we schedule the action to start as soon as possible and repeat at the default interval of the load balancer. ExamplesLoadBalancer.examplesBalancer.Add(action); } else if (Input.GetKeyUp(KeyCode.Alpha2)) { //Here we create an action using an anonymous method. We also do not specify a repetition count, instead we control the life time in the method. int counter = 0; var action = new RepeatableAction( (t) => { Debug.Log("Execution " + ++counter + " done after " + t.ToString() + " seconds"); return(counter < 5); }); //Here we schedule the action to take place after a short delay of 3 seconds or as soon after that delay as possible. //It will then repeat with an interval of 2 seconds. ExamplesLoadBalancer.examplesBalancer.Add(action, 2f, 3f); } else if (Input.GetKeyUp(KeyCode.Alpha3)) { //Here we create an action using an anonymous method. We also do not specify a repetition count, and instruct it to continue indefinitely. //The only way to stop it is to use the handle returned from the load balancer when the action is added. int counter = 0; var action = new RepeatableAction( (t) => { Debug.Log("Execution " + ++counter + " done after " + t.ToString() + " seconds"); return(true); }); //Here we schedule the action to take as soon as possible. //It will then repeat with an interval of 2 seconds. _handle = ExamplesLoadBalancer.examplesBalancer.Add(action, 2f); } else if (Input.GetKeyUp(KeyCode.Alpha4)) { //Here we stop the action initiated in 3 above if (_handle != null) { _handle.Stop(); } } }
public void MoveToSticky(Vector3 destination) { _destination = destination; if (_pollHandle != null) { _pollHandle.Stop(); } GameServices.messageBus.Unsubscribe(this); GameServices.messageBus.Subscribe(this); _unit.MoveTo(destination, false); }
private void Update() { if (Input.GetKeyUp(KeyCode.F)) { var unit = this.GetUnitFacade(); _followHandle = unit.Follow(target); } else if (Input.GetKeyUp(KeyCode.S)) { var unit = this.GetUnitFacade(); unit.Stop(); _followHandle.Stop(); } }
private void Update() { if (Input.GetKeyUp(KeyCode.Alpha1)) { //So here we create a long running action which will complete the DoWork call but only use 3 ms per frame, hence spreading it out across numerous frames. var action = new LongRunningAction(DoWork, 3); //We schedule it to run each frame if possible _handle = ExamplesLoadBalancer.extraBalancer.Add(action, 0f); } else if (Input.GetKeyUp(KeyCode.Alpha2)) { //Here we stop the action initiated in 3 above if (_handle != null) { _handle.Stop(); } } }