Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modding: Allow disabling/removing vanilla recipes #28

Open
jlai opened this issue Nov 1, 2021 · 1 comment
Open

Modding: Allow disabling/removing vanilla recipes #28

jlai opened this issue Nov 1, 2021 · 1 comment

Comments

@jlai
Copy link

jlai commented Nov 1, 2021

Right now (9.4.x), there doesn't appear to be a good way to remove or disable vanilla recipes from the game short of copying & pasting the entire item cs into a .override.cs -- which is quite fragile, especially for mods intended for distribution.

ModsPreInitialize/ModsPostInitialize allows tweaking some of the recipe options but there's no way to skip the calls to Initialize and CraftingComponent.AddRecipe or remove a recipe from a crafting object (also meaning the crafting component can't be customized this way).

I'm thinking the default template constructor could be updated to something like this

this.CraftingObject = typeof(RockerBoxObject); // allow overriding

this.ModsPreInitialize();
if (!this.Recipes.Any()) return; // don't register recipe family if all recipes removed by mod
this.Initialize(Localizer.DoStr("Gold Concentrate"), typeof(GoldConcentrateRecipe));
this.ModsPostInitialize();
CraftingComponent.AddRecipe(this.CraftingObject, this);

There probably also needs to be some tweaks to whatever this code is doing, to skip empty recipe family classes:

System.InvalidOperationException: Sequence contains no elements
   at System.Linq.ThrowHelper.ThrowNoElementsException()
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
   at Eco.Gameplay.Items.RecipeFamily.get_DefaultRecipe()
   at Eco.Gameplay.Items.RecipeFamily.get_Ingredients()
   at Eco.Gameplay.Items.RecipeFamily.<>c.<Initialize>b__77_14(RecipeFamily recipe)
   at System.Linq.Enumerable.SelectManyIterator[TSource,TCollection,TResult](IEnumerable`1 source, Func`2 collectionSelector, Func`3 resultSelector)+MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Linq.Lookup`2.Create[TSource](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at System.Linq.GroupedEnumerable`3.GetEnumerator()
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at Eco.Gameplay.Items.RecipeFamily.Initialize()
   at Eco.ModKit.ModDataSync..ctor()
   at Eco.ModKit.ModKitPlugin.<LoadModsDataAsync>b__34_0()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__277_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
@D3nnis3n D3nnis3n transferred this issue from StrangeLoopGames/EcoSuggestions Nov 26, 2021
@D3nnis3n
Copy link

Moved to the ModKit repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants