AIConfig.cs 870 B

1234567891011121314151617181920212223242526272829303132333435
  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. [BsonIgnore]
  12. public Dictionary<int, SortedDictionary<int, AIConfig>> AIConfigs = new Dictionary<int, SortedDictionary<int, AIConfig>>();
  13. public SortedDictionary<int, AIConfig> GetAI(int aiConfigId)
  14. {
  15. return this.AIConfigs[aiConfigId];
  16. }
  17. public override void AfterEndInit()
  18. {
  19. foreach (var kv in this.GetAll())
  20. {
  21. SortedDictionary<int, AIConfig> aiNodeConfig;
  22. if (!this.AIConfigs.TryGetValue(kv.Value.AIConfigId, out aiNodeConfig))
  23. {
  24. aiNodeConfig = new SortedDictionary<int, AIConfig>();
  25. this.AIConfigs.Add(kv.Value.AIConfigId, aiNodeConfig);
  26. }
  27. aiNodeConfig.Add(kv.Key, kv.Value);
  28. }
  29. }
  30. }
  31. }