Exemple #1
0
    private void UpdateLocomotion()
    {
        UpdateLocomotionBidsAndPath();

        if (CurrentlyDockedWith != null && !CurrentlyDockedWith.DockingTiles().Contains(transform.position))
        {
            // We were docked with an object, but are not anymore.
            perceptionRoot.DeleteKey(SDockedWith);
            CurrentlyDockedWith = null;
        }

        if (currentPath != null)
        {
            // Update the steering
            if (currentPath.UpdateSteering(steering) ||
                (Vector2.Distance(transform.position, currentDestination.transform.position) < 0.75 &&
                 currentDestination.IsCharacter()))
            {
                // Finished the path
                CurrentlyDockedWith = CurrentDestination;
                ELNode.Store(perceptionRoot / SDockedWith % CurrentlyDockedWith);
                ELNode.Store(lastDestination % CurrentDestination);
                currentPath        = null;
                currentDestination = null;
                (motorRoot / SWalkingTo).DeleteSelf();
                Face(CurrentlyDockedWith);
                steering.Stop();
                QueueEvent("arrived_at", CurrentlyDockedWith);
            }
        }
    }