JamesHDuffield / ascii-rust

A retro ASCII art space shooter, inspired by Vampire Survivors, written in the Bevy game engine.
https://jameshduffield.github.io/ascii-rust/
2 stars 1 forks source link

Feat: allow for selection of upgrades during level up #3

Closed JamesHDuffield closed 1 year ago

JamesHDuffield commented 1 year ago

Trying to invent a data structure for the upgrades and wanted some ideas if you have any.

Ideally the upgrades can be iterated over, and have a "display name" associated with them, but as properties of this struct that is not very simple or clean.

I've implemented the UI and Selection use cases so hopefully it makes sense,

EchelonFour commented 1 year ago

doesn't it make more sense for Upgrades to not be a component, but for it to modify the numbers on the other components when it happens?

JamesHDuffield commented 1 year ago

Sounds like a nightmare to display via UI or interact with when leveling up, queries that get 20 different components seem cumbersome.

EchelonFour commented 1 year ago

But the alternative is getting the same upgrade component everywhere for everything. Makes more sense for the engine to know it's own speed and the gun to know it's own fire rate and for the upgrade event to be complex. Oh! Events! https://bevy-cheatbook.github.io/programming/events.html Define an event for each upgrade type and emit that when it happens? That way each upgrade system is discrete?

JamesHDuffield commented 1 year ago

Events certainly make the splitting up of the upgrading of things cleaner, gave it a go. Main problem is there is now no central place to understand what upgrades have previously been selected. I.E. Need to query a bunch of disparate places to get info for the hud, and the same again to calculate what options to "roll" when leveling up.

EchelonFour commented 1 year ago

Hmm. Good point. Not sure.