a wee while ago, I had to deal with mutating array (as I learned what it was called). Basically as my game refer to array indexes in actors, when I remove items from the array the indexes are all out of whack because I delete or add items to the array.
The work around what that I keep references (double linked) and every time I remove an item from the array I make sure to update my references.
But as time goes on I realise how prevenlant this issue is, I constantly delete stuff from arrays and it feels really bad to refreshing the indexes to maintain the links (particularly between levels when I load everything back into game instance.
A simple example where I’m facing this again.
I link my item in inventory to an array index (because widgets aren’t persisted between level loads) I don’t load too much into the widget. however, as soon as I delete 1 item from the array all my inventory item id’s are broken…
I seem to be missing a developer pattern here, can anyone please share how they optimized this ?
Thank you!