I've found a lot of similar topics on this but not one that answers my question directly. I'm making a game which involves placing different types of rooms. I have a Room class, then several rooms which inherit from this, e.g. Bedroom, Canteen, etc.
Each room has certain static parameters to set its attributes. For example:
public class Room : WorldEntity
{
public static string Name = "Room";
public static uint MinHeight = 0;
public static uint MinWidth = 0;
//...
}
public class Bedroom : Room
{
new public static string Name = "Bedroom";
new public static uint MinHeight = 4;
new public static uint MinWidth = 4;
//...
}
When creating the room, I first pass through the type of the required room, e.g.
public static void PlaceRoom(Type T){//begin room creation process}
What I want to know is, how can I get the attributes of T from within my PlaceRoom function? For example, how can I get T.MinHeight (which will return 4 when T is type Bedroom)? Or is there a better way to go about this?
I wasn't intending to initialise my class T (where T : Room) until later, so that's why the members were static and I'm trying to use generics.