public GameComps() { FieldInfo[] fields = typeof(GameComps).GetFields(); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { object obj = Activator.CreateInstance(fieldInfo.FieldType); fieldInfo.SetValue(null, obj); Add(obj as IComponentManager); if (obj is IKComponentManager) { IKComponentManager inst = obj as IKComponentManager; AddKComponentManager(fieldInfo.FieldType, inst); } } }
public static void AddKComponentManager(Type kcomponent, IKComponentManager inst) { kcomponentManagers[kcomponent] = inst; }