/* * Activate the GOAP plan */ public bool Activate(Agent ai, GOAPGoal goal) { Owner = ai; /*if(ai.debugGOAP) * { * string s = this.ToString() + " - Activated for " + goal.ToString() + " do actions:"; * for (int i = 0 ; i < m_Actions.Count ; i++) * s += " " + m_Actions[i].ToString(); * * Debug.Log(Time.timeSinceLevelLoad + " " + s); * }*/ if (m_Actions.Count == 0) { return(false); } //Get the first action CurrentStep = 0; //For the first action, first check if context preconditions are satisfied. GOAPAction a = CurrentAction; if (a != null) { if (a.ValidateContextPreconditions(Owner) == false) {//Are the context preconditions validated???? //if (Owner.debugGOAP) Debug.Log(Time.timeSinceLevelLoad + " " + this.ToString() + " - " + a.ToString() + " ValidateContextPreconditions failed !!"); return(false); } a.Activate(); // if(a.IsActionComplete()) // AdvancePlan(); } return(true); }