Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
RecipeUpdater.cs
Go to the documentation of this file.
1using System.Collections;
2using System.Collections.Generic;
3using System.Linq;
4
5public class RecipeUpdater : EClass
6{
7 public enum Mode
8 {
12 }
13
14 public IEnumerator Enumerator;
15
16 public Point pos = new Point();
17
18 public static List<Thing> listD = new List<Thing>();
19
20 public static List<Thing> lastListD = new List<Thing>();
21
22 public static HashSet<Recipe> recipes = new HashSet<Recipe>();
23
24 public static HashSet<Recipe> lastRecipes = new HashSet<Recipe>();
25
26 public static HashSet<string> factories = new HashSet<string>();
27
28 public static Mode mode;
29
30 public static int sync;
31
32 public static bool dirty;
33
34 public void Build(Point _p, Mode _mode = Mode.Passive)
35 {
37 {
38 return;
39 }
40 pos.Set(_p);
41 mode = _mode;
42 sync++;
43 Enumerator = RunRecipe().GetEnumerator();
44 if (mode == Mode.Passive)
45 {
46 return;
47 }
48 for (int i = 0; i < 1000; i++)
49 {
51 if (Enumerator == null)
52 {
53 break;
54 }
55 }
56 }
57
58 public void FixedUpdate()
59 {
60 if (Enumerator != null && !Enumerator.MoveNext())
61 {
62 Enumerator = null;
63 }
64 }
65
66 public IEnumerable RunRecipe()
67 {
68 recipes.Clear();
69 factories.Clear();
70 yield return true;
71 int count = 0;
72 for (int i = pos.x - 1; i < pos.x + 2; i++)
73 {
74 if (i < 0 || i >= EClass._map.Size)
75 {
76 continue;
77 }
78 for (int j = pos.z - 1; j < pos.z + 2; j++)
79 {
80 if (j < 0 || j >= EClass._map.Size)
81 {
82 continue;
83 }
84 Cell cell = EClass._map.cells[i, j];
85 if (cell.detail == null || cell.detail.things.Count == 0)
86 {
87 continue;
88 }
89 if (pos.cell.effect?.IsFire ?? false)
90 {
91 factories.Add("fire");
92 }
93 foreach (Thing thing in cell.detail.things)
94 {
95 if (thing.IsInstalled)
96 {
97 if (thing.trait.IsFactory)
98 {
99 factories.Add(thing.id);
100 }
101 if (thing.trait.ToggleType == ToggleType.Fire && thing.isOn)
102 {
103 factories.Add("fire");
104 }
105 }
106 }
107 }
108 }
109 yield return true;
111 yield return true;
112 foreach (Thing thing2 in EClass.pc.things)
113 {
114 thing2.GetRecipes(recipes);
115 count++;
116 }
117 yield return true;
118 for (int k = pos.x - 1; k < pos.x + 2; k++)
119 {
120 if (k < 0 || k >= EClass._map.Size)
121 {
122 continue;
123 }
124 for (int l = pos.z - 1; l < pos.z + 2; l++)
125 {
126 if (l < 0 || l >= EClass._map.Size)
127 {
128 continue;
129 }
130 Cell cell = EClass._map.cells[k, l];
131 if (cell.detail == null || cell.detail.things.Count == 0)
132 {
133 continue;
134 }
135 foreach (Thing thing3 in cell.detail.things)
136 {
137 if (thing3.isNPCProperty)
138 {
139 continue;
140 }
141 if (thing3.trait.IsContainer)
142 {
143 if (!thing3.IsInstalled)
144 {
145 continue;
146 }
147 }
148 else if (thing3.IsInstalled)
149 {
150 continue;
151 }
152 thing3.GetRecipes(recipes);
153 count++;
154 }
155 }
156 }
157 yield return true;
158 List<Recipe> list = new List<Recipe>();
159 foreach (Recipe recipe in recipes)
160 {
161 bool flag = true;
162 string id = recipe.id;
163 if ((id == "waystone" || id == "waystone_temp") && EClass.game.quests.GetPhase<QuestExploration>() >= 6)
164 {
165 list.Add(recipe);
166 continue;
167 }
168 foreach (Recipe.Ingredient ingredient in recipe.ingredients)
169 {
170 if (ingredient.thing == null)
171 {
172 flag = false;
173 break;
174 }
175 }
176 if (!flag)
177 {
178 list.Add(recipe);
179 }
180 }
181 foreach (Recipe item in list)
182 {
183 recipes.Remove(item);
184 }
185 yield return true;
186 if (mode == Mode.Passive && lastRecipes.SetEquals(recipes))
187 {
188 yield return false;
189 }
190 else if (mode != Mode.Validate)
191 {
193 }
194 lastRecipes.Clear();
195 foreach (Recipe recipe2 in recipes)
196 {
197 lastRecipes.Add(recipe2);
198 }
199 yield return null;
200 }
201
202 public IEnumerable RunDisassemble()
203 {
204 lastListD.Clear();
205 foreach (Thing item in listD)
206 {
208 }
209 listD.Clear();
210 yield return true;
211 foreach (Card item2 in EClass.pc.pos.ListCards())
212 {
213 if (item2.isThing)
214 {
216 }
217 }
218 yield return true;
219 foreach (Thing thing in EClass.pc.things)
220 {
221 thing.GetDisassembles(listD);
222 }
223 yield return true;
224 if (mode == Mode.Passive && listD.SequenceEqual(lastListD))
225 {
226 yield return false;
227 }
228 else if (mode != Mode.Validate)
229 {
231 }
232 yield return null;
233 }
234}
ToggleType
Definition: ToggleType.cs:2
void Add(Act a, string s="")
Definition: ActPlan.cs:11
Definition: Card.cs:11
virtual bool isThing
Definition: Card.cs:1957
string id
Definition: Card.cs:31
bool isNPCProperty
Definition: Card.cs:526
Point pos
Definition: Card.cs:55
Trait trait
Definition: Card.cs:49
ThingContainer things
Definition: Card.cs:34
bool IsInstalled
Definition: Card.cs:2241
virtual Thing Thing
Definition: Card.cs:1934
bool isOn
Definition: Card.cs:514
List< Thing > things
Definition: CellDetail.cs:11
bool IsFire
Definition: CellEffect.cs:135
Definition: Cell.cs:7
CellEffect effect
Definition: Cell.cs:94
CellDetail detail
Definition: Cell.cs:92
Definition: EClass.cs:5
static Game game
Definition: EClass.cs:8
static Map _map
Definition: EClass.cs:18
static Chara pc
Definition: EClass.cs:14
QuestManager quests
Definition: Game.cs:179
static LayerCraftFloat Instance
int Size
Definition: MapBounds.cs:20
Cell[,] cells
Definition: Map.cs:85
Definition: Point.cs:9
List< Card > ListCards(bool includeMasked=false)
Definition: Point.cs:1015
Point Set(int _x, int _z)
Definition: Point.cs:479
int x
Definition: Point.cs:36
int z
Definition: Point.cs:39
Cell cell
Definition: Point.cs:51
static List< Thing > lastListD
static bool dirty
IEnumerator Enumerator
void Build(Point _p, Mode _mode=Mode.Passive)
static Mode mode
static HashSet< Recipe > recipes
static HashSet< string > factories
IEnumerable RunRecipe()
static HashSet< Recipe > lastRecipes
static List< Thing > listD
IEnumerable RunDisassemble()
static int sync
void FixedUpdate()
Definition: Recipe.cs:7
string id
Definition: Recipe.cs:161
List< Ingredient > ingredients
Definition: Recipe.cs:164
void AddFactory(HashSet< string > hash)
Definition: Thing.cs:8
void GetDisassembles(List< Thing > list)
Definition: Thing.cs:1687
void GetRecipes(HashSet< Recipe > recipes)
Definition: Thing.cs:1683
virtual bool IsFactory
Definition: Trait.cs:135
virtual ToggleType ToggleType
Definition: Trait.cs:456
virtual bool IsContainer
Definition: Trait.cs:205