Ejemplo n.º 1
0
        /**
         * Activate the server-side path calculation for a given ped
         *
         * @param ped Ped which path should be calculated by the server
         */
        public void AddPedMovementCalculcation(Ped ped, bool SetCurrentNavmashPositionsIndex = true)
        {
            if (ped.Freeze || ped.Dead || !ped.Wandering)
            {
                return;
            }
            if (SetCurrentNavmashPositionsIndex)
            {
                ped.CurrentNavmashPositionsIndex = GetNearestNavMeshOfPed(ped);
            }

            if (ped.CurrentNavmashPositionsIndex < 0 || ped.PathPositions.Count >= ped.CurrentNavmashPositionsIndex)
            {
                ped.Wandering = true;
                return;
            }

            ped.Position = ped.PathPositions[ped.CurrentNavmashPositionsIndex].Position;

            if (ped.PathPositions.Count < ped.CurrentNavmashPositionsIndex + 1)
            {
                ped.ContinueWandering();
                ped.CurrentNavmashPositionsIndex = 0;
            }

            AddPedMovement(
                (int)Math.Ceiling(Vector3Utils.GetDistanceBetweenPos(ped.Position, ped.PathPositions[ped.CurrentNavmashPositionsIndex + 1].Position)),
                ped
                );
        }