static ActionManager() { EntityTypeManager.Init(); List <ISystemAction>[] groupActions = new List <ISystemAction> [EntityTypeManager.TypeCount]; for (int i = 0; i < groupActions.Length; i++) { groupActions[i] = new List <ISystemAction>(); } //DateTime t0 = DateTime.Now; var types = LEType.GetTypes(t => t.GetInterfaces().Contains(typeof(ILE_Data))); foreach (var type in types) { if (type.IsClass && !type.IsAbstract) { //Console.WriteLine(type.FullName); Add(type, groupActions); } } for (int i = 0; i < groupActions.Length; i++) { //for (int j = 0; j < groupActions[i].Count; j++) //{ // Console.WriteLine(groupActions[i][j].Id); //} EntityTypeManager.GetEntityType(i).SetAction(groupActions[i].ToArray()); } //Console.WriteLine((DateTime.Now - t0).TotalMilliseconds); }
static EntityTypeManager() { Type bt = typeof(EntityType); var types = LEType.GetTypes(t => t.BaseType == bt); TypeCount = types.Length; for (int i = 0; i < TypeCount; i++) { Add(types[i], i); } }
protected TAManager() { Type baseType = typeof(T); TemplateIdManager.RegiserBase <T>(); var types = LEType.GetTypes(t => t.BaseType == baseType); actions = new T[types.Length]; for (int i = 0; i < types.Length; i++) { actions[i] = LEType.CreateInstance <T>(types[i]); TemplateIdManager.Register <T>(types[i]); } }
static TemplateManager() { Type baseType = typeof(T); var types = LEType.GetTypes(t => t.BaseType == baseType); datas = new T[types.Length]; for (int i = 0; i < types.Length; i++) { datas[i] = LEType.CreateInstance <T>(types[i]); int id = IdManager.IdDeliverer <T> .GetNextId(); var _id = types[i].GetField("id", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy); if (_id == null) { //TODO: Exception LE_Log.Log.Exception(new Exception(), "Template register fail", "template type:{0}", types[i].FullName); } _id.SetValue(datas[i], id); Console.WriteLine("{0}:{1}", types[i].Name, datas[i].Id); } }
private static void Add(Type type, int id) { EntityType entityType = LEType.CreateInstance <EntityType>(type); entityTypes.Add(entityType); idchanges.Add(type.FullName, id); var infos = type.GetFields(); Type dataTyep = typeof(DataInfo <>); var eType = (BitArray)typeof(EntityType).GetField("dataInfo", BindingFlags.NonPublic | BindingFlags.Instance) .GetValue(entityType); eType.Set(DataInfo <EntityData> .DataId, true); for (int i = 0; i < infos.Length; i++) { Type t = infos[i].FieldType; if (t.GetInterfaces().Contains(typeof(IData))) { int index = (int)dataTyep.MakeGenericType(t).GetField("dataId", BindingFlags.NonPublic | BindingFlags.Static) .GetValue(null); eType.Set(index, true); } } }