ComponentWithId.cs 539 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using MongoDB.Bson.Serialization.Attributes;
  2. #if !SERVER
  3. using UnityEngine;
  4. #endif
  5. namespace ETModel
  6. {
  7. [BsonIgnoreExtraElements]
  8. public abstract class ComponentWithId : Component
  9. {
  10. [BsonIgnoreIfDefault]
  11. [BsonDefaultValue(0L)]
  12. [BsonElement]
  13. [BsonId]
  14. public long Id { get; set; }
  15. protected ComponentWithId()
  16. {
  17. this.Id = this.InstanceId;
  18. }
  19. protected ComponentWithId(long id)
  20. {
  21. this.Id = id;
  22. }
  23. public override void Dispose()
  24. {
  25. if (this.IsDisposed)
  26. {
  27. return;
  28. }
  29. base.Dispose();
  30. }
  31. }
  32. }