11 public override void RefreshCurrentGrid()
13 this.RefreshRecipe(
true);
17 public override void ClearButtons()
19 this.RefreshRecipe(
true);
23 public override string GetTextHeader(Window window)
29 public override void OnAfterInit()
31 this.info1.searchMode = StockSearchMode.AroundPC;
32 this.info1.ddList.pivot.SetActive(
true);
33 LayerCraft.Instance =
this;
37 public override void OnKill()
39 if (this.workbenchCrafted)
43 if (this.pickaxeCrafted)
50 public void SetFactory(
Thing t)
53 this.RefreshCategory(
"all");
54 bool flag = t !=
null && t.trait.IsRequireFuel;
55 this.transFuel.SetActive(flag);
59 this.buttonRefuel.SetOnClick(delegate
61 foreach (Window window
in this.windows)
63 window.SetInteractable(
false, 0f);
67 if ((onKill = <>9__2) ==
null)
69 onKill = (<>9__2 = delegate()
71 if (!this.isDestroyed)
77 layer.SetOnKill(onKill);
79 this.buttonAutoRefuel.SetOnClick(delegate
82 t.autoRefuel = !t.autoRefuel;
83 this.RefreshProduct();
89 public void OnClickCraft()
91 Dictionary<Thing, int> dictionary =
new Dictionary<Thing, int>();
94 if (ingredient.thing !=
null)
96 if (!dictionary.ContainsKey(ingredient.thing))
98 dictionary.Add(ingredient.thing, 0);
100 Dictionary<Thing, int> dictionary2 = dictionary;
101 Thing thing = ingredient.thing;
102 dictionary2[thing] += ingredient.req * this.inputNum.Num;
105 foreach (KeyValuePair<Thing, int> keyValuePair
in dictionary)
107 if (keyValuePair.Key.Num < keyValuePair.Value)
110 Msg.Say(
"craftDupError");
114 if (this.inputNum.Num == 0)
119 Thing thing2 = this.factory;
121 if (traitCrafter ==
null)
123 traitCrafter =
Trait.SelfFactory;
124 traitCrafter.owner =
ELayer.pc;
127 string id = this.recipe.id;
128 if (!(
id ==
"workbench"))
130 if (
id ==
"axe" ||
id ==
"hammer" ||
id ==
"pickaxe")
132 this.pickaxeCrafted =
true;
137 this.workbenchCrafted =
true;
141 crafter = traitCrafter,
143 recipe = this.recipe,
144 num = this.inputNum.Num
147 base.gameObject.SetActive(
false);
151 public override List<Thing> GetTargets()
153 List<Thing> list =
new List<Thing>();
156 if (!ingredient.optional || (ingredient.thing !=
null && !ingredient.thing.isDestroyed))
158 list.Add(ingredient.thing);
165 public override int GetReqIngredient(
int index)
167 return this.recipe.ingredients[index].req * this.inputNum.Num;
171 public override void OnEndCraft()
173 this.OnCompleteCraft();
177 public void OnCompleteCraft()
179 base.CancelInvoke(
"WaitUntilIdle");
180 EInput.haltInput =
true;
181 TweenUtil.Tween(this.waitComplete,
null, delegate()
183 EInput.haltInput =
false;
184 base.gameObject.SetActive(
true);
185 foreach (Window window
in this.windows)
187 window.SetInteractable(
true, 0.5f);
190 this.RefreshRecipe(
true);
191 this.windowList.groupTab.RefreshButtons();
192 this.list.Select<
Recipe>((
Recipe r) => this.recipe.id == r.id,
false);
197 public void WaitUntilIdle()
207 private void Update()
209 float axis = Input.GetAxis(
"Mouse ScrollWheel");
210 if (Input.GetMouseButton(0))
228 public void RefreshInfo()
231 if (buttonGrid && buttonGrid.recipe ==
null)
235 if (buttonGrid == this.lastB)
239 this.lastB = buttonGrid;
243 public void RefreshCategory(
string cat)
245 Dictionary<string, int> cats =
new Dictionary<string, int>();
247 BaseList baseList = this.list;
252 SE.Play(
"click_recipe");
253 this.RefreshRecipe(
true);
254 ELayer.player.recipes.hoveredRecipes.Add(a.id);
255 b.Dettach(
"recipe_new");
256 this.list.Select(a,
false);
260 if (a.ingredients.Count == 0)
262 a.BuildIngredientList();
264 b.SetCraftRecipe(a,
ButtonGrid.Mode.Recipe,
false);
265 if (!
ELayer.player.recipes.hoveredRecipes.Contains(a.id))
267 b.Attach(
"recipe_new",
false);
270 callback.onList = delegate(UIList.SortMode m)
272 this.newRecipes.Clear();
273 foreach (
RecipeSource recipeSource
in ELayer.player.recipes.ListSources(
this.factory,
this.newRecipes))
275 if (cat ==
"all" || recipeSource.row.Category.IsChildOf(cat))
281 if (row.id !=
"lightsource" && row.IsChildOf(
"armor"))
283 row =
ELayer.sources.categories.map[
"armor"];
285 Dictionary<string, int> cats;
286 if (!cats.ContainsKey(row.id))
298 this.list.objects.Sort((
object a,
object b) => (b as
Recipe).GetSortVal() - (a as
Recipe).GetSortVal());
299 int count = this.newRecipes.Count;
301 callback.onSort = ((
Recipe a, UIList.SortMode m) => a.GetSortVal());
302 baseList.callbacks = callback;
303 this.list.sortMode = UIList.SortMode.ByLevel;
305 if (cats.Count > 1 && !
this.tabBuilt)
307 this.windowList.AddTab(
"all",
null, delegate
309 this.RefreshCategory(
"all");
311 using (Dictionary<string, int>.Enumerator enumerator = cats.GetEnumerator())
313 while (enumerator.MoveNext())
315 KeyValuePair<string, int> c = enumerator.Current;
316 this.windowList.AddTab(
ELayer.sources.categories.map[c.Key].GetName() +
"(" + c.Value.ToString() +
")",
null, delegate
318 this.RefreshCategory(c.Key);
322 this.tabBuilt =
true;
323 this.windowList.BuildTabs(0);
326 if (this.list.rows.Count > 0)
328 this.list.Select(this.list.rows[0].objects[0],
true);
333 public void OnChangeIngredient()
335 this.RefreshRecipe(
true);
339 public void RefreshRecipe(
bool first)
343 if (this.info1.recipe !=
this.recipe || (!ingredient.optional && (ingredient.thing ==
null || ingredient.thing.isDestroyed)))
345 ingredient.SetThing(
null);
350 this.toggleCraftTo.SetToggle(
false,
null);
351 this.toggleRepeat.SetToggle(
false,
null);
352 this.inputNum.Num = 1;
353 this.info1.recipe =
null;
355 this.info1.factory = this.factory;
356 this.info1.SetRecipe(this.recipe);
357 this.recipe.OnChangeIngredient();
358 this.RefreshProduct();
362 public void RefreshInputNum()
364 this.inputNum.SetMinMax(1, this.recipe.GetMaxCount());
365 this.inputNum.onValueChanged = delegate(
int n)
367 this.RefreshProduct();
369 this.inputNum.Validate();
373 public void RefreshProduct()
375 this.RefreshInputNum();
376 ELayer.screen.tileSelector.summary.countValid = this.inputNum.Num;
377 ELayer.screen.tileSelector.summary.factory = this.factory;
378 this.info1.RefreshBalance();
379 if (this.factory !=
null)
381 this.textFuel.text =
"craftFuel".lang(((
int)((
float)this.factory.c_charges / (
float)
this.factory.trait.MaxFuel * 100f)).ToString() ??
"",
null,
null,
null,
null);
382 this.buttonAutoRefuel.mainText.text = (this.factory.autoRefuel ?
"On" :
"Off");
383 this.buttonAutoRefuel.icon.SetAlpha(this.factory.autoRefuel ? 1f : 0.4f);
385 this.RefreshQuality();
386 List<Thing> list =
new List<Thing>();
389 if (ingredient.thing !=
null)
391 list.Add(ingredient.thing);
394 Thing thing = this.recipe.Craft(BlessedState.Normal,
false, list,
true);
395 thing.SetNum(this.inputNum.Num);
396 if (thing.sockets !=
null)
398 thing.sockets.Clear();
400 if (thing.IsEquipmentOrRanged)
402 foreach (
Element element
in thing.elements.dict.Values.ToList<
Element>())
404 if (!element.IsTrait)
406 thing.elements.Remove(element.id);
410 this.info1.buttonProduct.SetCard(thing,
ButtonGrid.Mode.Default,
null);
411 thing.WriteNote(this.info1.note,
null,
IInspect.NoteMode.Product,
this.recipe);
412 this.product = thing;
416 public bool IsQualityMet()
422 public void RefreshQuality()
427 public void OnClickExamine()
436 public UIDynamicList list;
445 public Vector3 posInfo;
448 public Thing factory;
451 public Thing product;
457 public UIButton toggleRepeat;
460 public UIButton toggleCraftTo;
463 public UIInputText inputNum;
466 public UIInputText moldInputNum;
469 public List<RecipeSource> newRecipes =
new List<RecipeSource>();
472 public Window windowList;
475 public bool showInfo;
478 private bool pickaxeCrafted;
481 private bool workbenchCrafted;
484 public UIButton buttonRefuel;
487 public UIButton buttonAutoRefuel;
490 public Transform transFuel;
493 public UIText textFuel;
496 public UIText textQualityInvalid;
499 public UIText textQualityValid;
502 public Image imageQualityReq;
505 public Image imageQualityCurrent;
508 public float waitComplete;
511 public float qualityBarWidth;
520 private bool tabBuilt;