I'm working with a class whose instances are used to manages various booleans.
public bool walkable = true;
public bool current = false;
public bool target = false;
public bool selectable = false;
public bool visited = false;
public Tile parent = null;
public int distance = 0;
There's also this Reset utility function, that will just set all of the booleans back to 0
public void Reset ()
{
walkable = false;
...
}
Rather than writing out every attribute, I was hoping I could just have the function switch off any booleans that might belong to a given instance that this gets called on.
Poking around the internet I keep finding stuff on reflection, but as far as I have read this only works when one has a reference to the actual instance (not within the class definition), from the C# docs:
// Using GetType to obtain type information:
int i = 42;
System.Type type = i.GetType();
System.Console.WriteLine(type);
Is switching off the booleans from within the instance based on property possible? Is it a dumb thing to want to do? Perhaps I would be better off keeping track of the booleans in a Dictionary?