protected override void PlanJob() { _task = new HaulToItemHolderTask(_item, _itemHolder, _worker.MotionComponent, _worker.Inventory); _worker.CommandProcessor.AddTask(_task); _task.ResultHandler += OnJobFinish; _item.SetHaulJob(this); }
public IEnumerator haul_to_item_holder_task() { Human human = CreateHuman(); WoodLog item = Factory.Create <WoodLog>("wood log", _spawnPosition); Vector2Int holderPosition = _spawnPosition + new Vector2Int(0, 10); ItemHolder holder = Factory.Create <ItemHolder>("plank wall", holderPosition); Task task = new HaulToItemHolderTask(item, holder, human.MotionComponent, human.InventoryComponent); yield return(AddTaskAndWaitUntilFinished(task, human.CommandProcessor)); //check human position if ((human.MotionComponent.GridPosition - holder.Position).magnitude > 1) { Assert.Fail(); } //check item position if (item.Position != holder.Position) { Assert.Fail(); } //check holder inventory if (holder.Items.Contains(item) == false) { Assert.Fail(); } //check human inventory if (human.InventoryComponent.HasItem(item)) { Assert.Fail(); } human.Die(); holder.Destroy(); item.Destroy(); Assert.Pass(); }