// TODO: // It occurs to me that more tidying could be done. // This class could be changed to have // static (highest_id, objs_by_ID, IDs_by_tag) // and // (some collection such as Dictionary<int,int> storing ID => ID, for each specific type) // // With suitable changes to object_for_ID(), register_object_as() and so forth, // this scheme might be tidier. In particular, it would simplify the case analysis in register_object_as(). // // On the other hand, the current form works (and has gotten rid of objs_by_ID as needless). static ObjectRegistrar() { // Static class constructor: highest_ID = 0; All = new ObjectRegistrar(typeof(object), "ALL"); // No need for prefix on this one Archetypes = new ObjectRegistrar(typeof(Archetype), "Archetype"); Objs = new ObjectRegistrar(typeof(Obj), "Obj"); TileSheets = new ObjectRegistrar(typeof(TileSheet), "TileSheet"); Sprites = new ObjectRegistrar(typeof(ITileSprite), "Sprite"); // ...more such would be added, per each type we want to handily retrieve a list of instances of... }
static ObjectRegistrar() { // Static class constructor: HaxObjs = new ObjectRegistrar(typeof(Object), "Obj"); Sprites = new ObjectRegistrar(typeof(ITileSprite), "Spr"); }