I'm posting some functions I'm using in The Drifter that aren't in core PowerQuest now. Let me know if you find them useful and think they should be in core PowerQuest.
In The Drifter I have tonnes of enums for keeping track of the state of the game. Like, how much the player has progressed on certain puzzles, the state of doors, etc etc...
I got kinda tired of writing code like this
if ( Globals.m_kitchenWindow == eKitchenWindow.Open ) Globals.m_kitchenWindow = eKitchenWindow.Closed;
and similar, and so messed around with a simpler way to do it using fancy reflection stuff. The result is this
if ( E.Is(eKitchenWindow.Open) ) E.Set(eKitchenWindow.Closed);
So much more readable. There's a bunch of similar functions. Eg:
E.Before(eDog.Fed); // Check Dog hasn't been fed yet (anything prior to Fed) E.Reached(eYeti.UsedPie); // Check the pie's been used (any state after, or including) E.After(eShopkeeper.Intro); // Check you've seen the 'intro' (any state after 'intro') E.At(eLevel.Final); // Check you're at the final level (same as Is/In); E.In(eAct.Three); // Check you're In act 3 (same as Is/At);
This is kinda experimental and weird... and in-case you can't tell, I just stuck in all functions I could think of to see which I end up using... which is why it's just an extension for now.
Setup
- Add this package to your project: PowerQuestExEnums.unitypackage
Usage
- Add enums as usual to your GlobalScript or Room script file, and create a public variable for the enum too.
public enum eDog { Sleeping, Awake, Angry, Fed } public eDog m_dogState = eDog.Sleeping;
- From then on, use the functions mentioned above. Eg:
if ( E.After(eDog.Sleeping) && E.Before(eDog.Fed) ) E.Set(eDog.Angry);