public override ActionResult Execute(AI ai) { RaycastHit hit; if (Physics.Raycast(ai.Body.transform.position, -Vector3.up, out hit, 5.0f)) { GameObject go = hit.collider.gameObject; if (go == null) { return(ActionResult.FAILURE); } WaypointRig wRig = go.GetComponentInChildren <WaypointRig>(); if (wRig != null) { ai.WorkingMemory.SetItem("waypointPathToUse", wRig.gameObject); return(ActionResult.SUCCESS); } else { return(ActionResult.FAILURE); } } return(ActionResult.FAILURE); }
private WaypointSet GetWaypointSetFromExpression(AI ai) { WaypointSet waypointSet = null; if (WaypointNetwork != null && WaypointNetwork.IsValid) { if (WaypointNetwork.IsVariable) { string varName = WaypointNetwork.VariableName; if (ai.WorkingMemory.ItemExists(varName)) { Type t = ai.WorkingMemory.GetItemType(varName); if (t == typeof(WaypointRig) || t.IsSubclassOf(typeof(WaypointRig))) { WaypointRig wgComp = ai.WorkingMemory.GetItem <WaypointRig>(varName); if (wgComp != null) { waypointSet = wgComp.WaypointSet; } } else if (t == typeof(WaypointSet) || t.IsSubclassOf(typeof(WaypointSet))) { waypointSet = ai.WorkingMemory.GetItem <WaypointSet>(varName); } else if (t == typeof(GameObject)) { GameObject go = ai.WorkingMemory.GetItem <GameObject>(varName); if (go != null) { WaypointRig wgComp = go.GetComponentInChildren <WaypointRig>(); if (wgComp != null) { waypointSet = wgComp.WaypointSet; } } } else { string setName = ai.WorkingMemory.GetItem <string>(varName); if (!string.IsNullOrEmpty(setName)) { waypointSet = NavigationManager.Instance.GetWaypointSet(setName); } } } else { if (!string.IsNullOrEmpty(varName)) { waypointSet = NavigationManager.Instance.GetWaypointSet(varName); } } } else if (WaypointNetwork.IsConstant) { waypointSet = NavigationManager.Instance.GetWaypointSet(WaypointNetwork.Evaluate <string>(0, ai.WorkingMemory)); } } return(waypointSet); }