105 lines
2.7 KiB
C#
105 lines
2.7 KiB
C#
//using System;
|
|
//using System.Collections.Generic;
|
|
|
|
//namespace ET
|
|
//{
|
|
|
|
|
|
// public class DataTableComponentAwakeSystem : AwakeSystem<DataTableComponent>
|
|
// {
|
|
// public override void Awake(DataTableComponent self)
|
|
// {
|
|
// self.Awake();
|
|
|
|
// }
|
|
// }
|
|
|
|
|
|
// public class DataTableComponent : Entity
|
|
// {
|
|
// private readonly Dictionary<Type, ACategory> allConfig = new Dictionary<Type, ACategory>();
|
|
|
|
// public static DataTableComponent instance { get; set; }
|
|
|
|
// public void Awake()
|
|
// {
|
|
// instance = this;
|
|
// Load();
|
|
// }
|
|
// public void Load()
|
|
// {
|
|
// this.allConfig.Clear();
|
|
// List<Type> types = Game.EventSystem.GetTypes();
|
|
|
|
// foreach (Type type in types)
|
|
// {
|
|
// object[] attrs = type.GetCustomAttributes(typeof(ConfigAttribute), false);
|
|
// if (attrs.Length == 0)
|
|
// {
|
|
// continue;
|
|
// }
|
|
|
|
// ConfigAttribute configAttribute = attrs[0] as ConfigAttribute;
|
|
|
|
// object obj = Activator.CreateInstance(type);
|
|
|
|
// ACategory iCategory = obj as ACategory;
|
|
// if (iCategory == null)
|
|
// {
|
|
// throw new Exception($"class: {type.Name} not inherit from ACategory");
|
|
// }
|
|
|
|
// iCategory.BeginInit();
|
|
// iCategory.EndInit();
|
|
|
|
// this.allConfig[iCategory.ConfigType] = iCategory;
|
|
// }
|
|
// }
|
|
|
|
// public IConfig GetOne(Type type)
|
|
// {
|
|
// ACategory configCategory;
|
|
// if (!this.allConfig.TryGetValue(type, out configCategory))
|
|
// {
|
|
// throw new Exception($"ConfigComponent not found key: {type.FullName}");
|
|
// }
|
|
// return configCategory.GetOne();
|
|
// }
|
|
|
|
// public IConfig Get(Type type, long id)
|
|
// {
|
|
// ACategory configCategory;
|
|
// if (!this.allConfig.TryGetValue(type, out configCategory))
|
|
// {
|
|
// throw new Exception($"ConfigComponent not found key: {type.FullName}");
|
|
// }
|
|
|
|
// return configCategory.TryGet(id);
|
|
// }
|
|
|
|
|
|
// public IEnumerable<T> GetAll<T>(Type type)
|
|
// {
|
|
// ACategory configCategory;
|
|
// if (!this.allConfig.TryGetValue(type, out configCategory))
|
|
// {
|
|
// throw new Exception($"ConfigComponent not found key: {type.FullName}");
|
|
// }
|
|
// return configCategory.GetAll<T>();
|
|
// }
|
|
|
|
// public ACategory GetCategory(Type type)
|
|
// {
|
|
// ACategory configCategory;
|
|
// bool ret = this.allConfig.TryGetValue(type, out configCategory);
|
|
// return ret ? configCategory : null;
|
|
// }
|
|
|
|
// internal void Destroy()
|
|
// {
|
|
// allConfig.Clear();
|
|
// instance = null;
|
|
// }
|
|
// }
|
|
|
|
//} |