then click read more!
so an "item" in your inventory is just a named enum member, because then i can save/load the inventory by just casting those to/from int. then each enum maps to an InventoryItemProps instance which knows what sprite it uses and animates the sprite, and also has an OnUse delegate that takes a player and returns bool whether it was successful or not. the jank part is that's the same method signature as power up entities use when the player touches em so when i instantiate the item props i create an instance of the power up, then pass that power up's function to the props like
new PowerUpAir(0, null, Vector2.Zero).PickedUp
then when i use an item in the inventory, it calls a function on the current game mode and passes the item props to that. right now only the overworld mode has that implemented. the overworld mode has a clone of the player object that's used for the player preview (so you can see what power up you have like the super mario in the top left of the screen of SMW), and instead of applying the fake power up to the actual player object (which is on the map) it applies it to the clone instead. this works because the player state is global (for historical reasons) which is very bad but also i am never going to change it
except now the player's power up routine spawns a power up cloud particle in a random spot on the map so to fix that every frame i find out what the in-world position would be to match up with the player clone preview in the UI so that when the clone's power up routine spawns the particle it'll spawn it in the right area to overlay the GUI
except! the GUI is rendered after the world and its particles so i took the particles out of that render pass and gave them their own render pass so that the power up particle renders over the player preview window
its horrible
oh and all of this returns true if the player clone could actually utilize the power up (so if there's no change it returns false) so that eventually when everything's done the inventory knows whether or not to remove the power up from the player's inventory
