Пример #1
0
 private void lockTree(IInObjectTreeComponent tree)
 {
     if (tree == null)
     {
         return;
     }
     foreach (var child in tree.TreeNode.Children)
     {
         if (child == null || !_shouldLock(child))
         {
             continue;
         }
         var matrix = child.GetComponent <IModelMatrixComponent>();
         if (matrix != null)
         {
             lockComponent(matrix.ModelMatrixLockStep, _matrices);
         }
         var box = child.GetComponent <IBoundingBoxComponent>();
         if (box != null)
         {
             lockComponent(box.BoundingBoxLockStep, _boxes);
         }
         var boxWithChildren = child.GetComponent <IBoundingBoxWithChildrenComponent>();
         if (boxWithChildren != null)
         {
             lockComponent(boxWithChildren.LockStep, _boxesWithChildren);
         }
         var textComponent = child.GetComponent <ITextComponent>();
         if (textComponent != null)
         {
             lockComponent(textComponent.TextLockStep, _texts);
         }
         lockTree(child);
     }
 }
Пример #2
0
        public override void AfterInit()
        {
            _entity.Bind <IAnimationComponent>(
                c => { _animationComponent = c; _animationComponent.PropertyChanged += onAnimationChanged; onSomethingChanged(); },
                c => { _animationComponent = null; _animationComponent.PropertyChanged -= onAnimationChanged; onSomethingChanged(); });
            _entity.Bind <IHasRoomComponent>(
                c => { _room = c; refreshAreaScaling(); subscribeRoom(); onSomethingChanged(); },
                c => { unsubscribeRoom(c); _room = null; refreshAreaScaling(); onSomethingChanged(); });

            _entity.Bind <IScaleComponent>(
                c => { _scale = c; c.PropertyChanged += onScaleChanged; onSomethingChanged(); },
                c => { c.PropertyChanged -= onScaleChanged; _scale = null; onSomethingChanged(); });
            _entity.Bind <ITranslateComponent>(
                c => { _translate = c; c.PropertyChanged += onTranslateChanged; onSomethingChanged(); },
                c => { c.PropertyChanged -= onTranslateChanged; _translate = null; onSomethingChanged(); }
                );
            _entity.Bind <IJumpOffsetComponent>(
                c => { _jump = c; c.PropertyChanged += onJumpOffsetChanged; onSomethingChanged(); },
                c => { c.PropertyChanged -= onJumpOffsetChanged; _jump = null; onSomethingChanged(); }
                );
            _entity.Bind <IRotateComponent>(
                c => { _rotate = c; c.PropertyChanged += onRotateChanged; onSomethingChanged(); },
                c => { c.PropertyChanged -= onRotateChanged; _rotate = null; onSomethingChanged(); }
                );
            _entity.Bind <IImageComponent>(
                c => { _image = c; subscribeLabelRenderer(); c.PropertyChanged += onImageChanged; onSomethingChanged(); },
                c => { c.PropertyChanged -= onImageChanged; _image = null; onSomethingChanged(); }
                );

            _entity.Bind <IDrawableInfoComponent>(
                c =>
            {
                _drawable          = c;
                c.PropertyChanged += onDrawableChanged;
                onSomethingChanged();
            }, c =>
            {
                c.PropertyChanged -= onDrawableChanged;
                _drawable          = null;
                onSomethingChanged();
            });

            _entity.Bind <IInObjectTreeComponent>(
                c =>
            {
                _tree   = c;
                _parent = _tree.TreeNode.Parent;
                _tree.TreeNode.OnParentChanged.Subscribe(onParentChanged);
                _parent?.OnMatrixChanged.Subscribe(onSomethingChanged);
                onSomethingChanged();
            }, c =>
            {
                c.TreeNode.OnParentChanged.Unsubscribe(onParentChanged);
                c.TreeNode.Parent?.OnMatrixChanged.Unsubscribe(onSomethingChanged);
                _tree   = null;
                _parent = null;
                onSomethingChanged();
            });
        }
Пример #3
0
        public override void Init(IEntity entity)
        {
            base.Init(entity);
            _entity = entity;
            entity.Bind <ITextComponent>(c =>
            {
                _textComponent     = c;
                c.PropertyChanged += onTextPropertyChanged;
            }, c =>
            {
                _textComponent     = null;
                c.PropertyChanged -= onTextPropertyChanged;
            });
            entity.Bind <IImageComponent>(c => _imageComponent = c, _ => _imageComponent = null);
            entity.Bind <IUIEvents>(c =>
            {
                _uiEvents = c;
                c.MouseDown.Subscribe(onMouseDown);
                c.LostFocus.Subscribe(onMouseDownOutside);
            }, c =>
            {
                _uiEvents = null;
                c.MouseDown.Unsubscribe(onMouseDown);
                c.LostFocus.Unsubscribe(onMouseDownOutside);
            });
            entity.Bind <IInObjectTreeComponent>(c => _tree        = c, _ => _tree = null);
            entity.Bind <IHasRoomComponent>(c => _room             = c, _ => _room = null);
            entity.Bind <IVisibleComponent>(c => _visibleComponent = c, _ => _visibleComponent = null);

            _game.Events.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute);

            _caretFlashCounter = (int)CaretFlashDelay;
            _withCaret         = _game.Factory.UI.GetLabel(entity.ID + " Caret", "|", 1f, 1f, 0f, 0f, config: new AGSTextConfig(autoFit: AutoFit.LabelShouldFitText));
            _withCaret.Pivot   = new PointF(0f, 0f);
            _withCaret.TextBackgroundVisible = false;

            entity.Bind <IAnimationComponent>(c =>
            {
                c.PropertyChanged  += onAnimationPropertyChanged;
                _animationComponent = c;
                updateBorder();
            }, c =>
            {
                c.PropertyChanged  -= onAnimationPropertyChanged;
                _animationComponent = null;
                updateBorder();
            });

            entity.Bind <IDrawableInfoComponent>(c =>
            {
                _drawableComponent = c;
                c.PropertyChanged += onDrawableChanged;
                onRenderLayerChanged();
            }, c =>
            {
                c.PropertyChanged -= onDrawableChanged;
                _drawableComponent = null;
            });
        }
Пример #4
0
 public TreeLockStep(IInObjectTreeComponent tree, Func <IObject, bool> shouldLock)
 {
     _tree              = tree;
     _matrices          = _tree == null ? new List <ILockStep>() : new List <ILockStep>(_tree.TreeNode.ChildrenCount);
     _boxes             = _tree == null ? new List <ILockStep>() : new List <ILockStep>(_tree.TreeNode.ChildrenCount);
     _boxesWithChildren = _tree == null ? new List <ILockStep>() : new List <ILockStep>(_tree.TreeNode.ChildrenCount);
     _texts             = _tree == null ? new List <ILockStep>() : new List <ILockStep>(_tree.TreeNode.ChildrenCount);
     _shouldLock        = shouldLock;
 }
Пример #5
0
 public override void Init()
 {
     base.Init();
     bindGraphics(Graphics);
     Entity.Bind <IDrawableInfoComponent>(c => _drawableInfo = c, _ => _drawableInfo = null);
     Entity.Bind <IInObjectTreeComponent>(c => _tree         = c, _ => _tree = null);
     Entity.Bind <IVisibleComponent>(c => _visible           = c, _ => _visible = null);
     Entity.Bind <IEnabledComponent>(c => _enabled           = c, _ => _enabled = null);
     Entity.Bind <IUIEvents>(c => c.LostFocus.Subscribe(onLostFocus), c => c.LostFocus.Unsubscribe(onLostFocus));
     _gameEvents.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute);
 }
Пример #6
0
 public AGSCharacter(string id, Resolver resolver, IOutfit outfit) : base(id, resolver)
 {
     _hasRoomComponent = AddComponent <IHasRoomComponent>();
     Bind <IHasRoomComponent>(c => _hasRoomComponent = c, _ => {});
     _animationComponent = AddComponent <IAnimationComponent>();
     Bind <IAnimationComponent>(c => _animationComponent = c, _ => {});
     _inObjectTreeComponent = AddComponent <IInObjectTreeComponent>();
     Bind <IInObjectTreeComponent>(c => _inObjectTreeComponent = c, _ => {});
     _colliderComponent = AddComponent <IColliderComponent>();
     Bind <IColliderComponent>(c => _colliderComponent = c, _ => {});
     _visibleComponent = AddComponent <IVisibleComponent>();
     Bind <IVisibleComponent>(c => _visibleComponent = c, _ => {});
     _enabledComponent = AddComponent <IEnabledComponent>();
     Bind <IEnabledComponent>(c => _enabledComponent = c, _ => {});
     _customPropertiesComponent = AddComponent <ICustomPropertiesComponent>();
     Bind <ICustomPropertiesComponent>(c => _customPropertiesComponent = c, _ => {});
     _drawableInfoComponent = AddComponent <IDrawableInfoComponent>();
     Bind <IDrawableInfoComponent>(c => _drawableInfoComponent = c, _ => {});
     _shaderComponent = AddComponent <IShaderComponent>();
     Bind <IShaderComponent>(c => _shaderComponent = c, _ => {});
     _translateComponent = AddComponent <ITranslateComponent>();
     Bind <ITranslateComponent>(c => _translateComponent = c, _ => {});
     _imageComponent = AddComponent <IImageComponent>();
     Bind <IImageComponent>(c => _imageComponent = c, _ => {});
     _borderComponent = AddComponent <IBorderComponent>();
     Bind <IBorderComponent>(c => _borderComponent = c, _ => { });
     _scaleComponent = AddComponent <IScaleComponent>();
     Bind <IScaleComponent>(c => _scaleComponent = c, _ => {});
     _rotateComponent = AddComponent <IRotateComponent>();
     Bind <IRotateComponent>(c => _rotateComponent = c, _ => {});
     _pixelPerfectComponent = AddComponent <IPixelPerfectComponent>();
     Bind <IPixelPerfectComponent>(c => _pixelPerfectComponent = c, _ => {});
     _modelMatrixComponent = AddComponent <IModelMatrixComponent>();
     Bind <IModelMatrixComponent>(c => _modelMatrixComponent = c, _ => {});
     _boundingBoxComponent = AddComponent <IBoundingBoxComponent>();
     Bind <IBoundingBoxComponent>(c => _boundingBoxComponent = c, _ => {});
     _worldPositionComponent = AddComponent <IWorldPositionComponent>();
     Bind <IWorldPositionComponent>(c => _worldPositionComponent = c, _ => {});
     _faceDirectionComponent = AddComponent <IFaceDirectionComponent>();
     Bind <IFaceDirectionComponent>(c => _faceDirectionComponent = c, _ => {});
     _outfitComponent = AddComponent <IOutfitComponent>();
     Bind <IOutfitComponent>(c => _outfitComponent = c, _ => {});
     _inventoryComponent = AddComponent <IInventoryComponent>();
     Bind <IInventoryComponent>(c => _inventoryComponent = c, _ => {});
     _followComponent = AddComponent <IFollowComponent>();
     Bind <IFollowComponent>(c => _followComponent = c, _ => {});
     _hotspotComponent = AddComponent <IHotspotComponent>();
     Bind <IHotspotComponent>(c => _hotspotComponent = c, _ => {});
     beforeInitComponents(resolver, outfit);
     InitComponents();
     afterInitComponents(resolver, outfit);
 }
Пример #7
0
 public override void Init(IEntity entity)
 {
     _entity = entity;
     base.Init(entity);
     entity.Bind <IBoundingBoxComponent>(c =>
     {
         _boundingBox = c;
         c.OnBoundingBoxesChanged.Subscribe(onBoundingBoxChanged);
         onSomethingChanged();
     }, c => { c.OnBoundingBoxesChanged.Unsubscribe(onBoundingBoxChanged); _boundingBox = null; });
     entity.Bind <IInObjectTreeComponent>(c => { _tree = c; subscribeTree(c.TreeNode); onSomethingChanged(); },
                                          c => { unsubscribeTree(c.TreeNode); _tree = null; });
 }
Пример #8
0
 public AGSButton(string id, Resolver resolver) : base(id, resolver)
 {
     _uIEvents = AddComponent <IUIEvents>();
     Bind <IUIEvents>(c => _uIEvents = c, _ => {});
     _skinComponent = AddComponent <ISkinComponent>();
     Bind <ISkinComponent>(c => _skinComponent = c, _ => {});
     _hasRoomComponent = AddComponent <IHasRoomComponent>();
     Bind <IHasRoomComponent>(c => _hasRoomComponent = c, _ => {});
     _animationComponent = AddComponent <IAnimationComponent>();
     Bind <IAnimationComponent>(c => _animationComponent = c, _ => {});
     _inObjectTreeComponent = AddComponent <IInObjectTreeComponent>();
     Bind <IInObjectTreeComponent>(c => _inObjectTreeComponent = c, _ => {});
     _colliderComponent = AddComponent <IColliderComponent>();
     Bind <IColliderComponent>(c => _colliderComponent = c, _ => {});
     _visibleComponent = AddComponent <IVisibleComponent>();
     Bind <IVisibleComponent>(c => _visibleComponent = c, _ => {});
     _enabledComponent = AddComponent <IEnabledComponent>();
     Bind <IEnabledComponent>(c => _enabledComponent = c, _ => {});
     _customPropertiesComponent = AddComponent <ICustomPropertiesComponent>();
     Bind <ICustomPropertiesComponent>(c => _customPropertiesComponent = c, _ => {});
     _drawableInfoComponent = AddComponent <IDrawableInfoComponent>();
     Bind <IDrawableInfoComponent>(c => _drawableInfoComponent = c, _ => {});
     _shaderComponent = AddComponent <IShaderComponent>();
     Bind <IShaderComponent>(c => _shaderComponent = c, _ => {});
     _translateComponent = AddComponent <ITranslateComponent>();
     Bind <ITranslateComponent>(c => _translateComponent = c, _ => {});
     _imageComponent = AddComponent <IImageComponent>();
     Bind <IImageComponent>(c => _imageComponent = c, _ => {});
     _borderComponent = AddComponent <IBorderComponent>();
     Bind <IBorderComponent>(c => _borderComponent = c, _ => { });
     _scaleComponent = AddComponent <IScaleComponent>();
     Bind <IScaleComponent>(c => _scaleComponent = c, _ => {});
     _rotateComponent = AddComponent <IRotateComponent>();
     Bind <IRotateComponent>(c => _rotateComponent = c, _ => {});
     _pixelPerfectComponent = AddComponent <IPixelPerfectComponent>();
     Bind <IPixelPerfectComponent>(c => _pixelPerfectComponent = c, _ => {});
     _modelMatrixComponent = AddComponent <IModelMatrixComponent>();
     Bind <IModelMatrixComponent>(c => _modelMatrixComponent = c, _ => {});
     _boundingBoxComponent = AddComponent <IBoundingBoxComponent>();
     Bind <IBoundingBoxComponent>(c => _boundingBoxComponent = c, _ => {});
     _worldPositionComponent = AddComponent <IWorldPositionComponent>();
     Bind <IWorldPositionComponent>(c => _worldPositionComponent = c, _ => {});
     _textComponent = AddComponent <ITextComponent>();
     Bind <ITextComponent>(c => _textComponent = c, _ => {});
     _buttonComponent = AddComponent <IButtonComponent>();
     Bind <IButtonComponent>(c => _buttonComponent = c, _ => {});
     beforeInitComponents(resolver);
     InitComponents();
     afterInitComponents(resolver);
 }
 public AGSInventoryWindow(string id, Resolver resolver, IImage image) : base(id, resolver)
 {
     _uIEvents = AddComponent <IUIEvents>();
     Bind <IUIEvents>(c => _uIEvents = c, _ => {});
     _skinComponent = AddComponent <ISkinComponent>();
     Bind <ISkinComponent>(c => _skinComponent = c, _ => {});
     _hasRoom = AddComponent <IHasRoomComponent>();
     Bind <IHasRoomComponent>(c => _hasRoom = c, _ => {});
     _animationComponent = AddComponent <IAnimationComponent>();
     Bind <IAnimationComponent>(c => _animationComponent = c, _ => {});
     _inObjectTree = AddComponent <IInObjectTreeComponent>();
     Bind <IInObjectTreeComponent>(c => _inObjectTree = c, _ => {});
     _collider = AddComponent <IColliderComponent>();
     Bind <IColliderComponent>(c => _collider = c, _ => {});
     _visibleComponent = AddComponent <IVisibleComponent>();
     Bind <IVisibleComponent>(c => _visibleComponent = c, _ => {});
     _enabledComponent = AddComponent <IEnabledComponent>();
     Bind <IEnabledComponent>(c => _enabledComponent = c, _ => {});
     _customPropertiesComponent = AddComponent <ICustomPropertiesComponent>();
     Bind <ICustomPropertiesComponent>(c => _customPropertiesComponent = c, _ => {});
     _drawableInfo = AddComponent <IDrawableInfoComponent>();
     Bind <IDrawableInfoComponent>(c => _drawableInfo = c, _ => {});
     _hotspotComponent = AddComponent <IHotspotComponent>();
     Bind <IHotspotComponent>(c => _hotspotComponent = c, _ => {});
     _shaderComponent = AddComponent <IShaderComponent>();
     Bind <IShaderComponent>(c => _shaderComponent = c, _ => {});
     _translateComponent = AddComponent <ITranslateComponent>();
     Bind <ITranslateComponent>(c => _translateComponent = c, _ => {});
     _imageComponent = AddComponent <IImageComponent>();
     Bind <IImageComponent>(c => _imageComponent = c, _ => {});
     _scaleComponent = AddComponent <IScaleComponent>();
     Bind <IScaleComponent>(c => _scaleComponent = c, _ => {});
     _rotateComponent = AddComponent <IRotateComponent>();
     Bind <IRotateComponent>(c => _rotateComponent = c, _ => {});
     _pixelPerfectComponent = AddComponent <IPixelPerfectComponent>();
     Bind <IPixelPerfectComponent>(c => _pixelPerfectComponent = c, _ => {});
     _modelMatrixComponent = AddComponent <IModelMatrixComponent>();
     Bind <IModelMatrixComponent>(c => _modelMatrixComponent = c, _ => {});
     _boundingBoxComponent = AddComponent <IBoundingBoxComponent>();
     Bind <IBoundingBoxComponent>(c => _boundingBoxComponent = c, _ => {});
     _inventoryWindowComponent = AddComponent <IInventoryWindowComponent>();
     Bind <IInventoryWindowComponent>(c => _inventoryWindowComponent = c, _ => {});
     beforeInitComponents(resolver, image);
     InitComponents();
     afterInitComponents(resolver, image);
 }
Пример #10
0
            public EntitySubscriber(IEntity entity, Action <int> onLayerChanged)
            {
                _entity         = entity;
                _onLayerChanged = onLayerChanged;
                entity.Bind <IDrawableInfoComponent>(c => _layer = c.RenderLayer?.Z ?? 0, _ => _layer = 0);

                var vBinding = bind <IVisibleComponent>(entity, onObjVisibleChanged);
                var tBinding = bind <ITranslateComponent>(entity, onObjTranslatePropertyChanged);
                var dBinding = bind <IDrawableInfoComponent>(entity, onObjDrawablePropertyChanged);

                AnimationSubscriber animSubscriber = new AnimationSubscriber(entity, onSomethingChanged);
                var aBinding = animSubscriber.Bind();

                var trBinding = entity.Bind <IInObjectTreeComponent>(c => { _tree = c; c.TreeNode.OnParentChanged.Subscribe(onSomethingChanged); onSomethingChanged(); }, c => { _tree = null; c.TreeNode.OnParentChanged.Unsubscribe(onSomethingChanged); onSomethingChanged(); });

                _bindings = new List <API.IComponentBinding> {
                    vBinding, tBinding, dBinding, aBinding, trBinding
                };
            }
Пример #11
0
            public EntitySubscriber(IEntity entity, Action <int> onLayerChanged)
            {
                _onLayerChanged = onLayerChanged;
                entity.Bind <IDrawableInfoComponent>(c => _drawable = c, _ => _drawable = null);

                var vBinding = bind <IVisibleComponent>(entity, onObjVisibleChanged);
                var tBinding = bind <ITranslateComponent>(entity, onObjTranslatePropertyChanged);
                var dBinding = bind <IDrawableInfoComponent>(entity, onObjDrawablePropertyChanged);
                var eBinding = bind <IAreaComponent>(entity, onAreaPropertyChanged);
                var bBinding = bind <IWalkBehindArea>(entity, onWalkBehindPropertyChanged);

                AnimationSubscriber animSubscriber = new AnimationSubscriber(entity, onSomethingChanged);
                var aBinding = animSubscriber.Bind();

                var trBinding = entity.Bind <IInObjectTreeComponent>(c => { _tree = c; c.TreeNode.OnParentChanged.Subscribe(onSomethingChanged); onSomethingChanged(); }, c => { _tree = null; c.TreeNode.OnParentChanged.Unsubscribe(onSomethingChanged); onSomethingChanged(); });

                _bindings = new List <IComponentBinding> {
                    vBinding, tBinding, dBinding, aBinding, trBinding, eBinding, bBinding
                };
            }
Пример #12
0
        public override void Init()
        {
            base.Init();
            Entity.Bind <ITextComponent>(c =>
            {
                _textComponent     = c;
                c.PropertyChanged += onTextPropertyChanged;
            }, c =>
            {
                _textComponent     = null;
                c.PropertyChanged -= onTextPropertyChanged;
            });
            Entity.Bind <IUIEvents>(c =>
            {
                c.MouseDown.Subscribe(onMouseDown);
                c.LostFocus.Subscribe(onMouseDownOutside);
            }, c =>
            {
                c.MouseDown.Unsubscribe(onMouseDown);
                c.LostFocus.Unsubscribe(onMouseDownOutside);
            });
            Entity.Bind <IInObjectTreeComponent>(c => _tree        = c, _ => _tree = null);
            Entity.Bind <IHasRoomComponent>(c => _room             = c, _ => _room = null);
            Entity.Bind <IVisibleComponent>(c => _visibleComponent = c, _ => _visibleComponent = null);

            _caretFlashCounter = (int)CaretFlashDelay;
            _withCaret         = new Lazy <ILabel>(() =>
            {
                var label   = _game.Factory.UI.GetLabel(Entity.ID + " Caret", "|", 1f, 1f, 0f, 0f, config: _game.Factory.Fonts.GetTextConfig(autoFit: AutoFit.LabelShouldFitText));
                label.Pivot = new PointF(0f, 0f);
                label.TextBackgroundVisible = false;
                return(label);
            });

            Entity.Bind <IImageComponent>(c => _imageComponent           = c, _ => _imageComponent = null);
            Entity.Bind <IDrawableInfoComponent>(c => _drawableComponent = c, _ => _drawableComponent = null);

            _game.Events.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute);
        }
Пример #13
0
        public override void AfterInit()
        {
            Entity.Bind <IDrawableInfoComponent>(
                c =>
            {
                _drawable          = c;
                c.PropertyChanged += _onDrawbaleChangedCallback;
                onSomethingChanged();
            }, c =>
            {
                c.PropertyChanged -= _onDrawbaleChangedCallback;
                _drawable          = null;
                onSomethingChanged();
            });
            Entity.Bind <IHasRoomComponent>(
                c => { _room = c; refreshAreaScaling(); subscribeRoom(); onSomethingChanged(); },
                c => { unsubscribeRoom(c); _room = null; refreshAreaScaling(); onSomethingChanged(); });
            Entity.Bind <IScaleComponent>(
                c => { _scale = c; c.PropertyChanged += _onScaleChangedCallback; onSomethingChanged(); },
                c => { c.PropertyChanged -= _onScaleChangedCallback; _scale = null; onSomethingChanged(); });
            Entity.Bind <ITranslateComponent>(
                c => { _translate = c; c.PropertyChanged += _onTranslateChangedCallback; onSomethingChanged(); },
                c => { c.PropertyChanged -= _onTranslateChangedCallback; _translate = null; onSomethingChanged(); }
                );
            Entity.Bind <IWorldPositionComponent>(
                c => { _worldPosition = c; c.PropertyChanged += _onWorldPositionChangedCallback; onSomethingChanged(); },
                c => { c.PropertyChanged -= _onWorldPositionChangedCallback; _translate = null; onSomethingChanged(); }
                );
            Entity.Bind <IJumpOffsetComponent>(
                c => { _jump = c; c.PropertyChanged += _onJumpOffsetChangedCallback; onSomethingChanged(); },
                c => { c.PropertyChanged -= _onJumpOffsetChangedCallback; _jump = null; onSomethingChanged(); }
                );
            Entity.Bind <IRotateComponent>(
                c => { _rotate = c; c.PropertyChanged += _onRotateChangedCallback; onSomethingChanged(); },
                c => { c.PropertyChanged -= _onRotateChangedCallback; _rotate = null; onSomethingChanged(); }
                );
            Entity.Bind <IImageComponent>(
                c => { _image = c; c.PropertyChanged += _onImageChangedCallback; onSomethingChanged(); },
                c => { c.PropertyChanged -= _onImageChangedCallback; _image = null; onSomethingChanged(); }
                );
            Entity.Bind <ITextComponent>(
                c => { _text = c; subscribeTextComponent(); },
                _ => { unsubscribeTextComponent(); _text = null; }
                );

            Entity.Bind <IInObjectTreeComponent>(
                c =>
            {
                _tree   = c;
                _parent = _tree.TreeNode.Parent;
                _tree.TreeNode.OnParentChanged.Subscribe(_onParentChangedCallback);
                _parent?.OnMatrixChanged.Subscribe(_onSomethingChangedCallback);
                onSomethingChanged();
            }, c =>
            {
                c.TreeNode.OnParentChanged.Unsubscribe(_onParentChangedCallback);
                c.TreeNode.Parent?.OnMatrixChanged.Unsubscribe(_onSomethingChangedCallback);
                _tree   = null;
                _parent = null;
                onSomethingChanged();
            });
        }
Пример #14
0
 public override void Init()
 {
     base.Init();
     Entity.Bind <IInObjectTreeComponent>(c => _tree = c, _ => _tree = null);
 }
Пример #15
0
 public override void Init(IEntity entity)
 {
     base.Init(entity);
     entity.Bind <IScaleComponent>(c => _scale       = c, _ => _scale = null);
     entity.Bind <IInObjectTreeComponent>(c => _tree = c, _ => _tree = null);
 }
Пример #16
0
 public override void AfterInit()
 {
     base.AfterInit();
     _entity.Bind<IInObjectTreeComponent>(c => { _tree = c; c.TreeNode.OnParentChanged.Subscribe(onParentChanged); onParentChanged(); },
                                c => { _tree = null; c.TreeNode.OnParentChanged.Unsubscribe(onParentChanged); });
 }
Пример #17
0
        private AGSBoundingBox getBoundingBox(IInObjectTreeComponent tree, IBoundingBoxComponent box,
                                              Func <AGSBoundingBoxes, AGSBoundingBox> getBox, string printoutId)
        {
            float minX = float.MaxValue;
            float maxX = float.MinValue;
            float minY = float.MaxValue;
            float maxY = float.MinValue;

            var boxes = box?.GetBoundingBoxes(_state.Viewport);

            if (boxes != null)
            {
                var boundingBox = getBox(boxes);

                if (boundingBox.IsValid)
                {
                    minX = boundingBox.MinX;
                    maxX = boundingBox.MaxX;
                    minY = boundingBox.MinY;
                    maxY = boundingBox.MaxY;
                }

                if (printoutId != null)
                {
                    Debug.WriteLine($"{printoutId}: {minX}-{maxX}, {minY}-{maxY}");
                }
            }

            if (tree?.TreeNode != null)
            {
                foreach (var child in tree.TreeNode.Children)
                {
                    if (child == null || !child.UnderlyingVisible || EntitiesToSkip.Contains(child.ID))
                    {
                        continue;
                    }

                    //note: the text component check is needed for textboxes. We have a "with caret" version of the textbox flashing in and out
                    //but we don't want to set it to visible and not visible because it hurts performance to keep changing the display list (which triggers sorting)
                    //so we hide the the text and text background with label renderer properties. Because it's hidden the textbox may not be updated which correct bounding boxes.
                    var textComponent = child.GetComponent <ITextComponent>();
                    if (textComponent != null && !textComponent.TextVisible && !child.IsImageVisible)
                    {
                        continue;
                    }

                    var childBox = getBoundingBox(child, child, getBox, printoutId == null ? null : child.ID);
                    if (!childBox.IsValid)
                    {
                        continue;
                    }
                    if (minX > childBox.MinX)
                    {
                        minX = childBox.MinX;
                    }
                    if (maxX < childBox.MaxX)
                    {
                        maxX = childBox.MaxX;
                    }
                    if (minY > childBox.MinY)
                    {
                        minY = childBox.MinY;
                    }
                    if (maxY < childBox.MaxY)
                    {
                        maxY = childBox.MaxY;
                    }
                }
            }
            if (MathUtils.FloatEquals(minX, float.MaxValue))
            {
                return(default);