public override void OnDeselect() { base.OnDeselect(); // Unbind all inputs on this UnitHandler (meaning that callbacks will now longer be invoked for this unit on input) DefaultUnitHandler.UnbindAllInputs(ActionInputs); ClearActionInput.Unbind(DefaultUnitHandler.Instance.ClearActionQueueInput); }
public override void OnSelect() { base.OnSelect(); // Bind all the inputs on this UnitHandler (meaning that callbacks will now be invoked for this Unit on input) DefaultUnitHandler.BindAllInputs(ActionInputs); ClearActionInput.Bind(DefaultUnitHandler.Instance.ClearActionQueueInput); }
// Start is called before the first frame update protected override IEnumerator Start() { yield return(base.Start()); if (!Agent) { Agent = gameObject.GetComponent <AIAgent>(); } // If this unit is using the set of default actions then add them to this unit's list of available actions if (UseDefaultActions) { Helper.LoopList_ForEach <ActionInput>(DefaultUnitHandler.Instance.SelectionInputs, (ActionInput s) => { ActionInputs.Add(new ActionInput(s)); }); } AIAction tempAction = null; Helper.LoopList_ForEach <ActionInput>(ActionInputs, (ActionInput s) => { // Get a copy of the action associated and add it to the AIAgent's dictionary of possible actions tempAction = s.GetActionClone; if (tempAction) { Agent.SetActionInDict(s.ActionName, tempAction, true); Agent.PossibleActions.Add(tempAction); } // Set up the input callback for this action DefaultUnitHandler.AddPerformedAction(s, PerformedAction); }); if (DefaultUnitHandler.Instance.ClearActionQueueInput) { ClearActionInput.PerformedActions += (InputAction.CallbackContext cc) => { NetworkHandler.ClientInstance.CmdClearActions(Agent.gameObject); }; } }
// Start is called before the first frame update void Start() { Instance = this; }
private void OnDestroy() { // Safely unbind all the associated inputs of this UnitHandler DefaultUnitHandler.UnbindAllInputs(ActionInputs); }