using MongoDB.Bson.Serialization.Attributes; namespace Base { /// /// Component的Id与Owner Entity Id一样 /// public abstract class Component : Object { [BsonIgnore] public Entity Owner { protected get; set; } protected T GetOwner() where T: Entity { return this.Owner as T; } protected Component() { } protected Component(long id): base(id) { } protected T GetComponent() where T: Component { return this.Owner.GetComponent(); } public override void Dispose() { if (this.Id == 0) { return; } base.Dispose(); } } }