-
Notifications
You must be signed in to change notification settings - Fork 37
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
Better fix for #390 - Use AddGadget, but only when needed #404
Better fix for #390 - Use AddGadget, but only when needed #404
Conversation
Personally I preferred it the old way since it had less duplication of the "functional" code and property setting, but it's really personal preference. We can ask other contributors what they prefer. |
This way actually has less duplication and less redundant code. It makes use of the return value of |
I already asked ECM and I think she didn't mind either way. I'll ask one other "maintainer" and see what they think. |
Ask and you shall receive an even harder decision, A THIRD OPTION! public static CraftingGadget SetRecipe(this ICustomPrefab customPrefab, RecipeData recipeData)
{
if (!customPrefab.TryGetGadget(out CraftingGadget craftingGadget))
return customPrefab.AddGadget(new CraftingGadget(customPrefab, recipeData));
craftingGadget.RecipeData = recipeData;
return craftingGadget;
} |
I prefer this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest that the code should be reformatted to fit this suggestion.
265f333
to
51ec1ce
Compare
* Improve PDA item sorting capabilities * Prevented a breaking change. Applied suggestions to improve docs. * Added Enum for clarity of the insert position (sorting) * Carry over changes introduced in PR #404 --------- Co-authored-by: LeeTwentyThree <[email protected]>
This fixes the duplicate gadget exception by only using AddGadget when needed. (More efficient)