using System; using System.Collections.Generic; using MongoDB.Bson.Serialization.Attributes; using ProtoBuf; namespace ET { [ProtoContract] [Config] public partial class WeatherConfigCategory : ProtoObject, IMerge { public static WeatherConfigCategory Instance; [ProtoIgnore] [BsonIgnore] private Dictionary dict = new Dictionary(); [BsonElement] [ProtoMember(1)] private List list = new List(); public WeatherConfigCategory() { Instance = this; } public void Merge(object o) { WeatherConfigCategory s = o as WeatherConfigCategory; this.list.AddRange(s.list); } public override void EndInit() { foreach (WeatherConfig config in list) { config.EndInit(); this.dict.Add(config.Id, config); } this.AfterEndInit(); } public WeatherConfig Get(int id) { this.dict.TryGetValue(id, out WeatherConfig item); if (item == null) { throw new Exception($"配置找不到,配置表名: {nameof (WeatherConfig)},配置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 WeatherConfig GetOne() { if (this.dict == null || this.dict.Count <= 0) { return null; } return this.dict.Values.GetEnumerator().Current; } } [ProtoContract] public partial class WeatherConfig: ProtoObject, IConfig { /// 编号 [ProtoMember(1)] public int Id { get; set; } /// 天气名称 [ProtoMember(2)] public string Name { get; set; } /// 疾病值 [ProtoMember(3)] public int Disease { get; set; } /// 外伤值 [ProtoMember(4)] public int Injury { get; set; } /// 耐久破坏 [ProtoMember(5)] public int DurableDestroy { get; set; } /// 劳力变化 [ProtoMember(6)] public int LaborVariety { get; set; } /// 持续时长 [ProtoMember(7)] public int[] Duration { get; set; } /// 天气CD [ProtoMember(8)] public int[] CD { get; set; } /// 天气特效 [ProtoMember(9)] public string WeaterEffect { get; set; } /// 特效间隔 [ProtoMember(10)] public int[] SpecialEfficacyCD { get; set; } /// 天气图标 [ProtoMember(11)] public string ICON { get; set; } /// 描述 [ProtoMember(12)] public string Describe { get; set; } } }