I created a own BlackList class which manages blacklisted items and also offers available item lists which are already pre-filtered with the blacklist.
A random pick from one of these lists is now always guarateed to not have a blacklisted item, and if the available list is empty instead no item will be shared.
This change should also improve performance when picking up a lot of items since there are no more allocations nor loops at runtime.
The precalculated lists will be refreshed whenever either the config changes or new items get unlocked.
Other stuff
I've added a .editorconfig so my VS doesn't go nuts and apply my formatting preferences when i autoformat the code.
Is there any reason the two references to MonoMod.RuntimeDetour and MonoMod.Utils (and some others, but they worked somehow) in the ShareSuite.csproj are fully specified? I couldn't get my VS to find/accept these libraries until I removed the full specification. If you need them, I can add them back.
If there's anything you're unhappy about or any newly introduced bugs let me know here or on discord
Issue
The game will freeze with randomize shared items enabled when picking up a boss items wich is also on the blacklist.
Cause
GetRandomItemOfTier
always returns the same boss item, thewhile
loop will never exit https://github.com/FunkFrog/RoR2SharedItems/blob/5b7bced132efeccd7b147c6fb3b7b5ddd5041fb0/ShareSuite/ItemSharingHooks.cs#L280-L281Fix
I created a own
BlackList
class which manages blacklisted items and also offers available item lists which are already pre-filtered with the blacklist. A random pick from one of these lists is now always guarateed to not have a blacklisted item, and if the available list is empty instead no item will be shared.This change should also improve performance when picking up a lot of items since there are no more allocations nor loops at runtime. The precalculated lists will be refreshed whenever either the config changes or new items get unlocked.
Other stuff
.editorconfig
so my VS doesn't go nuts and apply my formatting preferences when i autoformat the code.MonoMod.RuntimeDetour
andMonoMod.Utils
(and some others, but they worked somehow) in theShareSuite.csproj
are fully specified? I couldn't get my VS to find/accept these libraries until I removed the full specification. If you need them, I can add them back.