예제 #1
0
 public void RemoveParameterAgent(IActorGroup actor)
 {
     if (paramActors.Remove(actor))
     {
         actor.UnsubscribeOnDestruction(removeParamActorKey);
     }
 }
예제 #2
0
        public ActorGroupShould()
        {
            _actor        = new TestActor(1);
            _actorContext = new Mock <IActorContext>();
            _actorGroup   = new ActorGroup <TestActor>(_actorContext.Object);

            InjectComponentsArray(Array.Empty <IComponent>());
        }
예제 #3
0
        public void AddGroup <TActor>(IActorGroup <TActor> actorGroup) where TActor : Actor
        {
            var typeId = Typeof <TActor> .Id;

            using (Lock.Enter(_groups))
            {
                _groups.Add(typeId, actorGroup);
            }
        }
예제 #4
0
 public void AddParameterActor(IActorGroup actor)
 {
     if (!paramActors.Contains(actor))
     {
         paramActors.Add(actor);
         actor.SubscribeOnDestruction(removeParamActorKey,
                                      () => RemoveParameterAgent(actor));
     }
 }
예제 #5
0
 public void ChangeParentTo(IActorGroup newParent)
 {
     if (newParent != null)
     {
         (newParent as UnitGroup).Internal_AddSubGroup(this);
     }
     else
     {
         if (GetParentGroupAsUG() != null)
         {
             GetParentGroupAsUG().Internal_RemoveSubGroup(this);
         }
     }
 }
예제 #6
0
        public virtual TaskPlan2 InsertAssociatedTaskIntoPlan(IActorGroup actor, TaskMarker previousTaskMarker)
        {
            TaskPlan2 taskPlan;

            if (previousTaskMarker == null)
            {
                taskPlan = actor.CreateAndRegisterNewOwnedPlan();
                taskPlan.AddTaskToPlan(GetTask());
            }
            else
            {
                GetTask().GetParameters().AddExecutionMode(TaskParams.TaskExecutionMode.Chain);

                taskPlan = previousTaskMarker.GetTask().GetTaskPlan();
                taskPlan.AddTaskToPlan(GetTask());
            }
            return(taskPlan);
        }
예제 #7
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);
            }
        }
예제 #8
0
 public TaskPlan2(IActorGroup group)
 {
     _group = new RefWrapper <IActorGroup>(group);
 }