@@ -108,10 +108,11 @@ public static void RecursiveRecipes()
108108 if ( storedItems == null )
109109 return ;
110110
111- lock ( ( Dictionary < Recipe , RecipeInfo > ) Members . recipeCache )
111+ var recipeCache = ( Dictionary < Recipe , RecipeInfo > ) Members . recipeCache ;
112+ lock ( recipeCache )
112113 {
113114 var recursiveSearch = new RecursiveSearch ( storedItems , GuiAsCraftingSource ( ) ) ;
114- ( ( Dictionary < Recipe , RecipeInfo > ) Members . recipeCache ) . Clear ( ) ;
115+ recipeCache . Clear ( ) ;
115116 foreach ( int i in RecursiveCraft . RecursiveCraft . SortedRecipeList )
116117 {
117118 Recipe recipe = Main . recipe [ i ] ;
@@ -158,7 +159,10 @@ private static void SingleSearch(RecursiveSearch recursiveSearch, Recipe recipe)
158159 }
159160
160161 if ( recipeInfo != null && recipeInfo . RecipeUsed . Count > 1 )
161- ( ( Dictionary < Recipe , RecipeInfo > ) Members . recipeCache ) . Add ( recipe , recipeInfo ) ;
162+ {
163+ var recipeCache = ( Dictionary < Recipe , RecipeInfo > ) Members . recipeCache ;
164+ recipeCache . Add ( recipe , recipeInfo ) ;
165+ }
162166 }
163167
164168 [ MethodImpl ( MethodImplOptions . NoInlining ) ]
@@ -176,27 +180,34 @@ public static bool UpdateRecipe(Recipe recipe)
176180 return false ;
177181
178182 Dictionary < int , int > storedItems = GetStoredItems ( ) ;
183+ var recipeCache = ( Dictionary < Recipe , RecipeInfo > ) Members . recipeCache ;
184+
179185 if ( storedItems != null )
180- lock ( ( Dictionary < Recipe , RecipeInfo > ) Members . recipeCache )
186+ lock ( recipeCache )
181187 {
182- ( ( Dictionary < Recipe , RecipeInfo > ) Members . recipeCache ) . Remove ( recipe ) ;
188+ recipeCache . Remove ( recipe ) ;
183189 var recursiveSearch = new RecursiveSearch ( storedItems , GuiAsCraftingSource ( ) ) ;
184190 SingleSearch ( recursiveSearch , recipe ) ;
185191 }
186192
187- return ( ( Dictionary < Recipe , RecipeInfo > ) Members . recipeCache ) . ContainsKey ( recipe ) ;
193+ return recipeCache . ContainsKey ( recipe ) ;
188194 }
189195
190196 [ MethodImpl ( MethodImplOptions . NoInlining ) ]
191197 public static Recipe ApplyCompoundRecipe ( Recipe recipe )
192198 {
193199 if ( recipe is CompoundRecipe compound )
194200 recipe = compound . OverridenRecipe ;
195- if ( ( ( Dictionary < Recipe , RecipeInfo > ) Members . recipeCache ) . TryGetValue ( recipe , out RecipeInfo recipeInfo ) )
201+
202+ var recipeCache = ( Dictionary < Recipe , RecipeInfo > ) Members . recipeCache ;
203+
204+ if ( recipeCache . TryGetValue ( recipe , out RecipeInfo recipeInfo ) )
196205 {
197206 int index = Array . IndexOf ( Main . recipe , recipe ) ;
198- ( ( CompoundRecipe ) Members . compoundRecipe ) . Apply ( index , recipeInfo ) ;
199- return ( CompoundRecipe ) Members . compoundRecipe ;
207+ var compoundRecipe = ( CompoundRecipe ) Members . compoundRecipe ;
208+
209+ compoundRecipe . Apply ( index , recipeInfo ) ;
210+ return compoundRecipe ;
200211 }
201212
202213 return recipe ;
@@ -205,11 +216,15 @@ public static Recipe ApplyCompoundRecipe(Recipe recipe)
205216 [ MethodImpl ( MethodImplOptions . NoInlining ) ]
206217 public static Recipe ApplyThreadCompoundRecipe ( Recipe recipe )
207218 {
208- if ( ( ( Dictionary < Recipe , RecipeInfo > ) Members . recipeCache ) . TryGetValue ( recipe , out RecipeInfo recipeInfo ) )
219+ var recipeCache = ( Dictionary < Recipe , RecipeInfo > ) Members . recipeCache ;
220+
221+ if ( recipeCache . TryGetValue ( recipe , out RecipeInfo recipeInfo ) )
209222 {
210223 int index = Array . IndexOf ( Main . recipe , recipe ) ;
211- ( ( CompoundRecipe ) Members . threadCompoundRecipe ) . Apply ( index , recipeInfo ) ;
212- return ( CompoundRecipe ) Members . threadCompoundRecipe ;
224+ var threadCompoundRecipe = ( CompoundRecipe ) Members . threadCompoundRecipe ;
225+
226+ threadCompoundRecipe . Apply ( index , recipeInfo ) ;
227+ return threadCompoundRecipe ;
213228 }
214229
215230 return recipe ;
0 commit comments