AIConfig.cs 833 B

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