AIConfig.cs 857 B

12345678910111213141516171819202122232425262728293031323334
  1. using System.Collections.Generic;
  2. using System.ComponentModel;
  3. using MongoDB.Bson;
  4. using MongoDB.Bson.Serialization.Attributes;
  5. using ProtoBuf;
  6. namespace ET
  7. {
  8. public partial class AIConfigCategory
  9. {
  10. [ProtoIgnore]
  11. public Dictionary<int, SortedDictionary<int, AIConfig>> AIConfigs = new Dictionary<int, SortedDictionary<int, AIConfig>>();
  12. public SortedDictionary<int, AIConfig> GetAI(int aiConfigId)
  13. {
  14. return this.AIConfigs[aiConfigId];
  15. }
  16. public override void AfterEndInit()
  17. {
  18. foreach (var kv in this.GetAll())
  19. {
  20. SortedDictionary<int, AIConfig> aiNodeConfig;
  21. if (!this.AIConfigs.TryGetValue(kv.Value.AIConfigId, out aiNodeConfig))
  22. {
  23. aiNodeConfig = new SortedDictionary<int, AIConfig>();
  24. this.AIConfigs.Add(kv.Value.AIConfigId, aiNodeConfig);
  25. }
  26. aiNodeConfig.Add(kv.Key, kv.Value);
  27. }
  28. }
  29. }
  30. }