using MongoDB.Bson.Serialization.Attributes; namespace Hotfix { public abstract class Component : Disposer { [BsonIgnore] public Entity Entity { get; set; } public T GetEntity() where T : Entity { return this.Entity as T; } protected Component() { this.Id = 1; } public T GetComponent() where T : Component { return this.Entity.GetComponent(); } public override void Dispose() { if (this.Id == 0) { return; } base.Dispose(); this.Entity?.RemoveComponent(this.GetType()); } } }