public UnitActionBase SelectAbility(UnitActionBase ability) { if (Unit.SelectedUnit != m_Owner || !HasAP() || IsAnimationPlaying() || m_Owner.IsDead()) { MDebug.Log("^abilityCould not select ability " + ability.GetActionID()); return(null); } if (currentAction != null && currentAction == ability) { if (GetOwnerID() == 0) { SoundManager.PlayAtSourceTag("SoundSFXSource", "sfx_" + SoundManager.Presets.ability_cancel.ToString()); } UnsetCurrentAction(); return(null); } UnsetCurrentAction(); if (!ability.CanExecAction(true)) { MDebug.Log("^abilitycan not execute ability " + ability.GetActionID()); if (GetOwnerID() == 0) { SoundManager.PlayAtSourceTag("SoundSFXSource", "sfx_" + SoundManager.Presets.error.ToString()); } return(null); } ToastNotification.StopToast(); currentAction = ability; currentAction.OnActionStart += OnActionUsed; currentAction.OnActionComplete += onComplete; currentAction.OnTarget += TargetedAction; currentAction.SelectAction(); if (GetOwnerID() == 0) { SoundManager.PlayAtSourceTag("SoundSFXSource", "sfx_" + SoundManager.Presets.ability_select.ToString()); } if (OnActionSelected != null) { OnActionSelected(currentAction); } return(currentAction); }