public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { base.OnStateEnter(animator, stateInfo, layerIndex); if (_pathFinder == null) _pathFinder = AICtrl.GetComponent<Pathfinder>(); if(_input == null) _input = AICtrl.ControlledBy.GetComponent<InputManager>(); #if UNITY_EDITOR if (_pathFinder == null) Debug.LogError("No PathFinder in AIController object!"); #endif if (AICtrl.StateMachineAnimator.GetBool("IsDead")) Interrupt(); if (!bHasInit && _wpCtrl == null) { _wpCtrl = AICtrl.GetComponent<WaypointControl>(); bHasInit = true; } _wpCtrl.EOnPointReached -= this.OnPointReached; _wpCtrl.EOnFirstPointReached -= this.OnFirstPointReached; _wpCtrl.EOnLastPointReached -= this.OnLastPointReached; _wpCtrl.EOnPointReached += this.OnPointReached; _wpCtrl.EOnFirstPointReached += this.OnFirstPointReached; _wpCtrl.EOnLastPointReached += this.OnLastPointReached; AICtrl.LadderClimberCmp.EOnLadderUnset -= OffTheLadder; AICtrl.LadderClimberCmp.EOnLadderUnset += OffTheLadder; }//OnStateEnter
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { base.OnStateEnter(animator, stateInfo, layerIndex); if (_wpCtrl == null) _wpCtrl = this.AICtrl.GetComponent<WaypointControl>(); Vector3 distressPoint = Vector3.one * float.NegativeInfinity; if (target == null) { distressPoint = findTarget(); Vector3 from = this.AICtrl.ControlledBy.transform.position; this.huntPath = _pathFinder.FindPath(from, distressPoint); if (this.huntPath == null) { //this.Interrupt(); //return; } _wpCtrl.SetPatrolPath(this.huntPath); } //FIXME: GARBAGE for debugging if (distressPoint.x != float.NegativeInfinity) { if (SearchAreaNotifier != null) { var particle = Instantiate(SearchAreaNotifier); Vector3 pos = distressPoint; pos.y += 1f; particle.transform.position = pos; } } this.enteredTime = Time.timeSinceLevelLoad; }//OnStateEnter
}//OnLastPointReached protected override void OnFirstPointReached(WaypointControl wpCtrl) { base.OnFirstPointReached(wpCtrl); if (wpCtrl.IsWaitingAtWaypoint) { this.deferPointSwitch = true; return; } wpCtrl.FlipIterationIndex(); }//OnFirstPointReached
public MovementAction(Location location, Point destinationPoint, VehicleParameters vehicleParameters, VehicleSpecific vehicleSpecific) { vehicleState = VehicleState.Moving; this.destinationPoint = destinationPoint; wayPointControl = new WaypointControl(location, vehicleParameters); this.vehicleParameters = vehicleParameters; this.vehicleSpecific = vehicleSpecific; this.location = location; }
}//Action protected override void OnLastPointReached(WaypointControl wpCtrl) { base.OnLastPointReached(wpCtrl); if (wpCtrl.IsWaitingAtWaypoint) { this.deferPointSwitch = true; return; } wpCtrl.FlipIterationIndex(); if (!bUsePatrolPath) { var t = wpCtrl.GetActivePoint(); wpCtrl.ResetPatrolPoints(); bUsePatrolPath = true; this.target = wpCtrl.GetNext(t).transform; } }//OnLastPointReached
/// <summary> /// Is a WaypointControl event subscribtion callback. /// Called when actor reaches a First in its path waypoint node. /// </summary> /// <param name="wpCtrl">A WaypointControl cmp that has called this /// function or the way that controls the waypoint /// that has been reached. /// </param> protected virtual void OnFirstPointReached(WaypointControl wpCtrl) {}