12 this.rectDrop.SetActive(
false);
22 public void Build(List<GridItem> items)
25 BaseList baseList = this.list;
39 baseList.callbacks = callback;
40 for (
int j = 0; j < this.slots; j++)
44 this.list.Add(items[j]);
51 this.list.Refresh(
false);
55 public List<Thing> ListIngredients(
Recipe.
Ingredient ingredient, StockSearchMode searchMode)
57 return EMono._map.Stocked.ListThingStack(ingredient, searchMode).list;
61 public void BuildIngredients(
Recipe _recipe, Image _icon, Action _onValueChange, StockSearchMode _searchMode)
63 this.recipe = _recipe;
66 this.onValueChange = _onValueChange;
67 this.searchMode = _searchMode;
68 if (this.recipe ==
null)
76 if (ingredient.id.IsEmpty())
78 b.SetIngredient(this.recipe, ingredient);
81 List<Thing> things = this.ListIngredients(ingredient, this.searchMode);
82 if (things.Count == 0)
84 if (
EMono.debug.godBuild && ingredient.thing ==
null)
86 Thing thing =
ThingGen.Create(ingredient.IdThing,
this.recipe.DefaultMaterial.alias).SetNum(99);
88 ingredient.SetThing(thing);
92 ingredient.SetThing(
null);
93 things.Insert(0,
null);
96 else if (!ingredient.optional)
98 if (ingredient.thing ==
null)
100 int num = this.lastMats.TryGetValue(this.recipe.id, -1);
103 foreach (
Thing thing2
in things)
105 if (thing2.material.id == num && thing2.Num >= ingredient.req)
107 ingredient.SetThing(thing2);
112 if (ingredient.thing ==
null)
115 foreach (
Thing thing3
in things)
117 if (thing3.material.id == defaultMaterial.id && thing3.Num >= ingredient.req)
119 ingredient.SetThing(thing3);
123 if (
EMono.debug.godBuild && ingredient.thing ==
null)
125 Thing thing4 = (ingredient.useCat ?
ThingGen.CreateFromCategory(ingredient.id, -1) :
ThingGen.Create(ingredient.id, defaultMaterial.alias)).SetNum(99);
127 ingredient.SetThing(thing4);
130 if (ingredient.thing ==
null)
132 ingredient.SetThing(things[0]);
138 foreach (
Thing thing5
in things)
140 if (ingredient.thing == thing5)
148 ingredient.SetThing(things[0]);
152 b.SetIngredient(this.recipe, ingredient);
153 b.onClick.RemoveAllListeners();
154 b.onClick.AddListener(delegate()
156 things = this.ListIngredients(ingredient, this.searchMode);
157 if (ingredient.optional)
159 if (things.Count == 0 || things[0] ==
null)
165 else if (ingredient.thing ==
null)
172 this.Activate(ingredient, things);
173 this.rectDropContent.position = this.list.transform.position + this.fixPos;
179 b.SetIngredient(this.recipe, a);
182 for (
int j = 0; j < this.slots; j++)
184 if (j < this.recipe.ingredients.Count)
186 this.list.Add(this.recipe.ingredients[j]);
196 this.list.Refresh(
false);
210 this.soundPop.Play();
212 DropdownGrid.IsActive =
true;
213 DropdownGrid.Instance =
this;
214 this.rectDrop.SetActive(
true);
215 this.rectDrop.SetParent(
EMono.ui.transform);
216 this.rectDrop.sizeDelta =
new Vector2(0f, 0f);
217 this.rectDrop.anchoredPosition = Vector3.zero;
223 ingredient.SetThing(a);
224 this.OnChangeIngredient();
225 if (this.onValueChange !=
null)
227 this.onValueChange();
237 b.SetIngredient(this.recipe, a);
240 this.listDrop.Clear();
241 foreach (
Thing o
in things)
243 this.listDrop.Add(o);
245 this.listDrop.Refresh(
false);
249 public void OnChangeIngredient()
251 if (this.recipe ==
null)
255 this.recipe.OnChangeIngredient();
262 this.recipe.renderRow.SetImage(this.icon,
null, this.recipe.renderRow.GetColorInt(
this.recipe.GetColorMaterial()),
true, 0,
this.recipe.idSkin);
268 public void Deactivate()
270 DropdownGrid.IsActive =
false;
271 if (this.rectDrop !=
null)
273 this.rectDrop.SetActive(
false);
278 public void OnDestroy()
280 DropdownGrid.IsActive =
false;
281 UnityEngine.Object.DestroyImmediate(this.rectDrop.gameObject);
285 public void TrySelect(
int a)
288 if (!componentOf || componentOf.ing ==
null)
293 List<Thing> list =
EMono._map.Stocked.ListThingStack(ing, this.searchMode).list;
294 int num = list.IndexOf(ing.thing);
305 if (num >= list.Count)
307 num = list.Count - 1;
309 ing.SetThing(list[num]);
310 this.OnChangeIngredient();
311 TooltipManager.Instance.ResetTooltips();
312 componentOf.ShowTooltip();
315 this.recipeInfo.RefreshImages();
336 public static bool IsActive;
345 public UIList listDrop;
348 public RectTransform rectDrop;
351 public RectTransform rectDropContent;
354 public RectTransform pivot;
363 public SoundData soundPop;
366 public Action onValueChange;
369 public int slots = 4;
372 public Vector3 fixPos;
375 public StockSearchMode searchMode;
382 public Dictionary<string, int> lastMats =
new Dictionary<string, int>();