Elin Modding Docs Doc
Loading...
Searching...
No Matches
LayerCraftFloat.cs
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4using UnityEngine.UI;
5
6// Token: 0x02000536 RID: 1334
7public class LayerCraftFloat : ELayer
8{
9 // Token: 0x06002429 RID: 9257 RVA: 0x000CB930 File Offset: 0x000C9B30
10 public override void OnInit()
11 {
12 LayerCraftFloat.Instance = this;
13 }
14
15 // Token: 0x0600242A RID: 9258 RVA: 0x000CB938 File Offset: 0x000C9B38
16 public override void OnSwitchContent(Window window)
17 {
18 if (!ELayer.core.IsGameStarted)
19 {
20 return;
21 }
22 ELayer.game.updater.recipe.Build(ELayer.pc.pos, RecipeUpdater.Mode.Immediate);
23 }
24
25 // Token: 0x0600242B RID: 9259 RVA: 0x000CB968 File Offset: 0x000C9B68
26 public void Update()
27 {
28 if (EInput.middleMouse.down)
29 {
30 ButtonGrid componentOf = InputModuleEX.GetComponentOf<ButtonGrid>();
31 if (componentOf && componentOf.transform.IsChildOf(base.transform))
32 {
33 Recipe recipe = componentOf.recipe;
34 if (recipe != null && this.windows[0].idTab == 0)
35 {
36 this.ShowContextMenu(recipe);
37 }
38 }
39 }
40 if (Input.GetMouseButton(0))
41 {
42 ButtonGrid componentOf2 = InputModuleEX.GetComponentOf<ButtonGrid>();
43 if (componentOf2 && componentOf2.transform.IsChildOf(base.transform) && ELayer.player.waitingInput && ELayer.pc.HasNoGoal && componentOf2.recipe.id == this.idLastRecipe)
44 {
45 this.list.callbacks.OnClick(componentOf2.recipe, componentOf2);
46 return;
47 }
48 }
49 else
50 {
51 this.idLastRecipe = null;
52 }
53 }
54
55 // Token: 0x0600242C RID: 9260 RVA: 0x000CBA3E File Offset: 0x000C9C3E
56 public void OnCompleteCraft()
57 {
58 }
59
60 // Token: 0x0600242D RID: 9261 RVA: 0x000CBA40 File Offset: 0x000C9C40
61 public void RefreshCraft()
62 {
63 this.list.callbacks = new UIList.Callback<Recipe, ButtonGrid>
64 {
65 onClick = delegate(Recipe a, ButtonGrid b)
66 {
67 ELayer.ui.RemoveLayers(false);
68 ELayer.game.updater.recipe.Build(ELayer.pc.pos, RecipeUpdater.Mode.Validate);
69 if (!RecipeUpdater.recipes.Contains(a))
70 {
71 SE.BeepSmall();
72 ELayer.game.updater.recipe.Build(ELayer.pc.pos, RecipeUpdater.Mode.Immediate);
73 return;
74 }
75 a.OnChangeIngredient();
76 this.recipe = a;
77 this.idLastRecipe = this.recipe.id;
78 if (!ELayer.player.waitingInput)
79 {
80 SE.BeepSmall();
81 return;
82 }
83 TaskCraft taskCraft = new TaskCraft
84 {
85 recipe = this.recipe,
86 num = 1,
87 repeat = false,
88 floatMode = true
89 };
90 taskCraft.ResetReq();
91 if (!taskCraft.IsIngredientsValid(false, taskCraft.num))
92 {
93 SE.Beep();
94 return;
95 }
96 ELayer.pc.SetAI(taskCraft);
97 ActionMode.Adv.SetTurbo(-1);
98 },
99 onRedraw = delegate(Recipe a, ButtonGrid b, int i)
100 {
101 b.SetCraftRecipe(a, ButtonGrid.Mode.RecipeGrid, true);
102 if (!ELayer.player.recipes.hoveredRecipes.Contains(a.id))
103 {
104 b.Attach("recipe_new", false);
105 }
106 b.onRightClick = delegate()
107 {
108 this.ShowContextMenu(a);
109 };
110 },
111 onList = delegate(UIList.SortMode m)
112 {
113 foreach (Recipe o in RecipeUpdater.recipes)
114 {
115 this.list.Add(o);
116 }
117 }
118 };
119 this.list.List();
120 this.RefreshSize();
121 this.list.dsv.OnResize();
122 }
123
124 // Token: 0x0600242E RID: 9262 RVA: 0x000CBAB4 File Offset: 0x000C9CB4
125 public void ShowContextMenu(Recipe a)
126 {
127 UIContextMenu m = ELayer.ui.CreateContextMenuInteraction();
128 Point point = ELayer.pc.pos.Copy();
129 using (List<Recipe.Ingredient>.Enumerator enumerator = a.ingredients.GetEnumerator())
130 {
131 while (enumerator.MoveNext())
132 {
133 Recipe.Ingredient ing = enumerator.Current;
134 UIContextMenu uicontextMenu = (a.ingredients.Count == 1) ? m : m.AddChild(ing.GetName() + "x" + ing.req.ToString());
135 List<Thing> list = new List<Thing>();
136 foreach (Thing thing in ELayer.pc.things)
137 {
138 thing.GetIngredients(ing, list);
139 }
140 for (int i = point.x - 1; i < point.x + 2; i++)
141 {
142 if (i >= 0 && i < ELayer._map.Size)
143 {
144 for (int j = point.z - 1; j < point.z + 2; j++)
145 {
146 if (j >= 0 && j < ELayer._map.Size)
147 {
148 Cell cell = ELayer._map.cells[i, j];
149 if (cell.detail != null && cell.detail.things.Count != 0)
150 {
151 foreach (Thing thing2 in cell.detail.things)
152 {
153 thing2.GetIngredients(ing, list);
154 }
155 }
156 }
157 }
158 }
159 }
160 using (List<Thing>.Enumerator enumerator2 = list.GetEnumerator())
161 {
162 while (enumerator2.MoveNext())
163 {
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;
170 string str3;
171 if (t.parent != ELayer.pc)
172 {
173 string str = "(";
174 string str2;
175 if (t.parent != ELayer._zone)
176 {
177 Card card = t.parent as Card;
178 str2 = ((card != null) ? card.Name : null);
179 }
180 else
181 {
182 str2 = "ground".lang();
183 }
184 str3 = str + str2 + ")";
185 }
186 else
187 {
188 str3 = "";
189 }
190 mainText.text = name + str3;
191 uibutton.onClick.AddListener(delegate()
192 {
193 ing.thing = t;
194 SE.ClickOk();
195 this.list.List();
196 m.Hide();
197 });
198 }
199 }
200 }
201 }
202 m.Show();
203 }
204
205 // Token: 0x0600242F RID: 9263 RVA: 0x000CBE34 File Offset: 0x000CA034
206 public void RefreshDisassemble()
207 {
208 BaseList baseList = this.list;
209 UIList.Callback<Thing, ButtonGrid> callback = new UIList.Callback<Thing, ButtonGrid>();
210 callback.onClick = delegate(Thing a, ButtonGrid b)
211 {
212 if (!ELayer.player.waitingInput)
213 {
214 SE.BeepSmall();
215 return;
216 }
217 a.Disassemble();
218 ELayer.player.EndTurn(true);
219 };
220 callback.onRedraw = delegate(Thing a, ButtonGrid b, int i)
221 {
222 b.SetCard(a, ButtonGrid.Mode.RecipeGrid, delegate(UINote n)
223 {
224 RecipeSource recipeSource = RecipeManager.Get(a.id);
225 if (recipeSource != null)
226 {
227 n.Space(0, 1);
228 Recipe.Create(recipeSource, -1, null).WriteReqSkill(n);
229 }
230 });
231 b.mainText.SetActive(false);
232 };
233 callback.onList = delegate(UIList.SortMode m)
234 {
235 foreach (Thing o in RecipeUpdater.listD)
236 {
237 this.list.Add(o);
238 }
239 };
240 baseList.callbacks = callback;
241 this.list.List();
242 this.RefreshSize();
243 this.list.dsv.OnResize();
244 }
245
246 // Token: 0x06002430 RID: 9264 RVA: 0x000CBED0 File Offset: 0x000CA0D0
247 public void RefreshSize()
248 {
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)
254 {
255 num = (float)this.maxSize;
256 }
257 rectTransform.sizeDelta = new Vector2(x, num + (float)((this.list.ItemCount > 0) ? this.paddingY : this.paddingY2));
258 rectTransform.RebuildLayout(false);
259 }
260
261 // Token: 0x04001395 RID: 5013
262 public static LayerCraftFloat Instance;
263
264 // Token: 0x04001396 RID: 5014
265 public UIDynamicList list;
266
267 // Token: 0x04001397 RID: 5015
268 public Recipe recipe;
269
270 // Token: 0x04001398 RID: 5016
271 public UIButton moldButtonContext;
272
273 // Token: 0x04001399 RID: 5017
274 public int maxSize;
275
276 // Token: 0x0400139A RID: 5018
277 public int paddingY;
278
279 // Token: 0x0400139B RID: 5019
280 public int paddingY2;
281
282 // Token: 0x0400139C RID: 5020
283 public string idLastRecipe;
284}
Definition Card.cs:13
Definition Cell.cs:10
Definition Point.cs:11
Definition Thing.cs:10