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.
115 lines
3.0 KiB
115 lines
3.0 KiB
using System; |
|
using System.Collections.Generic; |
|
using MongoDB.Bson.Serialization.Attributes; |
|
using ProtoBuf; |
|
|
|
namespace ET |
|
{ |
|
[ProtoContract] |
|
[Config] |
|
public partial class InitialResourceConfigCategory : ProtoObject, IMerge |
|
{ |
|
public static InitialResourceConfigCategory Instance; |
|
|
|
[ProtoIgnore] |
|
[BsonIgnore] |
|
private Dictionary<int, InitialResourceConfig> dict = new Dictionary<int, InitialResourceConfig>(); |
|
|
|
[BsonElement] |
|
[ProtoMember(1)] |
|
private List<InitialResourceConfig> list = new List<InitialResourceConfig>(); |
|
|
|
public InitialResourceConfigCategory() |
|
{ |
|
Instance = this; |
|
} |
|
|
|
public void Merge(object o) |
|
{ |
|
InitialResourceConfigCategory s = o as InitialResourceConfigCategory; |
|
this.list.AddRange(s.list); |
|
} |
|
|
|
public override void EndInit() |
|
{ |
|
foreach (InitialResourceConfig config in list) |
|
{ |
|
config.EndInit(); |
|
this.dict.Add(config.Id, config); |
|
} |
|
this.AfterEndInit(); |
|
} |
|
|
|
public InitialResourceConfig Get(int id) |
|
{ |
|
this.dict.TryGetValue(id, out InitialResourceConfig item); |
|
|
|
if (item == null) |
|
{ |
|
throw new Exception($"配置找不到,配置表名: {nameof (InitialResourceConfig)},配置id: {id}"); |
|
} |
|
|
|
return item; |
|
} |
|
|
|
public bool Contain(int id) |
|
{ |
|
return this.dict.ContainsKey(id); |
|
} |
|
|
|
public Dictionary<int, InitialResourceConfig> GetAll() |
|
{ |
|
return this.dict; |
|
} |
|
|
|
public List<InitialResourceConfig> GetList() |
|
{ |
|
return this.list; |
|
} |
|
|
|
public InitialResourceConfig GetOne() |
|
{ |
|
if (this.dict == null || this.dict.Count <= 0) |
|
{ |
|
return null; |
|
} |
|
return this.dict.Values.GetEnumerator().Current; |
|
} |
|
} |
|
|
|
[ProtoContract] |
|
public partial class InitialResourceConfig: ProtoObject, IConfig |
|
{ |
|
/// <summary>编号</summary> |
|
[ProtoMember(1)] |
|
public int Id { get; set; } |
|
/// <summary>食物</summary> |
|
[ProtoMember(2)] |
|
public int Food { get; set; } |
|
/// <summary>水</summary> |
|
[ProtoMember(3)] |
|
public int Water { get; set; } |
|
/// <summary>木材</summary> |
|
[ProtoMember(4)] |
|
public int Wood { get; set; } |
|
/// <summary>石头</summary> |
|
[ProtoMember(5)] |
|
public int Stone { get; set; } |
|
/// <summary>银两</summary> |
|
[ProtoMember(6)] |
|
public int SilverTael { get; set; } |
|
/// <summary>金元宝</summary> |
|
[ProtoMember(7)] |
|
public int GoldIngot { get; set; } |
|
/// <summary>初始村民</summary> |
|
[ProtoMember(8)] |
|
public int[] Villagers { get; set; } |
|
/// <summary>起始季节</summary> |
|
[ProtoMember(9)] |
|
public int StartSeason { get; set; } |
|
/// <summary>起始时刻</summary> |
|
[ProtoMember(10)] |
|
public int StartTime { get; set; } |
|
|
|
} |
|
}
|
|
|