2using System.Collections.Generic;
18 public static List<RecipeSource>
list =
new List<RecipeSource>();
20 public static Dictionary<string, RecipeSource>
dict =
new Dictionary<string, RecipeSource>();
29 public Dictionary<string, int>
knownRecipes =
new Dictionary<string, int>();
35 public HashSet<string>
newRecipes =
new HashSet<string>();
38 public Dictionary<string, List<int>>
lastIngredients =
new Dictionary<string, List<int>>();
46 Debug.Log(
"Rebuilding recipe list");
62 Create(row2,
"BridgePillar",
"-p");
67 if (!row3.tag.Contains(
"noFloor"))
74 if (!row4.tag.Contains(
"noBridge") && !row4.factory.IsEmpty() && row4.factory[0] !=
"x")
76 Create(row4,
"Bridge",
"-b");
97 recipeSource.id = row.RecipeID + suffix;
98 recipeSource.isBridge = type ==
"Bridge";
99 recipeSource.isBridgePillar = type ==
"BridgePillar";
100 recipeSource.type = type;
101 recipeSource.row = row;
106 if (text !=
"x" && text !=
"none" && text !=
"None" && text !=
"self" && !
EClass.
sources.
cards.
map.ContainsKey(text))
108 Debug.LogWarning(
"Recipe '" + recipeSource.
id +
"' (" + row.
GetAlias +
") has unknown factory '" + text +
"'");
109 recipeSource.noListing =
true;
114 recipeSource.noListing =
true;
116 list.Add(recipeSource);
117 dict[recipeSource.
id] = recipeSource;
125 list.Remove(recipeSource);
126 dict.Remove(recipeSource.
id);
127 Debug.LogWarning(
$"Failed to create recipe '{row.RecipeID}' '{type}{suffix}'\n{ex}");
133 return dict.TryGetValue(
id);
138 return dict.TryGetValue(
id);
141 public void Add(
string id,
bool showEffect =
true)
148 if (recipeSource ==
null)
164 EClass.
pc.
Say(
"learnRecipe" + ((num == 1) ?
"New" :
""),
dict[
id].Name.ToTitleCase(), num.ToString() ??
"");
176 recipeSource =
Get(
id +
"-p");
177 if (recipeSource !=
null && !
knownRecipes.ContainsKey(recipeSource.
id))
179 Add(recipeSource.
id, showEffect:
false);
181 recipeSource =
Get(
id.Replace(
"-p",
""));
182 if (recipeSource !=
null && !
knownRecipes.ContainsKey(recipeSource.
id))
184 Add(recipeSource.
id, showEffect:
false);
188 recipeSource =
Get(
id +
"-b");
189 if (recipeSource !=
null && !
knownRecipes.ContainsKey(recipeSource.
id))
191 Add(recipeSource.
id, showEffect:
false);
193 recipeSource =
Get(
id.Replace(
"-b",
""));
194 if (recipeSource !=
null && !
knownRecipes.ContainsKey(recipeSource.
id))
196 Add(recipeSource.
id, showEffect:
false);
213 List<RecipeSource>
list =
new List<RecipeSource>();
216 if (
item.isBridgePillar || (factory ==
null &&
item.idFactory !=
"self") || (factory !=
null && !factory.trait.Contains(
item)) ||
item.isChara || !
item.ShouldList())
223 if (
item.row.recipeKey !=
null &&
item.row.recipeKey.Length != 0 &&
item.row.recipeKey[0].Length > 0 &&
item.row.recipeKey[0][0] ==
'*')
228 if (!(
id ==
"waystone"))
264 Msg.
Say(
"learnRecipeSleep");
272 string randomRecipe =
GetRandomRecipe(lvBonus, idCat, onlyUnlearned:
true);
273 if (randomRecipe !=
null)
275 Msg.
Say(
"learnRecipeIdea");
282 if (idRecipe.IsEmpty())
305 if (idRecipe.IsEmpty())
329 Msg.
Say(
"learnRecipeIdea");
336 List<RecipeSource>
list =
new List<RecipeSource>();
349 List<RecipeSource>
list =
new List<RecipeSource>();
355 list.Add(recipeSource);
361 public static string GetRandomRecipe(
int lvBonus,
string cat =
null,
bool onlyUnlearned =
false)
365 if (recipeSource ==
null)
369 return recipeSource?.
id;
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
void ShowEmo(Emo _emo=Emo.none, float duration=0f, bool skipSame=true)
void Say(string lang, string ref1=null, string ref2=null)
static SourceManager sources
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
static void SetSeed(int a=-1)
Dictionary< string, List< int > > lastIngredients
HashSet< string > craftedRecipes
static List< RecipeSource > list
void ComeUpWithRecipe(string idRecipe, int chanceForRandomRecipe=0)
static RecipeSource Get(string id)
static RecipeSource GetLearnedRecipe(string cat=null)
static Dictionary< string, RecipeSource > dict
HashSet< string > knownIngredients
static void Create(RenderRow row, string type, string suffix="")
static RecipeSource GetUnlearnedRecipe(int lvBonus, string cat, bool onlyUnlearned)
LearnState GetRecipeLearnState(string idRecipe)
void OnSleep(bool ehe=false)
Dictionary< string, int > knownRecipes
List< RecipeSource > ListSources(Thing factory, List< RecipeSource > newRecipes=null)
void Add(string id, bool showEffect=true)
HashSet< string > hoveredRecipes
static string GetRandomRecipe(int lvBonus, string cat=null, bool onlyUnlearned=false)
void ComeUpWithRandomRecipe(string idCat=null, int lvBonus=0)
RecipeSource GetSource(string id)
HashSet< string > newRecipes
static Dictionary< string, Recipe > recipeCache
static Recipe Create(RecipeSource _source, int idMat=-1, Thing ing=null)
virtual void BuildIngredientList()
SourceCategory.Row Category
Dictionary< string, CardRow > map
SourceCellEffect cellEffects
void Foreach(Action< Thing > action, bool onlyAccessible=true)
static TileTypePillar Pillar