AIConfig.cs 814 B

1234567891011121314151617181920212223242526272829303132333435363738
  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, List<AIConfig>> AIConfigs = new ();
  11. public List<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. List<AIConfig> aiNodeConfig;
  20. if (!this.AIConfigs.TryGetValue(kv.Value.AIConfigId, out aiNodeConfig))
  21. {
  22. aiNodeConfig = new List<AIConfig>();
  23. this.AIConfigs.Add(kv.Value.AIConfigId, aiNodeConfig);
  24. }
  25. aiNodeConfig.Add(kv.Value);
  26. }
  27. foreach (var kv in this.AIConfigs)
  28. {
  29. kv.Value.Sort((x, y)=>x.AIConfigId - y.AIConfigId);
  30. }
  31. }
  32. }
  33. }