Exemplo n.º 1
0
        public Task(TaskManager taskManager
                    , string description, string tipText, string code, string helpKeyword
                    , TaskPriority priority, TaskCategory category, TaskMarker markerType
                    , Location loc
                    , ITaskCommands commands
                    )
        {
            this.taskManager = taskManager;
            this.code        = code;
            this.description = description;
            this.tipText     = ((tipText == null || tipText.Length == 0) ? description : tipText);
            this.helpKeyword = helpKeyword;
            this.priority    = priority;
            this.category    = category;
            this.markerType  = markerType;
            this.commands    = commands;

            location   = (loc == null ? new Location(null, null) : loc);
            initLoc    = location.Clone();
            persistLoc = location.Clone();

            // isChecked = false;
            // isDeleted = false;
            // marker = null;

            // Create markers if the document is already opened.
            IVsTextLines textLines = location.GetTextLines(false);

            if (textLines != null)
            {
                OnOpenFile(textLines, false);
            }
        }
Exemplo n.º 2
0
        private static List <object> tokenize(string input)
        {
            Debug.Assert(input != null);

            var objects = new List <object>();

            do
            {
                input = input.Trim();
                var match = s_regex.Match(input);

                if (match.Success)
                {
                    match.Groups.Cast <Group>().ToArray();
                    string first = input.Substring(0, match.Index);
                    objects.Add(first);

                    TaskMarker second = parseMarker(match.Groups[1].Value);
                    objects.Add(second);

                    input = input.Substring(match.Index + match.Length);
                }
                else
                {
                    objects.Add(input);
                    input = "";
                }
            } while (input.Length > 0);

            return(objects);
        }
Exemplo n.º 3
0
        public void AddTask(string description, string tipText, string code, string helpKeyword
                            , TaskPriority priority, TaskCategory category
                            , TaskMarker marker, Guid outputPane
                            , string projectName
                            , string fileName, int startLine, int startColumn, int endLine, int endColumn
                            , ITaskCommands commands
                            )
        {
            // Add a new task
            Location span = new Location(projectName, fileName, startLine, startColumn, endLine, endColumn);
            Task     task = new Task(this
                                     , description, tipText, code, helpKeyword
                                     , priority, category, marker
                                     , span
                                     , commands);

            tasks.Add(task);

            // show standard error in the build output pane
            if (outputPane != TaskOutputPane.None && description != null)
            {
                string kind;
                switch (category)
                {
                case TaskCategory.Error: kind = "error "; break;

                case TaskCategory.Warning: kind = "warning "; break;

                case TaskCategory.Message: kind = "message "; break;

                default: kind = ""; break;
                }
                OutputString(span + ": " + kind + (code != null ? code : "") + ": " + description + "\n", outputPane);
            }
        }
Exemplo n.º 4
0
    public Task( TaskManager taskManager
               , string description, string tipText, string code, string helpKeyword
               , TaskPriority priority, TaskCategory category, TaskMarker markerType
               , Location loc
               , ITaskCommands commands
               )
    {
      this.taskManager = taskManager;
      this.code = code;
      this.description = description;
      this.tipText = ((tipText == null || tipText.Length == 0) ? description : tipText);
      this.helpKeyword = helpKeyword;
      this.priority = priority;
      this.category = category;
      this.markerType = markerType;
      this.commands = commands;

      this.location = (loc == null ? new Location(null, null) : loc);
      this.initLoc = this.location.Clone();
      this.persistLoc = this.location.Clone();

      // isChecked = false;
      // isDeleted = false;
      // marker = null;

      // Create markers if the document is already opened.
      IVsTextLines textLines = this.location.GetTextLines(false);
      if (textLines != null) {
        OnOpenFile(textLines);
      }
    }
Exemplo n.º 5
0
    public void AddTask(string description, string tipText, string code, string helpKeyword
                       ,TaskPriority priority, TaskCategory category
                       ,TaskMarker marker, Guid outputPane
                       ,string projectName
                       ,string fileName, int startLine, int startColumn, int endLine, int endColumn 
                       ,ITaskCommands commands
                       )
    {
      // Add a new task
      Location span = new Location(projectName,fileName, startLine, startColumn, endLine, endColumn);
      Task task = new Task(this
                          ,description, tipText, code, helpKeyword
                          ,priority, category, marker
                          ,span
                          ,commands);
      tasks.Add(task);

      // show standard error in the build output pane
      if (outputPane != TaskOutputPane.None && description != null) {
        string kind;
        switch (category) {
          case TaskCategory.Error: kind = "error "; break;
          case TaskCategory.Warning: kind = "warning "; break;
          case TaskCategory.Message: kind = "message "; break;
          default: kind = ""; break;
        }
        OutputString(span + ": " + kind + (code != null ? code : "") + ": " + description + "\n", outputPane);
      }
    }
Exemplo n.º 6
0
        private List <TaskMarker> SplitTaskMarkers(List <Titan.Task> tasks)
        {
            List <TaskMarker> markers = new List <TaskMarker>();

            for (int i = 0; i < tasks.Count; i++)
            {
                var task     = tasks[i];
                var nextTask = i + 1 < tasks.Count ? tasks[i + 1]: null;
                if (task is MoveTask)
                {
                    var        moveTask = task as MoveTask;
                    TaskMarker marker;
                    if (nextTask is ResourceTask)
                    {
                        marker = new TaskMarker()
                        {
                            Position = moveTask.Position, cancelTasks = new Titan.Task[] { moveTask, nextTask as ResourceTask }
                        };
                        i += 1;
                    }
                    else
                    {
                        marker = new TaskMarker()
                        {
                            Position = moveTask.Position, cancelTasks = new Titan.Task[] { moveTask }
                        };
                    }
                    markers.Add(marker);
                }
                if (task is ResourceTask)
                {
                    var        resourceTask = task as ResourceTask;
                    TaskMarker marker       = new TaskMarker()
                    {
                        Position = resourceTask.Position, cancelTasks = new Titan.Task[] { resourceTask }
                    };
                    markers.Add(marker);
                }
            }
            return(markers);
        }
Exemplo n.º 7
0
 private static string getMarkerName(TaskMarker tm)
 {
     return(Enum.GetName(typeof(TaskMarker), tm));
 }
Exemplo n.º 8
0
        private void UITaskMarkerCreationAndTaskBuilding<T>(List<ISelectable> selected) where T : TaskMarker
        {
            if (selected.Count > 0)
            {

                //if (_taskSubject == null)
                //    _taskSubject = PrepareAndGetSubjectFromSelected(selected);

                T taskMarker = TaskMarker.CreateInstanceAtScreenPosition<T>(UIHandler.GetPointedScreenPosition());
                taskMarker.InitBinderForTask(associatedTaskEditMenu);
                taskMarker.EnterPlacementUIMode();

                taskMarker.OnExitPlacementUIMode.SubscribeEventHandlerMethod("spawnerbuttondeactivate",// += SpawnerButtonDeactivate;
                    () =>
                    {
                        on = false;
                        taskMarker.OnExitPlacementUIMode.UnsubscribeEventHandlerMethod("spawnerbuttondeactivate");
                    });

                taskMarker.OnPlacementConfirmation.SubscribeEventHandlerMethod("onplacementconfirmationcallback",
                    (b) =>
                    {
                        if (b)
                        {
                            if (_actorGroup == null)
                                _actorGroup = UnitGroup.PrepareAndCreateGroupFromSelected(selected);

                            TaskPlan2 taskPlan = taskMarker.InsertAssociatedTaskIntoPlan(_actorGroup, _lastPlacedTaskMarkerWrapper?.Value);

                            if (!taskPlan.IsPlanBeingExecuted())
                                taskPlan.StartPlanExecution();

                            if (Input.GetKey(KeyCode.LeftShift))
                            {
                                /*if (_lastPlacedTaskMarkerWrapper == null)
                                {
                                    var tm = ITaskSubject.GetPlans().FirstOrDefault()?.GetCurrentTaskInPlan()?.GetTaskMarker();
                                    if (tm != null)
                                        _lastPlacedTaskMarkerWrapper = new MapMarkerWrapper<TaskMarker>(tm);
                                }
                                else
                                {
                                    _lastPlacedTaskMarkerWrapper = new MapMarkerWrapper<TaskMarker>(taskMarker);
                                }*/
                                _lastPlacedTaskMarkerWrapper = new MapMarkerWrapper<TaskMarker>(taskMarker);
                                OnButtonActivationOrNot(true);
                            }
                            else
                            {
                                _actorGroup = null;
                                _lastPlacedTaskMarkerWrapper = null;
                            }
                        }
                        else
                        {
                            _actorGroup = null;
                            _lastPlacedTaskMarkerWrapper = null;
                            taskMarker.OnPlacementConfirmation.UnsubscribeEventHandlerMethod("onplacementconfirmationcallback");
                            //editedTaskPlan = null;
                        }
                    });

                SelectionHandler.GetUsedSelector().SelectEntity(taskMarker);
            }
        }
Exemplo n.º 9
0
 protected override void InstanceSetTaskMarker(TaskMarker taskMarker)
 {
     _targetTaskMarkerWrapper = new MapMarkerWrapper <TargetTaskMarker>(taskMarker as TargetTaskMarker);
 }
Exemplo n.º 10
0
        protected override void InstanceSetTaskPlan(TaskPlan2 taskPlan)
        {
            base.InstanceSetTaskPlan(taskPlan);

            if (taskPlan != null)
            {
                UpdateFormationFacing(unit, GetTaskMarker().GetWorldPosition());

                unit.GetFormation().FormTest();

                foreach (var subg in actorGroupAsUG.GetSubGroupsAsUG())
                {
                    Vector3 wpos;
                    wpos = subg.GetActorsAsUnits()[0].GetFormation().GetAcceptableMovementTargetPosition(GetTaskMarker().GetWorldPosition());

                    MoveTaskMarker tm = TaskMarker.CreateInstanceAtWorldPosition <MoveTaskMarker>(wpos);
                    tm.AddWaypointMarker(WaypointMarker.CreateWaypointMarker(wpos));

                    MoveTask chmvt = tm.GetTask() as MoveTask;

                    chmvt.parentActorMoveTask = this;
                    subActorsMoveTasks.Add(subg, chmvt);

                    chmvt.SubscribeOnDestruction("removeparentssubactorsmovetasks", () => subActorsMoveTasks.Remove(subg));

                    subg.SubscribeOnParentGroupChange("onchangeparentgroup",
                                                      () =>
                    {
                        chmvt.parentActorMoveTask = null;
                        subActorsMoveTasks.Remove(subg);
                        subg.UnsubscribeOnParentGroupChange("onchangeparentgroup");
                    });

                    var        prevtask = GetTaskPlan().GetTaskInPlanBefore(this) as MoveTask;
                    TaskMarker chprevtm;
                    if (prevtask != null && prevtask.subActorsMoveTasks.ContainsKey(subg))
                    {
                        chprevtm = prevtask.subActorsMoveTasks[subg].GetTaskMarker();
                    }
                    else
                    {
                        chprevtm = null;
                    }

                    TaskPlan2 chtp = tm.InsertAssociatedTaskIntoPlan(subg, chprevtm);
                }

                /*SubscribeOnDestruction("parentactormovetaskchange", () =>
                 * {
                 *  foreach (var chmvt in new List<MoveTask>(subActorsMoveTasks.Values))
                 *  {
                 *      chmvt.EndExecution();
                 *      chmvt.parentActorMoveTask = null;
                 *  }
                 *  subActorsMoveTasks.Clear();
                 * });*/

                SetPhase(TaskPhase.Staging);
            }
            else
            {
                foreach (var chmvt in new List <MoveTask>(subActorsMoveTasks.Values))
                {
                    chmvt.EndExecution();
                    chmvt.parentActorMoveTask = null;
                }
                subActorsMoveTasks.Clear();
            }
        }
Exemplo n.º 11
0
 protected override void InstanceSetTaskMarker(TaskMarker taskMarker)
 {
     _moveTaskMarkerWrapper = new MapMarkerWrapper <MoveTaskMarker>(taskMarker as MoveTaskMarker);
 }
Exemplo n.º 12
0
        //public abstract bool CompatibleForParallelExecution(Task task);

        #region Abstract instance methods

        protected abstract void InstanceSetTaskMarker(TaskMarker taskMarker);
Exemplo n.º 13
0
 public void SetTaskMarker(TaskMarker taskMarker)
 {
     InstanceSetTaskMarker(taskMarker);
 }
Exemplo n.º 14
0
        /*private bool CompatibilityPerActor(IActor actor, Task task)
        {
            bool b = true;
            if (task is MoveTask2)
            {
                var mvtsk = task as MoveTask2;
                var subut = (actor as UnitGroup);

                //b = !((task.GetAgent() as UnitTeam).GetUnit() == subut.GetUnit()
                //    || mvtsk.agentAsTeam.GetUnits().Where(_ => (_ as UnitTeam).GetUnit() == subut.GetUnit()).Count() > 0);
            }
            return b;
        }*/

        protected override void InstanceSetTaskPlan(TaskPlan2 taskPlan)
        {
            base.InstanceSetTaskPlan(taskPlan);

            if (taskPlan != null)
            {
                Debug.Log("setting task plan to task");

                SubscribeOnDestruction("clearchildrenmovetaskmarkers", () => subActorsMoveTaskMarkers.Clear());
    
                foreach (var u in units)
                {
                    /*actorGroupAsUG.SubscribeOnUnitRemovalFromGroup(u,
                        _ => 
                        {
                            subActorsMoveTaskMarkers.Remove(u);
                            actorGroupAsUG.UnsubscribeOnUnitRemovalFromGroup(_);
                        });*/

                    //UpdateFormationFacing(u, GetTaskMarker().GetWorldPosition());
                    //u.GetFormation().FormTest();
                }

                foreach (var subg in actorGroupAsUG.GetSubGroupsAsUG())
                {
                    Vector3 wpos;
                    wpos = subg.GetActorsAsUnits()[0].GetFormation().GetParentFormation().GetAcceptableMovementTargetPosition(GetTaskMarker().GetWorldPosition());

                    var prevtm = GetTaskMarker().GetPreviousTaskMarker()?.GetTask() as MoveTask2;
                    
                    TaskMarker chprevtm;
                    if (prevtm != null)
                        chprevtm = prevtm.subActorsMoveTaskMarkers.FirstOrDefault(_ => (UnitGroup)_.GetTask().GetActorGroup() == subg);
                    else
                        chprevtm = null;

                    MoveTaskMarker tm = TaskMarker.CreateInstanceAtWorldPosition<MoveTaskMarker>(wpos);
                    tm.AddWaypointMarker(WaypointMarker.CreateWaypointMarker(wpos));

                    TaskPlan2 chtp = tm.InsertAssociatedTaskIntoPlan(subg, chprevtm);

                    tm.SubscribeOnDestruction("removefromparentmovetaskmarkerslist",() => subActorsMoveTaskMarkers.Remove(tm));                    
                    subActorsMoveTaskMarkers.Add(tm);
                }

                SetPhase(TaskPhase.Staging);
            }
            else
            {
                subActorsMoveTaskMarkers.Clear();
            }

            if (taskPlan != null)
            {
                //AddSubjectAgent(GetAgent());

                /*foreach (var sbt in agentAsTeam.GetAllSubTeamsBFS())
                {
                    AddSubjectAgent(sbt);
                }*/

                /*foreach (var subAgent in GetSubjectAgents())
                {
                    var sbt = subAgent as UnitTeam;
                    if (!sbt.IsVirtualTeam())
                        sbt.GetUnit().GetFormation().FormTest();
                }
                foreach (var subAgent in GetSubjectAgents())
                {
                    Vector3 wpos;
                    wpos = (subAgent as UnitTeam).GetUnit().GetFormation().GetAcceptableMovementTargetPosition(GetTaskMarker().GetWorldPosition());
                }*/

                //SetPhase(TaskPhase.Staging);
            }
        }
Exemplo n.º 15
0
 private static string getMarkerName(TaskMarker tm)
 {
     return Enum.GetName(typeof(TaskMarker), tm);
 }