using System; using System.Collections.Generic; using MongoDB.Bson.Serialization.Attributes; using ProtoBuf; namespace ET { [ProtoContract] [Config] public partial class AllItemConfigCategory : ProtoObject, IMerge { public static AllItemConfigCategory Instance; [ProtoIgnore] [BsonIgnore] private Dictionary dict = new Dictionary(); [BsonElement] [ProtoMember(1)] private List list = new List(); public AllItemConfigCategory() { Instance = this; } public void Merge(object o) { AllItemConfigCategory s = o as AllItemConfigCategory; this.list.AddRange(s.list); } public override void EndInit() { foreach (AllItemConfig config in list) { config.EndInit(); this.dict.Add(config.Id, config); } this.AfterEndInit(); } public AllItemConfig Get(int id) { this.dict.TryGetValue(id, out AllItemConfig item); if (item == null) { throw new Exception($"配置找不到,配置表名: {nameof (AllItemConfig)},配置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 AllItemConfig GetOne() { if (this.dict == null || this.dict.Count <= 0) { return null; } return this.dict.Values.GetEnumerator().Current; } } [ProtoContract] public partial class AllItemConfig: ProtoObject, IConfig { /// 编号 [ProtoMember(1)] public int Id { get; set; } /// 名称 [ProtoMember(2)] public string Name { get; set; } /// 关联子表 [ProtoMember(3)] public int RelatedTable { get; set; } /// 子表编号 [ProtoMember(4)] public int RelatedId { get; set; } /// 仓库类别 [ProtoMember(5)] public int StockType { get; set; } /// 仓库子类别 [ProtoMember(6)] public int StockSecondaryType { get; set; } /// 转移性 [ProtoMember(7)] public int Transfer { get; set; } /// 可出售 [ProtoMember(8)] public int Sell { get; set; } /// 出售货币 [ProtoMember(9)] public int SellMoney { get; set; } /// 出售价格 [ProtoMember(10)] public int SellPrice { get; set; } /// 购买货币 [ProtoMember(11)] public int BuyMoney { get; set; } /// 购买价格 [ProtoMember(12)] public int BuyPrice { get; set; } /// 购买上限 [ProtoMember(13)] public int PurchaseMax { get; set; } /// 叠加上限 [ProtoMember(14)] public long SuperpositionMax { get; set; } /// 可丢弃 [ProtoMember(15)] public int AbleThrow { get; set; } /// 品级 [ProtoMember(16)] public int Grade { get; set; } /// 图标 [ProtoMember(17)] public string Icon { get; set; } /// 物品描述 [ProtoMember(18)] public string Description { get; set; } /// 来源描述 [ProtoMember(19)] public string GetMethod { get; set; } } }