Still a work-in-progress since I'm not convinced upon how to achieve this - here I hard-wired BombSpawner and RopeSpawner with Inventory singleton which is specifically for main-dude - but in the end, should I care about implementing it in a generic way, if main dude is the only thing in the game that can spawn bombs and ropes?
I proposed more generic way of implementing in the comments
To be settled
Edit 1:
After getting back to this, I'm fresh with a new idea. Place bomb counter in the BombSpawner, RopeCounter in the RopeSpawner, hearts counter is already within the HitpointComponent, dollars counter will be after https://github.com/dbeef/spelunky-psp/pull/99 inside the Wallet passive item - so there's no need for the Inventory in the
end, once I tangle them with the subject/observer pattern.
Once Inventory is removed, GameLoop should take the responsibility of storing main-dude state inbetween the levels, i.e by copying the amount of dollars/hearts/ropes/bombs/items.
However, I am leaving it for a future housekeeping, as the present use of Inventory inside the spawners is not inherently bad.
Edit 2:
Decided to untangle RopeSpawner/BombSpawner from Inventory in this MR.
Still a work-in-progress since I'm not convinced upon how to achieve this - here I hard-wired
BombSpawner
andRopeSpawner
withInventory
singleton which is specifically for main-dude - but in the end, should I care about implementing it in a generic way, if main dude is the only thing in the game that can spawn bombs and ropes?I proposed more generic way of implementing in the comments
To be settled
Edit 1:
After getting back to this, I'm fresh with a new idea. Place bomb counter in the
BombSpawner
,RopeCounter
in theRopeSpawner
, hearts counter is already within theHitpointComponent
, dollars counter will be after https://github.com/dbeef/spelunky-psp/pull/99 inside theWallet
passive item - so there's no need for theInventory
in the end, once I tangle them with the subject/observer pattern.Once
Inventory
is removed,GameLoop
should take the responsibility of storing main-dude state inbetween the levels, i.e by copying the amount of dollars/hearts/ropes/bombs/items.However, I am leaving it for a future housekeeping, as the present use of
Inventory
inside the spawners is not inherently bad.Edit 2:
Decided to untangle
RopeSpawner
/BombSpawner
fromInventory
in this MR.