122{
123 return dict.TryGetValue(id);
124 }
125
127 {
128 return dict.TryGetValue(id);
129 }
130
131 public void Add(string id, bool showEffect = true)
132 {
133 if (id.IsEmpty())
134 {
135 return;
136 }
138 if (recipeSource == null)
139 {
140 return;
141 }
142 if (!knownRecipes.ContainsKey(id))
143 {
144 newRecipes.Add(id);
145 knownRecipes[id] = 0;
146 }
147 knownRecipes[id]++;
148 int num = knownRecipes[id];
149 if (showEffect)
150 {
153 }
154 EClass.
pc.
Say(
"learnRecipe" + ((num == 1) ?
"New" :
""), dict[
id].Name.ToTitleCase(), num.ToString() ??
"");
156 {
158 {
160 }
161 else
162 {
164 }
165 }
166 recipeSource = Get(id + "-p");
167 if (recipeSource !=
null && !knownRecipes.ContainsKey(recipeSource.
id))
168 {
169 Add(recipeSource.
id, showEffect:
false);
170 }
171 recipeSource = Get(id.Replace("-p", ""));
172 if (recipeSource !=
null && !knownRecipes.ContainsKey(recipeSource.
id))
173 {
174 Add(recipeSource.
id, showEffect:
false);
175 }
177 {
178 recipeSource = Get(id + "-b");
179 if (recipeSource !=
null && !knownRecipes.ContainsKey(recipeSource.
id))
180 {
181 Add(recipeSource.
id, showEffect:
false);
182 }
183 recipeSource = Get(id.Replace("-b", ""));
184 if (recipeSource !=
null && !knownRecipes.ContainsKey(recipeSource.
id))
185 {
186 Add(recipeSource.
id, showEffect:
false);
187 }
188 }
189 }
190
191 public bool IsKnown(string id)
192 {
194 {
196 }
197 return true;
198 }
199
200 public List<RecipeSource> ListSources(
Thing factory, List<RecipeSource> newRecipes =
null)
201 {
202 BuildList();
203 List<RecipeSource> list = new List<RecipeSource>();
205 {
206 if (
item.isBridgePillar || (factory ==
null &&
item.idFactory !=
"self") || (factory !=
null && !factory.
trait.
Contains(
item)) ||
item.isChara ||
item.noListing)
207 {
208 continue;
209 }
211 {
212 bool flag = false;
213 if (
item.row.recipeKey !=
null &&
item.row.recipeKey.Length != 0 &&
item.row.recipeKey[0][0] ==
'*')
214 {
215 flag = true;
216 }
218 if (!(id == "waystone"))
219 {
221 {
222 flag = true;
223 }
224 }
226 {
227 flag = true;
228 }
229 if (!flag)
230 {
231 continue;
232 }
233 if (newRecipes != null)
234 {
237 {
238 newRecipes.Add(
item);
240 }
241 }
242 }
244 }
245 return list;
246 }
247
248 public void OnSleep(bool ehe = false)
249 {
253 {
254 Msg.
Say(
"learnRecipeSleep");
257 }
258 }
259
260 public void ComeUpWithRandomRecipe(string idCat = null, int lvBonus = 0)
261 {
262 string randomRecipe = GetRandomRecipe(lvBonus, idCat, onlyUnlearned: true);
263 if (randomRecipe != null)
264 {
265 Msg.
Say(
"learnRecipeIdea");
266 Add(randomRecipe);
267 }
268 }
269
270 public LearnState GetRecipeLearnState(string idRecipe)
271 {
272 if (idRecipe.IsEmpty())
273 {
274 return LearnState.Unavailable;
275 }
278 {
279 return LearnState.Unavailable;
280 }
282 {
283 return LearnState.AlreadyLearned;
284 }
287 {
288 return LearnState.InsufficientSkill;
289 }
290 return LearnState.Learnable;
291 }
292
293 public void ComeUpWithRecipe(string idRecipe, int chanceForRandomRecipe = 0)
294 {
295 if (idRecipe.IsEmpty())
296 {
297 return;
298 }
302 {
303 return;
304 }
306 {
308 {
309 ComeUpWithRandomRecipe(recipeSource.
row.
Category.id);
310 }
311 return;
312 }
315 {
317 return;
318 }
319 Msg.
Say(
"learnRecipeIdea");
320 Add(idRecipe);
321 }
322
323 public static RecipeSource GetUnlearnedRecipe(
int lvBonus,
string cat,
bool onlyUnlearned)
324 {
325 BuildList();
326 List<RecipeSource> list = new List<RecipeSource>();
328 {
330 {
332 }
333 }
335 }
336
337 public static RecipeSource GetLearnedRecipe(
string cat =
null)
338 {
339 List<RecipeSource> list = new List<RecipeSource>();
341 {
344 {
345 list.Add(recipeSource);
346 }
347 }
349 }
350
351 public static string GetRandomRecipe(int lvBonus, string cat = null, bool onlyUnlearned = false)
352 {
354 recipeSource = GetUnlearnedRecipe(lvBonus, cat, onlyUnlearned);
355 if (recipeSource == null)
356 {
357 recipeSource = GetLearnedRecipe(cat);
358 }
359 return recipeSource?.
id;
360 }
361
362 public void OnVersionUpdate()
363 {
365 {
366 knownIngredients.Add(t.
id);
367 });
368 knownIngredients.Add("flower");
369 }
370}
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)