I'm running into an issue where the quest works completely fine if you do everything in the right order, but if conditions are met out of order (i.e., you get an item in your inventory before the quest asks you to), then it doesn't continue.
Here's my setup:
https://ibb.co/XWn2L8G
1. First condition to be met: https://ibb.co/k8S1pyp
2. Second condition to be met: https://ibb.co/gF9FcTJ
3. Node to make sure that both are met: https://ibb.co/tpMLD1S
Any idea why the "Found All Items" isn't registering as true when the previous conditions were met? For example, you can accomplish all of the above items even before getting the quest.
Here is my custom code for HasRecipe:
Code: Select all
using UnityEngine;
using System;
namespace PixelCrushers.QuestMachine
{
public class HasRecipe : QuestCondition // Rename this class.
{
public StringField recipeName = new StringField();
public override void StartChecking(System.Action trueAction)
{
base.StartChecking(trueAction);
if (IsTrue())
{
SetTrue();
}
else
{
EventHandler.PlayerRecipeAdded += PlayerRecipeAdded;
}
}
private bool IsTrue()
{
foreach (var recipe in Statics.player.GetComponent<CharacterCraftingData>().playerRecipes)
{
if (recipe.name == recipeName.text)
{
QuestMachineMessages.RefreshUIs(this);
return true;
}
}
return false;
}
private void PlayerRecipeAdded(string recipe)
{
recipeName.text = recipe;
if (IsTrue())
{
SetTrue();
}
}
public override void StopChecking()
{
base.StopChecking();
EventHandler.PlayerRecipeAdded -= PlayerRecipeAdded;
}
}
}
Thanks!