PlayerData.cs 940 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using MongoDB.Bson;
  2. using MongoDB.Bson.Serialization.Attributes;
  3. using MongoDB.Driver;
  4. namespace NetServer.MongoDB.DBData;
  5. public class PlayerData
  6. {
  7. [BsonId] public ObjectId id { get; set; }
  8. public long playerId { get; set; }
  9. public string name { get; set; }
  10. public int age { get; set; }
  11. public PlayerHero PlayerHero { get; set; }
  12. [BsonIgnore] public UpdateDefinition<PlayerData> Update;
  13. public UpdateDefinition<PlayerData> CapyUpdate()
  14. {
  15. lock (Update)
  16. {
  17. UpdateDefinition<PlayerData> updateValue = Update;
  18. Update = null;
  19. return updateValue;
  20. }
  21. }
  22. public void AddUpdateDefinition(UpdateDefinition<PlayerData> updateDefinition)
  23. {
  24. if (Update != null)
  25. {
  26. Builders<PlayerData>.Update.Combine(Update, updateDefinition);
  27. }
  28. else
  29. {
  30. Update = updateDefinition;
  31. }
  32. }
  33. }