I did an event flag system this morning. No gif because it's an event flag system: just take my word for it, if you open the chest in the starting room and reload the scene it stays open. Excitement!
Anyway, I had one of those moments while I was doing it: I was lamenting
how I couldn't very easily fit all my event flags into one enum, and I
was thinking of a way to handle that! I had halfway designed this completely ludicrous
solution which would require a custom inspector, and included both an
int to cast to the necessary enum and a separate index value that we'd
use to look up the enum type to cast to and the parameter in
GameStateManager we needed to compare that to.
Basically, it would've been a giant clusterfuck that'd break horribly if you looked at it wrong.
But then I realized that, no, wait, why was I trying to do this?
So I just defined a generic FlagManager type and decided that things
would take a reference to that, and I could then extend FlagManager to
implement the abstract methods that'd actually do the heavy lifting. You
don't need to do some overcomplicated quasi-dynamic type system to
figure out which enum this flag should be cast to and what to compare it
to - just stick the appropriate FlagManager on the thing, pick the flag
from the dropdown, point the thing that needs to look at the flag to
I spent more time designing and scrapping the ludicrously
overcomplicated, look-how-clever-I-am solution to the problem of "event
flags" than I did actually implementing the thing that's in place and
works. And it's not even ugly or anything? There's a little bit of code
repetition that's completely fucking worth it because it lets me
Just Say No to dynamic typing, but it's eminently readable in the way
that the "smarter" solution I came up with in the first place definitely
would not have been.
I do hope the compiler basically inlines the FlagManager object out of
existence, though, lol. Since an enum isn't a "real" type - it's just a
friendly face for the integral type behind it - it'd be really
embarrassing if the result of this design was that I wound up repeating
the same tiny section of machine code 20 times and having
different things using different repetitions of that code to do their
checks for no apparent reason.
Event flags being a thing means keys can be a thing, so keys are now a thing.
Also: man, I really need to build a fight that's not complete shit
sometime soon. Well past the point where that room with the ghosts is
Weapon pickups. Progression!
At the end of this gif, you can also clearly see the new energy regain animation - which is a "fake bullet" that enemies "fire" on death that tracks the player with ludicrous homing properties and heals you on contact whether you're dodging or not. This is a lot more intuitive and nicer-feeling, (Even if you can't really see the graphic against the floor that easily right now...)
Which brings us to the next point: homing bullets. They're in and I've got a neat little setup that gives them a lot of granularity - anything from ludicrous Macross missiles that do hairpin turns in the air to chase their prey to a more subtle aim-assist. I just don't have any visual way to show that off apart from the health whatsit homing right now, sorry!