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 }
private void _Show() { content.SetActive(true); if (_entity.Has <IsSceneInactiveComponent>()) { _entity.Del <IsSceneInactiveComponent>(); } _entity.Get <IsSceneActiveComponent>(); _entity.Get <SceneBecomeActiveComponent>(); }
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; }
// 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>(); } }
// 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>(); } }
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); } } }
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(); }
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 } }
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>(); } } }
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>(); }
public virtual void MoveFromPool() { this.gameObject.SetActive(true); entity.Del <InPool>(); }
private static void SelectEntity(ref EcsEntity entity) { entity.Get <Selected>(); entity.Get <OnSelectedEvent>(); entity.Del <Selectable>(); }
public override void OnTargetReached() { base.OnTargetReached(); _entity.Del <IsMovingComponent>(); }