public override void Init(IEntity entity) { base.Init(entity); entity.Bind <IImageComponent>(c => { _image = c; AGSScale.BindSizeToImage(c, _scale); _scale.PropertyChanged += onScalePropertyChanged; }, c => { _image = null; c.PropertyChanged -= onScalePropertyChanged; }); }
public override void Init() { base.Init(); Entity.Bind <IImageComponent>(c => { _image = c; _unsubscribeBindSizeToImage = AGSScale.BindSizeToImage(c, _scale); _scale.PropertyChanged += _onScalePropertyChangedCallback; }, c => { _image = null; _unsubscribeBindSizeToImage?.Invoke(); _unsubscribeBindSizeToImage = null; c.PropertyChanged -= _onScalePropertyChangedCallback; }); }
public AGSSprite(Resolver resolver, IMaskLoader maskLoader) { _id = Interlocked.Increment(ref _lastId); _pixelPerfectArea = new Lazy <IArea>(generatePixelPerfectArea); _maskLoader = maskLoader; _resolver = resolver; //todo: abstract it to the constructor _translate = new AGSTranslate(); _hasImage = new AGSHasImage(); _hasImage.Pivot = new PointF(); _scale = new AGSScale(); AGSScale.BindSizeToImage(_hasImage, _scale); _rotate = new AGSRotate(); _scale.PropertyChanged += onPropertyChanged; _hasImage.PropertyChanged += onPropertyChanged; _translate.PropertyChanged += onPropertyChanged; }