Elin Modding Docs Doc
Loading...
Searching...
No Matches
RecipeUpdater.cs
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Linq;
5
6// Token: 0x0200005F RID: 95
7public class RecipeUpdater : EClass
8{
9 // Token: 0x06000279 RID: 633 RVA: 0x000137AC File Offset: 0x000119AC
10 public void Build(Point _p, RecipeUpdater.Mode _mode = RecipeUpdater.Mode.Passive)
11 {
12 if (!LayerCraftFloat.Instance)
13 {
14 return;
15 }
16 this.pos.Set(_p);
17 RecipeUpdater.mode = _mode;
18 RecipeUpdater.sync++;
19 this.Enumerator = this.RunRecipe().GetEnumerator();
20 if (RecipeUpdater.mode != RecipeUpdater.Mode.Passive)
21 {
22 for (int i = 0; i < 1000; i++)
23 {
24 this.FixedUpdate();
25 if (this.Enumerator == null)
26 {
27 break;
28 }
29 }
30 }
31 }
32
33 // Token: 0x0600027A RID: 634 RVA: 0x0001381B File Offset: 0x00011A1B
34 public void FixedUpdate()
35 {
36 if (this.Enumerator == null)
37 {
38 return;
39 }
40 if (!this.Enumerator.MoveNext())
41 {
42 this.Enumerator = null;
43 }
44 }
45
46 // Token: 0x0600027B RID: 635 RVA: 0x0001383A File Offset: 0x00011A3A
47 public IEnumerable RunRecipe()
48 {
49 RecipeUpdater.recipes.Clear();
50 RecipeUpdater.factories.Clear();
51 yield return true;
52 int count = 0;
53 for (int i = this.pos.x - 1; i < this.pos.x + 2; i++)
54 {
55 if (i >= 0 && i < EClass._map.Size)
56 {
57 for (int j = this.pos.z - 1; j < this.pos.z + 2; j++)
58 {
59 if (j >= 0 && j < EClass._map.Size)
60 {
61 Cell cell = EClass._map.cells[i, j];
62 if (cell.detail != null && cell.detail.things.Count != 0)
63 {
64 CellEffect effect = this.pos.cell.effect;
65 if (effect != null && effect.IsFire)
66 {
67 RecipeUpdater.factories.Add("fire");
68 }
69 foreach (Thing thing in cell.detail.things)
70 {
71 if (thing.IsInstalled)
72 {
73 if (thing.trait.IsFactory)
74 {
75 RecipeUpdater.factories.Add(thing.id);
76 }
77 if (thing.trait.ToggleType == ToggleType.Fire && thing.isOn)
78 {
79 RecipeUpdater.factories.Add("fire");
80 }
81 }
82 }
83 }
84 }
85 }
86 }
87 }
88 yield return true;
89 EClass.pc.things.AddFactory(RecipeUpdater.factories);
90 yield return true;
91 foreach (Thing thing2 in EClass.pc.things)
92 {
93 thing2.GetRecipes(RecipeUpdater.recipes);
94 int num = count;
95 count = num + 1;
96 }
97 yield return true;
98 for (int k = this.pos.x - 1; k < this.pos.x + 2; k++)
99 {
100 if (k >= 0 && k < EClass._map.Size)
101 {
102 for (int l = this.pos.z - 1; l < this.pos.z + 2; l++)
103 {
104 if (l >= 0 && l < EClass._map.Size)
105 {
106 Cell cell = EClass._map.cells[k, l];
107 if (cell.detail != null && cell.detail.things.Count != 0)
108 {
109 foreach (Thing thing3 in cell.detail.things)
110 {
111 if (!thing3.isNPCProperty)
112 {
113 if (thing3.trait.IsContainer)
114 {
115 if (!thing3.IsInstalled)
116 {
117 continue;
118 }
119 }
120 else if (thing3.IsInstalled)
121 {
122 continue;
123 }
124 thing3.GetRecipes(RecipeUpdater.recipes);
125 int num = count;
126 count = num + 1;
127 }
128 }
129 }
130 }
131 }
132 }
133 }
134 yield return true;
135 List<Recipe> list = new List<Recipe>();
136 foreach (Recipe recipe in RecipeUpdater.recipes)
137 {
138 bool flag = true;
139 string id = recipe.id;
140 if ((id == "waystone" || id == "waystone_temp") && EClass.game.quests.GetPhase<QuestExploration>() >= 6)
141 {
142 list.Add(recipe);
143 }
144 else
145 {
146 using (List<Recipe.Ingredient>.Enumerator enumerator3 = recipe.ingredients.GetEnumerator())
147 {
148 while (enumerator3.MoveNext())
149 {
150 if (enumerator3.Current.thing == null)
151 {
152 flag = false;
153 break;
154 }
155 }
156 }
157 if (!flag)
158 {
159 list.Add(recipe);
160 }
161 }
162 }
163 foreach (Recipe item in list)
164 {
165 RecipeUpdater.recipes.Remove(item);
166 }
167 yield return true;
168 if (RecipeUpdater.mode == RecipeUpdater.Mode.Passive && RecipeUpdater.lastRecipes.SetEquals(RecipeUpdater.recipes))
169 {
170 yield return false;
171 }
172 else if (RecipeUpdater.mode != RecipeUpdater.Mode.Validate)
173 {
174 LayerCraftFloat.Instance.RefreshCraft();
175 }
176 RecipeUpdater.lastRecipes.Clear();
177 foreach (Recipe item2 in RecipeUpdater.recipes)
178 {
179 RecipeUpdater.lastRecipes.Add(item2);
180 }
181 yield return null;
182 yield break;
183 }
184
185 // Token: 0x0600027C RID: 636 RVA: 0x0001384A File Offset: 0x00011A4A
186 public IEnumerable RunDisassemble()
187 {
188 RecipeUpdater.lastListD.Clear();
189 foreach (Thing item in RecipeUpdater.listD)
190 {
191 RecipeUpdater.lastListD.Add(item);
192 }
193 RecipeUpdater.listD.Clear();
194 yield return true;
195 foreach (Card card in EClass.pc.pos.ListCards(false))
196 {
197 if (card.isThing)
198 {
199 card.Thing.GetDisassembles(RecipeUpdater.listD);
200 }
201 }
202 yield return true;
203 foreach (Thing thing in EClass.pc.things)
204 {
205 thing.GetDisassembles(RecipeUpdater.listD);
206 }
207 yield return true;
208 if (RecipeUpdater.mode == RecipeUpdater.Mode.Passive && RecipeUpdater.listD.SequenceEqual(RecipeUpdater.lastListD))
209 {
210 yield return false;
211 }
212 else if (RecipeUpdater.mode != RecipeUpdater.Mode.Validate)
213 {
214 LayerCraftFloat.Instance.RefreshDisassemble();
215 }
216 yield return null;
217 yield break;
218 }
219
220 // Token: 0x0400050F RID: 1295
221 public IEnumerator Enumerator;
222
223 // Token: 0x04000510 RID: 1296
224 public Point pos = new Point();
225
226 // Token: 0x04000511 RID: 1297
227 public static List<Thing> listD = new List<Thing>();
228
229 // Token: 0x04000512 RID: 1298
230 public static List<Thing> lastListD = new List<Thing>();
231
232 // Token: 0x04000513 RID: 1299
233 public static HashSet<Recipe> recipes = new HashSet<Recipe>();
234
235 // Token: 0x04000514 RID: 1300
236 public static HashSet<Recipe> lastRecipes = new HashSet<Recipe>();
237
238 // Token: 0x04000515 RID: 1301
239 public static HashSet<string> factories = new HashSet<string>();
240
241 // Token: 0x04000516 RID: 1302
242 public static RecipeUpdater.Mode mode;
243
244 // Token: 0x04000517 RID: 1303
245 public static int sync;
246
247 // Token: 0x04000518 RID: 1304
248 public static bool dirty;
249
250 // Token: 0x020007D1 RID: 2001
251 public enum Mode
252 {
253 // Token: 0x040021ED RID: 8685
254 Passive,
255 // Token: 0x040021EE RID: 8686
256 Immediate,
257 // Token: 0x040021EF RID: 8687
258 Validate
259 }
260}
Definition Card.cs:13
Definition Cell.cs:10
Definition Point.cs:11
Definition Thing.cs:10