Component.cs 484 B

1234567891011121314151617181920212223242526272829303132333435
  1. using MongoDB.Bson.Serialization.Attributes;
  2. namespace ETHotfix
  3. {
  4. public abstract class Component : Disposer
  5. {
  6. public long Id { get; set; }
  7. [BsonIgnore]
  8. public Component Parent { get; set; }
  9. public T GetParent<T>() where T : Component
  10. {
  11. return this.Parent as T;
  12. }
  13. public Entity Entity
  14. {
  15. get
  16. {
  17. return this.Parent as Entity;
  18. }
  19. }
  20. public override void Dispose()
  21. {
  22. if (this.IsDisposed)
  23. {
  24. return;
  25. }
  26. base.Dispose();
  27. }
  28. }
  29. }