/// <summary> /// Called on Awake /// </summary> protected override void Awake() { base.Awake(); this.WarnIfMultipleInstances(); _transform = this.transform; _wayPoints = new WaypointList(); _navMessage = new UnitNavigationEventMessage(this.gameObject); _resultProcessors = this.GetComponents<SteerForPathResultProcessorComponent>(); Array.Sort(_resultProcessors, (a, b) => a.processingOrder.CompareTo(b.processingOrder)); _unit = this.GetUnitFacade(); _pathSettings = _unit.pathNavigationOptions; _stopped = true; }
private void AnnounceEvent(UnitNavigationEventMessage.Event e, Vector3 destination, Vector3[] pendingWaypoints) { _navMessage.isHandled = false; _navMessage.eventCode = e; _navMessage.destination = destination; _navMessage.pendingWaypoints = pendingWaypoints ?? Consts.EmptyVectorArray; GameServices.messageBus.Post(_navMessage); }
float? ILoadBalanced.ExecuteUpdate(float deltaTime, float nextInterval) { if (this.averageActualVelocity) { _actualVelocity = (_transform.position - _lastFramePosition) / deltaTime; _lastFramePosition = _transform.position; } if (_stopped || _waiting) { return null; } if (IsStuck(deltaTime)) { var msg = new UnitNavigationEventMessage(this.gameObject, UnitNavigationEventMessage.Event.Stuck) { destination = _unit.finalDestination.GetValueOrDefault(), pendingWaypoints = _unit.currentWaypoints.ToArray() }; Stop(); StopMovement(); GameServices.messageBus.Post(msg); return null; } UpdateInput(); return null; }
private void InitializeModelUnitSettings() { var pathNavOptions = _modelUnit != null ? _modelUnit.pathNavigationOptions : this[0].pathNavigationOptions; // cache locally the relevant path navigation options _replanMode = pathNavOptions.replanMode; _replanInterval = pathNavOptions.replanInterval; _nextNodeDistance = pathNavOptions.nextNodeDistance; _requestNextWaypointDistance = pathNavOptions.requestNextWaypointDistance; _navMessage = new UnitNavigationEventMessage(_modelUnit != null ? _modelUnit.gameObject : this[0].gameObject); }
/// <summary> /// Called on Awake /// </summary> protected override void Awake() { base.Awake(); _transform = this.transform; _wayPoints = new WaypointList(); _navMessage = new UnitNavigationEventMessage(this.gameObject); _resultProcessors = this.GetComponents<SteerForPathResultProcessorComponent>(); Array.Sort(_resultProcessors, (a, b) => a.processingOrder.CompareTo(b.processingOrder)); StartCoroutine(delayToInit()); }
/// <summary> /// Called on Awake /// </summary> protected override void Awake() { base.Awake(); this.WarnIfMultipleInstances(); _transform = this.transform; _wayPoints = new SimpleQueue<Vector3>(); _pathboundWayPoints = new SimpleQueue<Vector3>(); _navMessage = new UnitNavigationEventMessage(this.gameObject); _resultProcessors = this.GetComponents<SteerForPathResultProcessorComponent>(); Array.Sort(_resultProcessors, (a, b) => a.processingOrder.CompareTo(b.processingOrder)); _unit = this.GetUnitFacade(); _pathSettings = _unit.pathNavigationOptions; if (this.arrivalDistance > _pathSettings.nextNodeDistance) { Debug.LogError("The Arrival Distance must be equal to or less that the Next Node Distance."); } _stopped = true; _unit.hasArrivedAtDestination = true; }
/// <summary> /// Called on Awake /// </summary> protected override void Awake() { base.Awake(); this.WarnIfMultipleInstances(); if (this.arrivalDistance > this.nextNodeDistance) { Debug.LogError("The Arrival Distance must be equal to or less that the Next Node Distance."); } _wayPoints = new Queue<Vector3>(); _pathboundWayPoints = new Queue<Vector3>(); _navMessage = new UnitNavigationEventMessage(this.gameObject); _resultProcessors = this.GetComponents<SteerForPathResultProcessorComponent>(); Array.Sort(_resultProcessors, (a, b) => a.processingOrder.CompareTo(b.processingOrder)); _proximityAngleCos = Mathf.Cos(this.proximityEvaluationMinAngle * Mathf.Deg2Rad); _slowingDistanceSquared = this.slowingDistance * this.slowingDistance; _requestNextWaypointDistanceSquared = this.requestNextWaypointDistance * this.requestNextWaypointDistance; _stopped = true; }