You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
145 lines
4.0 KiB
145 lines
4.0 KiB
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<int, ResourcesConfig> dict = new Dictionary<int, ResourcesConfig>(); |
|
|
|
[BsonElement] |
|
[ProtoMember(1)] |
|
private List<ResourcesConfig> list = new List<ResourcesConfig>(); |
|
|
|
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<int, ResourcesConfig> GetAll() |
|
{ |
|
return this.dict; |
|
} |
|
|
|
public List<ResourcesConfig> 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 |
|
{ |
|
/// <summary>编号</summary> |
|
[ProtoMember(1)] |
|
public int Id { get; set; } |
|
/// <summary>行为类型</summary> |
|
[ProtoMember(2)] |
|
public int BehaviourType { get; set; } |
|
/// <summary>行为名称</summary> |
|
[ProtoMember(3)] |
|
public string BehaviourName { get; set; } |
|
/// <summary>互斥行为</summary> |
|
[ProtoMember(4)] |
|
public int[] MutexBehaviour { get; set; } |
|
/// <summary>科技要求</summary> |
|
[ProtoMember(5)] |
|
public int TechnologyLimited { get; set; } |
|
/// <summary>执行条件</summary> |
|
[ProtoMember(6)] |
|
public int AccessableCondition { get; set; } |
|
/// <summary>执行条件参数</summary> |
|
[ProtoMember(7)] |
|
public int AccessableParameter { get; set; } |
|
/// <summary>执行人数</summary> |
|
[ProtoMember(8)] |
|
public int WorkerNumber { get; set; } |
|
/// <summary>再生条件</summary> |
|
[ProtoMember(9)] |
|
public int[] RebornCondition { get; set; } |
|
/// <summary>再生条件参数</summary> |
|
[ProtoMember(10)] |
|
public int[] RebornConditionParameters { get; set; } |
|
/// <summary>消失条件</summary> |
|
[ProtoMember(11)] |
|
public int DisappearCondition { get; set; } |
|
/// <summary>消失条件参数</summary> |
|
[ProtoMember(12)] |
|
public int[] DisappearConditionParameter { get; set; } |
|
/// <summary>进入资源</summary> |
|
[ProtoMember(13)] |
|
public int InResource { get; set; } |
|
/// <summary>资源总量</summary> |
|
[ProtoMember(14)] |
|
public int OutAmount { get; set; } |
|
/// <summary>基础效率</summary> |
|
[ProtoMember(15)] |
|
public int BaseEfficient { get; set; } |
|
/// <summary>产出间隔</summary> |
|
[ProtoMember(16)] |
|
public int OutInterval { get; set; } |
|
/// <summary>基础产出</summary> |
|
[ProtoMember(17)] |
|
public int BaseOut { get; set; } |
|
/// <summary>额外产出</summary> |
|
[ProtoMember(18)] |
|
public int[] ExtraOut { get; set; } |
|
/// <summary>月圆夜产出</summary> |
|
[ProtoMember(19)] |
|
public int MoonnightOut { get; set; } |
|
/// <summary>铲除性</summary> |
|
[ProtoMember(20)] |
|
public int Eradicate { get; set; } |
|
|
|
} |
|
}
|
|
|