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.
142 lines
3.8 KiB
142 lines
3.8 KiB
using System; |
|
using System.Collections.Generic; |
|
using MongoDB.Bson.Serialization.Attributes; |
|
using ProtoBuf; |
|
|
|
namespace ET |
|
{ |
|
[ProtoContract] |
|
[Config] |
|
public partial class FormationConfigCategory : ProtoObject, IMerge |
|
{ |
|
public static FormationConfigCategory Instance; |
|
|
|
[ProtoIgnore] |
|
[BsonIgnore] |
|
private Dictionary<int, FormationConfig> dict = new Dictionary<int, FormationConfig>(); |
|
|
|
[BsonElement] |
|
[ProtoMember(1)] |
|
private List<FormationConfig> list = new List<FormationConfig>(); |
|
|
|
public FormationConfigCategory() |
|
{ |
|
Instance = this; |
|
} |
|
|
|
public void Merge(object o) |
|
{ |
|
FormationConfigCategory s = o as FormationConfigCategory; |
|
this.list.AddRange(s.list); |
|
} |
|
|
|
public override void EndInit() |
|
{ |
|
foreach (FormationConfig config in list) |
|
{ |
|
config.EndInit(); |
|
this.dict.Add(config.Id, config); |
|
} |
|
this.AfterEndInit(); |
|
} |
|
|
|
public FormationConfig Get(int id) |
|
{ |
|
this.dict.TryGetValue(id, out FormationConfig item); |
|
|
|
if (item == null) |
|
{ |
|
throw new Exception($"配置找不到,配置表名: {nameof (FormationConfig)},配置id: {id}"); |
|
} |
|
|
|
return item; |
|
} |
|
|
|
public bool Contain(int id) |
|
{ |
|
return this.dict.ContainsKey(id); |
|
} |
|
|
|
public Dictionary<int, FormationConfig> GetAll() |
|
{ |
|
return this.dict; |
|
} |
|
|
|
public List<FormationConfig> GetList() |
|
{ |
|
return this.list; |
|
} |
|
|
|
public FormationConfig GetOne() |
|
{ |
|
if (this.dict == null || this.dict.Count <= 0) |
|
{ |
|
return null; |
|
} |
|
return this.dict.Values.GetEnumerator().Current; |
|
} |
|
} |
|
|
|
[ProtoContract] |
|
public partial class FormationConfig: ProtoObject, IConfig |
|
{ |
|
/// <summary>编号</summary> |
|
[ProtoMember(1)] |
|
public int Id { get; set; } |
|
/// <summary>类型</summary> |
|
[ProtoMember(2)] |
|
public int Type { get; set; } |
|
/// <summary>名称</summary> |
|
[ProtoMember(3)] |
|
public string Name { get; set; } |
|
/// <summary>位置一</summary> |
|
[ProtoMember(4)] |
|
public int Position1 { get; set; } |
|
/// <summary>位置一名称</summary> |
|
[ProtoMember(5)] |
|
public string Position1Name { get; set; } |
|
/// <summary>位置一效果</summary> |
|
[ProtoMember(6)] |
|
public int[] Position1Effect { get; set; } |
|
/// <summary>位置二</summary> |
|
[ProtoMember(7)] |
|
public int Position2 { get; set; } |
|
/// <summary>位置二名称</summary> |
|
[ProtoMember(8)] |
|
public string Position2Name { get; set; } |
|
/// <summary>位置二效果</summary> |
|
[ProtoMember(9)] |
|
public int[] Position2Effect { get; set; } |
|
/// <summary>位置三</summary> |
|
[ProtoMember(10)] |
|
public int Position3 { get; set; } |
|
/// <summary>位置三名称</summary> |
|
[ProtoMember(11)] |
|
public string Position3Name { get; set; } |
|
/// <summary>位置三效果</summary> |
|
[ProtoMember(12)] |
|
public int[] Position4Effect { get; set; } |
|
/// <summary>位置四</summary> |
|
[ProtoMember(13)] |
|
public int Position4 { get; set; } |
|
/// <summary>位置四名称</summary> |
|
[ProtoMember(14)] |
|
public string Position4Name { get; set; } |
|
/// <summary>位置五</summary> |
|
[ProtoMember(15)] |
|
public int Position5 { get; set; } |
|
/// <summary>位置五名称</summary> |
|
[ProtoMember(16)] |
|
public string Position5Name { get; set; } |
|
/// <summary>位置五效果</summary> |
|
[ProtoMember(17)] |
|
public int[] Position5Effect { get; set; } |
|
/// <summary>图标</summary> |
|
[ProtoMember(18)] |
|
public string Icon { get; set; } |
|
/// <summary>描述</summary> |
|
[ProtoMember(19)] |
|
public string Description { get; set; } |
|
|
|
} |
|
}
|
|
|