public override void OnNPCDoJob(ref NPCBase.NPCState state) { state.JobIsDone = true; usedNPC.LookAt(position.Vector); if (!state.Inventory.IsEmpty) { usedNPC.Inventory.Dump(blockInventory); } if (selectedRecipe != null) { if (selectedRecipe.IsPossible(usedNPC.Colony.UsedStockpile, blockInventory)) { blockInventory.Take(selectedRecipe.Requirements); blockInventory.Add(selectedRecipe.Results); state.SetIndicator(NPCIndicatorType.Crafted, TimeBetweenJobs, selectedRecipe.Results[0].Type); state.JobIsDone = false; } else { selectedRecipe = null; blockInventory.Dump(usedNPC.Inventory); if (!state.Inventory.IsEmpty) { shouldTakeItems = true; } OverrideCooldown(0.1); } } else { var recipeMatch = Recipe.MatchRecipe(GetPossibleRecipes, usedNPC.Colony.UsedStockpile); switch (recipeMatch.MatchType) { case Recipe.RecipeMatchType.AllDone: case Recipe.RecipeMatchType.FoundMissingRequirements: if (!state.Inventory.IsEmpty || !blockInventory.IsEmpty) { blockInventory.Dump(usedNPC.Inventory); shouldTakeItems = true; } else { state.JobIsDone = false; if (recipeMatch.MatchType == Recipe.RecipeMatchType.AllDone) { state.SetIndicator(NPCIndicatorType.SuccessIdle, 6f); } else { state.SetIndicator(NPCIndicatorType.MissingItem, 6f, recipeMatch.FoundRecipe.Requirements[0].Type); } OverrideCooldown(6.0); } break; case Recipe.RecipeMatchType.FoundCraftable: blockInventory.Dump(usedNPC.Inventory); selectedRecipe = recipeMatch.FoundRecipe; shouldTakeItems = true; OverrideCooldown(0.5); break; } } }