private void InvokeDecisionEvent(bool decisionValue, MAIDecision decision) { if (decision.send == MAIDecision.WSend.SendTrue && decisionValue) { OnDecisionSucceded.Invoke(decision.MessageID); } else if (decision.send == MAIDecision.WSend.SendFalse && !decisionValue) { OnDecisionSucceded.Invoke(decision.MessageID); } }
private void AddDecision(Type desicion, int index) { MAIDecision des = (MAIDecision)CreateInstance(desicion); des.hideFlags = HideFlags.None; des.name = "D_" + desicion.Name; AssetDatabase.AddObjectToAsset(des, AssetDatabase.GetAssetPath(target)); AssetDatabase.SaveAssets(); m.transitions[index].decision = des; //the other way was not working EditorUtility.SetDirty(des); EditorUtility.SetDirty(target); transitions.serializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties(); Reo_List_Transitions.index = index; Reo_List_Tasks.index = -1; }
public virtual void TransitionToState(MAIState nextState, bool decisionValue, MAIDecision decision) { if (Time.time - TransitionLastTime >= TransitionCoolDown) //This avoid making transition on the same Frame ****IMPORTANT { if (nextState != remainInState) { TransitionLastTime = Time.time; if (debug) { Debug.Log($"Changed from <B>{currentState.name} </B> to <B>{nextState.name}</B> with the decision <b>{decision.name}</b> been <B>{decisionValue}</B>."); } InvokeDecisionEvent(decisionValue, decision); StartNewState(nextState); } } }
public virtual void TransitionToState(MAIState nextState, bool decisionValue, MAIDecision decision, int Index) { if (MTools.ElapsedTime(TransitionLastTime, TransitionCoolDown)) //This avoid making transition on the same Frame ****IMPORTANT { if (nextState != null && nextState != remainInState && nextState != currentState) //Do not transition to itself! { TransitionLastTime = Time.time; decision.FinishDecision(this, Index); Debuging($"<color=white>Changed AI State from <B>[{currentState.name}]</B> to <B>[{nextState.name}]</B>. Decision: <b>[{decision.name}]</b> = <B>[{decisionValue}]</B>.</color>"); InvokeDecisionEvent(decisionValue, decision); StartNewState(nextState); } } }