132{
133 return dict.TryGetValue(id);
134 }
135
137 {
138 return dict.TryGetValue(id);
139 }
140
141 public void Add(string id, bool showEffect = true)
142 {
143 if (id.IsEmpty())
144 {
145 return;
146 }
148 if (recipeSource == null)
149 {
150 return;
151 }
152 if (!knownRecipes.ContainsKey(id))
153 {
154 newRecipes.Add(id);
155 knownRecipes[id] = 0;
156 }
157 knownRecipes[id]++;
158 int num = knownRecipes[id];
159 if (showEffect)
160 {
163 }
164 EClass.
pc.
Say(
"learnRecipe" + ((num == 1) ?
"New" :
""), dict[
id].Name.ToTitleCase(), num.ToString() ??
"");
166 {
168 {
170 }
171 else
172 {
174 }
175 }
176 recipeSource = Get(id + "-p");
177 if (recipeSource !=
null && !knownRecipes.ContainsKey(recipeSource.
id))
178 {
179 Add(recipeSource.
id, showEffect:
false);
180 }
181 recipeSource = Get(id.Replace("-p", ""));
182 if (recipeSource !=
null && !knownRecipes.ContainsKey(recipeSource.
id))
183 {
184 Add(recipeSource.
id, showEffect:
false);
185 }
187 {
188 recipeSource = Get(id + "-b");
189 if (recipeSource !=
null && !knownRecipes.ContainsKey(recipeSource.
id))
190 {
191 Add(recipeSource.
id, showEffect:
false);
192 }
193 recipeSource = Get(id.Replace("-b", ""));
194 if (recipeSource !=
null && !knownRecipes.ContainsKey(recipeSource.
id))
195 {
196 Add(recipeSource.
id, showEffect:
false);
197 }
198 }
199 }
200
201 public bool IsKnown(string id)
202 {
204 {
206 }
207 return true;
208 }
209
210 public List<RecipeSource> ListSources(
Thing factory, List<RecipeSource> newRecipes =
null)
211 {
212 BuildList();
213 List<RecipeSource> list = new List<RecipeSource>();
215 {
216 if (
item.isBridgePillar || (factory ==
null &&
item.idFactory !=
"self") || (factory !=
null && !factory.
trait.
Contains(
item)) ||
item.isChara ||
item.noListing)
217 {
218 continue;
219 }
221 {
222 bool flag = false;
223 if (
item.row.recipeKey !=
null &&
item.row.recipeKey.Length != 0 &&
item.row.recipeKey[0].Length > 0 &&
item.row.recipeKey[0][0] ==
'*')
224 {
225 flag = true;
226 }
228 if (!(id == "waystone"))
229 {
231 {
232 flag = true;
233 }
234 }
236 {
237 flag = true;
238 }
239 if (!flag)
240 {
241 continue;
242 }
243 if (newRecipes != null)
244 {
247 {
248 newRecipes.Add(
item);
250 }
251 }
252 }
254 }
255 return list;
256 }
257
258 public void OnSleep(bool ehe = false)
259 {
263 {
264 Msg.
Say(
"learnRecipeSleep");
267 }
268 }
269
270 public void ComeUpWithRandomRecipe(string idCat = null, int lvBonus = 0)
271 {
272 string randomRecipe = GetRandomRecipe(lvBonus, idCat, onlyUnlearned: true);
273 if (randomRecipe != null)
274 {
275 Msg.
Say(
"learnRecipeIdea");
276 Add(randomRecipe);
277 }
278 }
279
280 public LearnState GetRecipeLearnState(string idRecipe)
281 {
282 if (idRecipe.IsEmpty())
283 {
284 return LearnState.Unavailable;
285 }
288 {
289 return LearnState.Unavailable;
290 }
292 {
293 return LearnState.AlreadyLearned;
294 }
297 {
298 return LearnState.InsufficientSkill;
299 }
300 return LearnState.Learnable;
301 }
302
303 public void ComeUpWithRecipe(string idRecipe, int chanceForRandomRecipe = 0)
304 {
305 if (idRecipe.IsEmpty())
306 {
307 return;
308 }
312 {
313 return;
314 }
316 {
318 {
319 ComeUpWithRandomRecipe(recipeSource.
row.
Category.id);
320 }
321 return;
322 }
325 {
327 return;
328 }
329 Msg.
Say(
"learnRecipeIdea");
330 Add(idRecipe);
331 }
332
333 public static RecipeSource GetUnlearnedRecipe(
int lvBonus,
string cat,
bool onlyUnlearned)
334 {
335 BuildList();
336 List<RecipeSource> list = new List<RecipeSource>();
338 {
340 {
342 }
343 }
345 }
346
347 public static RecipeSource GetLearnedRecipe(
string cat =
null)
348 {
349 List<RecipeSource> list = new List<RecipeSource>();
351 {
354 {
355 list.Add(recipeSource);
356 }
357 }
359 }
360
361 public static string GetRandomRecipe(int lvBonus, string cat = null, bool onlyUnlearned = false)
362 {
364 recipeSource = GetUnlearnedRecipe(lvBonus, cat, onlyUnlearned);
365 if (recipeSource == null)
366 {
367 recipeSource = GetLearnedRecipe(cat);
368 }
369 return recipeSource?.
id;
370 }
371
372 public void OnVersionUpdate()
373 {
375 {
376 knownIngredients.Add(t.
id);
377 });
378 knownIngredients.Add("flower");
379 }
380}
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)
static List< RecipeSource > list
Dictionary< string, int > knownRecipes
void Add(string id, bool showEffect=true)
HashSet< string > newRecipes
SourceCategory.Row Category
void Foreach(Action< Thing > action, bool onlyAccessible=true)
virtual bool Contains(RecipeSource r)