예제 #1
0
        private static T Internal_CreateTask <T>() where T : Task
        {
            switch (typeof(T))
            {
            case Type taskType when taskType == typeof(MoveTask):
            {
                MoveTask t = new MoveTask();
                return(t as T);
            }

            case Type taskType when taskType == typeof(MoveTask2):
            {
                MoveTask2 t = new MoveTask2();
                return(t as T);
            }

            case Type taskType when taskType == typeof(EngageAtPositionsTask):
            {
                EngageAtPositionsTask t = new EngageAtPositionsTask();
                return(t as T);
            }

            default:
                throw new ArgumentException(
                          message: "Not a recognized type of task");
                //return null;
            }
        }
예제 #2
0
        public bool SolveParallelCompatibilityConflicts()
        {
            foreach (var pl in new List<TaskPlan2>(actorGroupAsUG.GetActorsGroupsAndSubGroupsPlans(true, true)))
            {
                if (pl.GetCurrentTaskInPlan() != this)
                {
                    MoveTask2 mvtsk = pl.GetCurrentTaskInPlan() as MoveTask2;
                    UnitGroup ug = mvtsk.GetActorGroup() as UnitGroup;
                    if (mvtsk != null/* && ug != null*/)
                    {
                        foreach (var u in new List<Unit>(units))
                        {
                            if (mvtsk.units.Contains(u))
                                ug.RemoveUnitFromGroup(u);
                        }
                        /*var intsect = mvtsk.units.Intersect(units);
                        foreach (var u in intsect)
                        {
                            ug.RemoveUnitFromGroup(u);
                        }*/
                    }

                    if (ug != null && ug.GetActors().Count == 0)
                    {
                        foreach (var subg in new List<UnitGroup>(ug.GetSubGroupsAsUG()))
                            subg.ChangeParentTo(null);
                        
                        pl.EndPlanExecution();
                    }
                }
            }

            return false;
        }