using System; using System.Collections.Generic; using MongoDB.Bson.Serialization.Attributes; using ProtoBuf; namespace ET { [ProtoContract] [Config] public partial class ResourcesConfigCategory : ProtoObject, IMerge { public static ResourcesConfigCategory Instance; [ProtoIgnore] [BsonIgnore] private Dictionary dict = new Dictionary(); [BsonElement] [ProtoMember(1)] private List list = new List(); public ResourcesConfigCategory() { Instance = this; } public void Merge(object o) { ResourcesConfigCategory s = o as ResourcesConfigCategory; this.list.AddRange(s.list); } public override void EndInit() { foreach (ResourcesConfig config in list) { config.EndInit(); this.dict.Add(config.Id, config); } this.AfterEndInit(); } public ResourcesConfig Get(int id) { this.dict.TryGetValue(id, out ResourcesConfig item); if (item == null) { throw new Exception($"配置找不到,配置表名: {nameof (ResourcesConfig)},配置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 ResourcesConfig GetOne() { if (this.dict == null || this.dict.Count <= 0) { return null; } return this.dict.Values.GetEnumerator().Current; } } [ProtoContract] public partial class ResourcesConfig: ProtoObject, IConfig { /// 编号 [ProtoMember(1)] public int Id { get; set; } /// 行为名称 [ProtoMember(2)] public string BehaviourName { get; set; } /// 行为类型 [ProtoMember(3)] public int BehaviourType { get; set; } /// 互斥行为 [ProtoMember(4)] public int[] MutexBehaviour { get; set; } /// 科技要求 [ProtoMember(5)] public int TechnologyLimited { get; set; } /// 执行人数 [ProtoMember(6)] public int WorkerNumber { get; set; } /// 再生条件 [ProtoMember(7)] public int[] RebornCondition { get; set; } /// 再生条件参数 [ProtoMember(8)] public int[] RebornConditionParameters { get; set; } /// 消失条件 [ProtoMember(9)] public int DisappearCondition { get; set; } /// 消失条件参数 [ProtoMember(10)] public int[] DisappearConditionParameter { get; set; } /// 进入资源 [ProtoMember(11)] public int InResource { get; set; } /// 资源总量 [ProtoMember(12)] public int OutAmount { get; set; } /// 基础效率 [ProtoMember(13)] public int BaseEfficient { get; set; } /// 产出间隔 [ProtoMember(14)] public int OutInterval { get; set; } /// 基础产出 [ProtoMember(15)] public int BaseOut { get; set; } /// 额外产出 [ProtoMember(16)] public int ExtraOut { get; set; } /// 额外产出概率 [ProtoMember(17)] public int ExtraOutProbability { get; set; } /// 露水量 [ProtoMember(18)] public int DewEachOut { get; set; } /// 月圆夜产出 [ProtoMember(19)] public int MoonnightOut { get; set; } /// 产出概率 [ProtoMember(20)] public int OutProbability { get; set; } /// 铲除性 [ProtoMember(21)] public int Eradicate { get; set; } } }