10 public override void OnInit()
12 LayerCraftFloat.Instance =
this;
16 public override void OnSwitchContent(Window window)
18 if (!
ELayer.core.IsGameStarted)
28 if (EInput.middleMouse.down)
31 if (componentOf && componentOf.transform.IsChildOf(base.transform))
33 Recipe recipe = componentOf.recipe;
34 if (recipe !=
null && this.windows[0].idTab == 0)
36 this.ShowContextMenu(recipe);
40 if (Input.GetMouseButton(0))
43 if (componentOf2 && componentOf2.transform.IsChildOf(base.transform) &&
ELayer.player.waitingInput &&
ELayer.pc.HasNoGoal && componentOf2.recipe.id ==
this.idLastRecipe)
45 this.list.callbacks.OnClick(componentOf2.recipe, componentOf2);
51 this.idLastRecipe =
null;
56 public void OnCompleteCraft()
61 public void RefreshCraft()
67 ELayer.ui.RemoveLayers(
false);
75 a.OnChangeIngredient();
77 this.idLastRecipe = this.recipe.id;
78 if (!
ELayer.player.waitingInput)
91 if (!taskCraft.IsIngredientsValid(
false, taskCraft.num))
96 ELayer.pc.SetAI(taskCraft);
101 b.SetCraftRecipe(a,
ButtonGrid.Mode.RecipeGrid,
true);
102 if (!
ELayer.player.recipes.hoveredRecipes.Contains(a.id))
104 b.Attach(
"recipe_new",
false);
106 b.onRightClick = delegate()
108 this.ShowContextMenu(a);
111 onList = delegate(UIList.SortMode m)
121 this.list.dsv.OnResize();
125 public void ShowContextMenu(
Recipe a)
127 UIContextMenu m =
ELayer.ui.CreateContextMenuInteraction();
129 using (List<
Recipe.
Ingredient>.Enumerator enumerator = a.ingredients.GetEnumerator())
131 while (enumerator.MoveNext())
134 UIContextMenu uicontextMenu = (a.ingredients.Count == 1) ? m : m.AddChild(ing.GetName() +
"x" + ing.req.ToString());
135 List<Thing> list =
new List<Thing>();
138 thing.GetIngredients(ing, list);
140 for (
int i = point.x - 1; i < point.x + 2; i++)
142 if (i >= 0 && i <
ELayer._map.Size)
144 for (
int j = point.z - 1; j < point.z + 2; j++)
146 if (j >= 0 && j <
ELayer._map.Size)
149 if (cell.detail !=
null && cell.detail.things.Count != 0)
151 foreach (
Thing thing2
in cell.detail.things)
153 thing2.GetIngredients(ing, list);
160 using (List<Thing>.Enumerator enumerator2 = list.GetEnumerator())
162 while (enumerator2.MoveNext())
164 Thing t = enumerator2.Current;
165 UIButton uibutton = Util.Instantiate<UIButton>(this.moldButtonContext,
null);
166 uicontextMenu.AddGameObject<UIButton>(uibutton);
167 t.SetImage(uibutton.icon);
168 Text mainText = uibutton.mainText;
169 string name = t.Name;
171 if (t.parent !=
ELayer.pc)
175 if (t.parent !=
ELayer._zone)
178 str2 = ((card !=
null) ? card.Name :
null);
182 str2 =
"ground".lang();
184 str3 = str + str2 +
")";
190 mainText.text = name + str3;
191 uibutton.onClick.AddListener(delegate()
206 public void RefreshDisassemble()
208 BaseList baseList = this.list;
212 if (!
ELayer.player.waitingInput)
218 ELayer.player.EndTurn(
true);
222 b.SetCard(a,
ButtonGrid.Mode.RecipeGrid, delegate(UINote n)
225 if (recipeSource !=
null)
228 Recipe.Create(recipeSource, -1,
null).WriteReqSkill(n);
231 b.mainText.SetActive(
false);
233 callback.onList = delegate(UIList.SortMode m)
240 baseList.callbacks = callback;
243 this.list.dsv.OnResize();
247 public void RefreshSize()
249 this.list.dsv.GetComponent<UIScrollView>().enabled = (this.list.ItemCount > 0);
250 RectTransform rectTransform = this.windows[0].Rect();
251 float x = rectTransform.sizeDelta.x;
252 float num = this.list.Rect().sizeDelta.y;
253 if (num > (
float)this.maxSize)
255 num = (float)this.maxSize;
257 rectTransform.sizeDelta =
new Vector2(x, num + (
float)((this.list.ItemCount > 0) ?
this.paddingY :
this.paddingY2));
258 rectTransform.RebuildLayout(
false);
265 public UIDynamicList list;
271 public UIButton moldButtonContext;
280 public int paddingY2;
283 public string idLastRecipe;