public void RemoveParameterAgent(IActorGroup actor) { if (paramActors.Remove(actor)) { actor.UnsubscribeOnDestruction(removeParamActorKey); } }
public ActorGroupShould() { _actor = new TestActor(1); _actorContext = new Mock <IActorContext>(); _actorGroup = new ActorGroup <TestActor>(_actorContext.Object); InjectComponentsArray(Array.Empty <IComponent>()); }
public void AddGroup <TActor>(IActorGroup <TActor> actorGroup) where TActor : Actor { var typeId = Typeof <TActor> .Id; using (Lock.Enter(_groups)) { _groups.Add(typeId, actorGroup); } }
public void AddParameterActor(IActorGroup actor) { if (!paramActors.Contains(actor)) { paramActors.Add(actor); actor.SubscribeOnDestruction(removeParamActorKey, () => RemoveParameterAgent(actor)); } }
public void ChangeParentTo(IActorGroup newParent) { if (newParent != null) { (newParent as UnitGroup).Internal_AddSubGroup(this); } else { if (GetParentGroupAsUG() != null) { GetParentGroupAsUG().Internal_RemoveSubGroup(this); } } }
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); }
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); } }
public TaskPlan2(IActorGroup group) { _group = new RefWrapper <IActorGroup>(group); }