private void detachTask(EcsEntity unit, EcsEntity task, TaskFinishedComponent finishComponent)
 {
     unit.Del <TaskFinishedComponent>();
     unit.Del <TaskComponent>();
     task.Replace(new TaskFinishedComponent {
         status = finishComponent.status
     });                                                                        // move status to task, it will be handled by TaskStatusSystem
 }
예제 #2
0
        private void _Show()
        {
            content.SetActive(true);

            if (_entity.Has <IsSceneInactiveComponent>())
            {
                _entity.Del <IsSceneInactiveComponent>();
            }

            _entity.Get <IsSceneActiveComponent>();
            _entity.Get <SceneBecomeActiveComponent>();
        }
예제 #3
0
        private void _Show()
        {
            if (content != null)
            {
                content.SetActive(true);
            }

            if (_entity.Has <IsSceneInactiveComponent>())
            {
                _entity.Del <IsSceneInactiveComponent>();
            }

            _entity.Get <IsSceneActiveComponent>();

            // sends event scene has been activated
            World.NewEntity().Get <SceneActivatedEvent>().Scene = this;
        }
예제 #4
0
 // unlinks unit from task and notifies unit that task is finished
 private void detachPerformer(EcsEntity task, TaskFinishedComponent component)
 {
     if (task.Has <TaskPerformerComponent>())
     {
         task.Get <TaskPerformerComponent>().performer.Replace(component);
         task.Del <TaskPerformerComponent>();
     }
 }
예제 #5
0
 // if task was completed, designation is no longer needed
 private void detachDesignation(EcsEntity task, TaskFinishedComponent component)
 {
     if (component.status == TaskStatusEnum.COMPLETE && task.Has <TaskDesignationComponent>())
     {
         // TODO handle workbenches
         task.Get <TaskDesignationComponent>().designation.Replace(component);
         task.Del <TaskDesignationComponent>();
     }
 }
 public void Run()
 {
     foreach (var i in filter)
     {
         EcsEntity           entity    = filter.GetEntity(i);
         ItemVisualComponent component = filter.Get1(i);
         Object.Destroy(component.go);
         entity.Del <ItemVisualComponent>();
     }
 }
예제 #7
0
 public void Run()
 {
     foreach (var i in filter)
     {
         EcsEntity             designation           = filter.GetEntity(i);
         TaskFinishedComponent taskFinishedComponent = filter.Get2(i);
         // detach task
         if (designation.Has <TaskComponent>())
         {
             designation.Get <TaskComponent>().task.Replace(taskFinishedComponent);
             designation.Del <TaskComponent>();
         }
         designation.Del <TaskFinishedComponent>();
         // remove designation entity, failed will recreate task
         if (taskFinishedComponent.status == TaskStatusEnum.CANCELED || taskFinishedComponent.status == TaskStatusEnum.COMPLETE)
         {
             GameModel.get().designationContainer.removeDesignation(designation);
         }
     }
 }
예제 #8
0
 public void removeDesignation(EcsEntity designation)
 {
     if (designation.Has <DesignationVisualComponent>())
     {
         Destroy(designation.Get <DesignationVisualComponent>().spriteRenderer.gameObject);
         designation.Del <DesignationVisualComponent>();
     }
     else
     {
         Debug.LogWarning("deleting designation without DesignationVisualComponent");
     }
     designation.Destroy();
 }
예제 #9
0
        public void takeItemFromMap(EcsEntity item)
        {
            validateForTaking(item);
            Vector3Int position = item.pos();

            itemsOnMap[position].Remove(item);
            all.Remove(item);
            item.Del <PositionComponent>();
            if (itemsOnMap[position].Count == 0)
            {
                itemsOnMap.Remove(position); // remove empty list
            }
        }
예제 #10
0
 public void Run()
 {
     foreach (int i in filter)
     {
         Debug.Log("performing");
         EcsEntity unit = filter.GetEntity(i);
         CurrentActionComponent component = filter.Get1(i);
         Action action = component.action;
         action.perform(unit);
         if (action.status == ActionStatusEnum.COMPLETE)
         {
             unit.Del <CurrentActionComponent>();
         }
     }
 }
예제 #11
0
 public void RemoveComponent <T>() where T : struct
 {
     Logging.Logger.Assert(HasComponent <T>(), "Entity does not contain component of type: " + typeof(T));
     entityHandle.Del <T>();
 }
 private void DeselectEntity(ref EcsEntity selectedEntity)
 {
     selectedEntity.Del <Selected>();
     selectedEntity.Get <OnDeselectEvent>();
     selectedEntity.Get <Selectable>();
 }
예제 #13
0
 public virtual void MoveFromPool()
 {
     this.gameObject.SetActive(true);
     entity.Del <InPool>();
 }
예제 #14
0
 private static void SelectEntity(ref EcsEntity entity)
 {
     entity.Get <Selected>();
     entity.Get <OnSelectedEvent>();
     entity.Del <Selectable>();
 }
예제 #15
0
 public override void OnTargetReached()
 {
     base.OnTargetReached();
     _entity.Del <IsMovingComponent>();
 }