private void replaceBoundingBox()
        {
            IBlockingEvent          boxChangeEvent = Entity.GetComponent <IBoundingBoxComponent>()?.OnBoundingBoxesChanged ?? new AGSEvent();
            AGSBoundingBoxComponent box            = new AGSBoundingBoxComponent(_settings, _labelBoundingBoxFakeBuilder, _state, _events, boxChangeEvent);

            Entity.RemoveComponent <IBoundingBoxComponent>();
            Entity.AddComponent <IBoundingBoxComponent>(box);
            box.Init(Entity, typeof(IBoundingBoxComponent));
            onBoundingBoxShouldChange();
        }
Exemple #2
0
        public void Prepare(IObject obj, IDrawableInfoComponent drawable, IViewport viewport)
        {
            if (!TextBackgroundVisible && !TextVisible)
            {
                return;
            }

            if (_lastObject != obj)
            {
                IBlockingEvent          boxChangeEvent = obj.GetComponent <IBoundingBoxComponent>()?.OnBoundingBoxesChanged ?? new AGSEvent();
                AGSBoundingBoxComponent box            = new AGSBoundingBoxComponent(_settings, _viewport,
                                                                                     _labelBoundingBoxFakeBuilder, _state, _events, boxChangeEvent);
                obj.RemoveComponent <IBoundingBoxComponent>();
                obj.AddComponent <IBoundingBoxComponent>(box);
                _lastObject = obj;
                foreach (var binding in _bindings)
                {
                    binding?.Unbind();
                }
                var scaleBinding    = obj.Bind <IScaleComponent>(c => c.PropertyChanged += onScalePropertyChanged, c => c.PropertyChanged -= onScalePropertyChanged);
                var matrixBinding   = obj.Bind <IModelMatrixComponent>(c => c.OnMatrixChanged.Subscribe(onMatrixChanged), c => c.OnMatrixChanged.Unsubscribe(onMatrixChanged));
                var drawableBinding = obj.Bind <IDrawableInfoComponent>(c => c.PropertyChanged += onDrawablePropertyChanged, c => c.PropertyChanged -= onDrawablePropertyChanged);
                onBoundingBoxShouldChange();
                _bindings.Clear();
                _bindings.Add(scaleBinding);
                _bindings.Add(matrixBinding);
                _bindings.Add(drawableBinding);
            }
            _glTextHitTest = _glTextHitTest ?? new GLText(_graphics, _messagePump, _fonts, _bitmapPool, false);
            _glTextRender  = _glTextRender ?? new GLText(_graphics, _messagePump, _fonts, _bitmapPool, true);

            updateBoundingBoxes(obj, drawable, viewport);
            if (_usedLabelBoundingBoxes != null)
            {
                _labelBoundingBoxFakeBuilder.BoundingBoxes = _usedLabelBoundingBoxes;
            }
            _bgRenderer.Prepare(obj, drawable, viewport);
            Width  = _usedLabelBoundingBoxes == null ? 1f : _usedLabelBoundingBoxes.RenderBox.Width;
            Height = _usedLabelBoundingBoxes == null ? 1f : _usedLabelBoundingBoxes.RenderBox.Height;
        }