using System; using System.Collections.Generic; using MongoDB.Bson.Serialization.Attributes; using ProtoBuf; namespace ET { [ProtoContract] [Config] public partial class StateConfigCategory : ProtoObject, IMerge { public static StateConfigCategory Instance; [ProtoIgnore] [BsonIgnore] private Dictionary dict = new Dictionary(); [BsonElement] [ProtoMember(1)] private List list = new List(); public StateConfigCategory() { Instance = this; } public void Merge(object o) { StateConfigCategory s = o as StateConfigCategory; this.list.AddRange(s.list); } public override void EndInit() { foreach (StateConfig config in list) { config.EndInit(); this.dict.Add(config.Id, config); } this.AfterEndInit(); } public StateConfig Get(int id) { this.dict.TryGetValue(id, out StateConfig item); if (item == null) { throw new Exception($"配置找不到,配置表名: {nameof (StateConfig)},配置id: {id}"); } return item; } public bool Contain(int id) { return this.dict.ContainsKey(id); } public Dictionary GetAll() { return this.dict; } public List GetList() { return this.list; } public StateConfig GetOne() { if (this.dict == null || this.dict.Count <= 0) { return null; } return this.dict.Values.GetEnumerator().Current; } } [ProtoContract] public partial class StateConfig: ProtoObject, IConfig { /// 编号 [ProtoMember(1)] public int Id { get; set; } /// 类型 [ProtoMember(2)] public int Type { get; set; } /// 状态名称 [ProtoMember(3)] public string Name { get; set; } /// BUFF所属对象 [ProtoMember(4)] public int[] Subject { get; set; } /// BUFF影响对象 [ProtoMember(5)] public int[] Object { get; set; } /// 作用对象参数 [ProtoMember(6)] public int[] ObjectParameter { get; set; } /// 等级 [ProtoMember(7)] public int Lv { get; set; } /// 组类型 [ProtoMember(8)] public int Cover { get; set; } /// 合成物品类型 [ProtoMember(9)] public int SyntheticType { get; set; } /// 效果类型 [ProtoMember(10)] public int[] Effection { get; set; } /// 效果数值 [ProtoMember(11)] public int[] EffectionValue { get; set; } /// 能否劳作 [ProtoMember(12)] public int Toil { get; set; } /// 能否叠加 [ProtoMember(13)] public int Superimposed { get; set; } /// 持续时间 [ProtoMember(14)] public int Duration { get; set; } /// 状态图标 [ProtoMember(15)] public string Icon { get; set; } /// 是否显示 [ProtoMember(16)] public int Display { get; set; } /// 状态描述 [ProtoMember(17)] public string Describe { get; set; } /// 效果读取状态描述 [ProtoMember(18)] public string Description2 { get; set; } } }