// Get all the TrajectoryXXXPlanners, and sort them according to their PlanNumber
        public static ICollection<TrajectoryPlannerBase> SortPlanners(
            ICollection<TrajectoryPlannerBase> unsortedPlanners)
        {
            var result = new TrajectoryPlannerBase[unsortedPlanners.Count];
            if (unsortedPlanners.Count == 0)
            {
                throw new MissingComponentException("Tried to use a " +
                "TurretHelper on a gameobject without any TrajectoryPlanner");
            }

            foreach (var planner in unsortedPlanners)
            {
                if (planner.planNumber < 0 || planner.planNumber >= result.Length)
                {
                    throw new UnityException(
                        "Tried to use an out-of-bounds PlanNumber in a TrajectoryPlanner");
                }
                if (result[planner.planNumber] != null)
                {
                    throw new UnityException("Tried to use the same TrajectoryPlanner " +
                        "planNumber multiple times in a gameobject");
                }
                result[planner.planNumber] = planner;
            }

            return result;
        }
Esempio n. 2
0
        // Get all the TrajectoryXXXPlanners, and sort them according to their PlanNumber
        public static ICollection <TrajectoryPlannerBase> SortPlanners(
            ICollection <TrajectoryPlannerBase> unsortedPlanners)
        {
            var result = new TrajectoryPlannerBase[unsortedPlanners.Count];

            if (unsortedPlanners.Count == 0)
            {
                throw new MissingComponentException("Tried to use a " +
                                                    "TurretHelper on a gameobject without any TrajectoryPlanner");
            }

            foreach (var planner in unsortedPlanners)
            {
                if (planner.planNumber < 0 || planner.planNumber >= result.Length)
                {
                    throw new UnityException(
                              "Tried to use an out-of-bounds PlanNumber in a TrajectoryPlanner");
                }
                if (result[planner.planNumber] != null)
                {
                    throw new UnityException("Tried to use the same TrajectoryPlanner " +
                                             "planNumber multiple times in a gameobject");
                }
                result[planner.planNumber] = planner;
            }

            return(result);
        }