using System; using System.Collections.Generic; using MongoDB.Bson.Serialization.Attributes; using ProtoBuf; namespace ET { [ProtoContract] [Config] public partial class FormationConfigCategory : ProtoObject, IMerge { public static FormationConfigCategory Instance; [ProtoIgnore] [BsonIgnore] private Dictionary dict = new Dictionary(); [BsonElement] [ProtoMember(1)] private List list = new List(); public FormationConfigCategory() { Instance = this; } public void Merge(object o) { FormationConfigCategory s = o as FormationConfigCategory; this.list.AddRange(s.list); } public override void EndInit() { foreach (FormationConfig config in list) { config.EndInit(); this.dict.Add(config.Id, config); } this.AfterEndInit(); } public FormationConfig Get(int id) { this.dict.TryGetValue(id, out FormationConfig item); if (item == null) { throw new Exception($"配置找不到,配置表名: {nameof (FormationConfig)},配置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 FormationConfig GetOne() { if (this.dict == null || this.dict.Count <= 0) { return null; } return this.dict.Values.GetEnumerator().Current; } } [ProtoContract] public partial class FormationConfig: ProtoObject, IConfig { /// 编号 [ProtoMember(1)] public int Id { get; set; } /// 类型 [ProtoMember(2)] public int Type { get; set; } /// 名称 [ProtoMember(3)] public string Name { get; set; } /// 位置一 [ProtoMember(4)] public int Position1 { get; set; } /// 位置一名称 [ProtoMember(5)] public string Position1Name { get; set; } /// 位置一效果 [ProtoMember(6)] public int[] Position1Effect { get; set; } /// 位置二 [ProtoMember(7)] public int Position2 { get; set; } /// 位置二名称 [ProtoMember(8)] public string Position2Name { get; set; } /// 位置二效果 [ProtoMember(9)] public int[] Position2Effect { get; set; } /// 位置三 [ProtoMember(10)] public int Position3 { get; set; } /// 位置三名称 [ProtoMember(11)] public string Position3Name { get; set; } /// 位置三效果 [ProtoMember(12)] public int[] Position4Effect { get; set; } /// 位置四 [ProtoMember(13)] public int Position4 { get; set; } /// 位置四名称 [ProtoMember(14)] public string Position4Name { get; set; } /// 位置五 [ProtoMember(15)] public int Position5 { get; set; } /// 位置五名称 [ProtoMember(16)] public string Position5Name { get; set; } /// 位置五效果 [ProtoMember(17)] public int[] Position5Effect { get; set; } /// 图标 [ProtoMember(18)] public string Icon { get; set; } /// 描述 [ProtoMember(19)] public string Description { get; set; } } }