Esempio n. 1
0
 public override void Init()
 {
     base.Init();
     Entity.Bind <IBoundingBoxComponent>(c => _boundingBox = c, _ => _boundingBox = null);
     Entity.Bind <IImageComponent>(c => _image             = c, _ => _image = null);
     _pipeline.Subscribe(Entity.ID, this, -200);
 }
Esempio n. 2
0
            public void UpdatePosition(IBoundingBoxComponent box)
            {
                const float padding     = 1f;
                float       offsetHoriz = 2f + padding;
                float       offsetVert  = 2f + padding;

                switch (_direction)
                {
                case Direction.UpRight:
                    move(box.WorldBoundingBox.MaxX + offsetHoriz, box.WorldBoundingBox.MaxY + offsetVert);
                    break;

                case Direction.UpLeft:
                    move(box.WorldBoundingBox.MinX - offsetHoriz, box.WorldBoundingBox.MaxY + offsetVert);
                    break;

                case Direction.DownRight:
                    move(box.WorldBoundingBox.MaxX + offsetHoriz, box.WorldBoundingBox.MinY - offsetVert);
                    break;

                case Direction.DownLeft:
                    move(box.WorldBoundingBox.MinX - offsetHoriz, box.WorldBoundingBox.MinY - offsetVert);
                    break;
                }
            }
Esempio n. 3
0
 public override void Init()
 {
     base.Init();
     Entity.Bind <IBoundingBoxComponent>(c => _box = c, _ => _box = null);
     _pipeline.Subscribe(Entity.ID, _back, 100);
     _pipeline.Subscribe(Entity.ID, _front, -100);
 }
Esempio n. 4
0
 public override void Init()
 {
     base.Init();
     Entity.Bind <IDrawableInfoComponent>(c => _drawableInfo = c, _ => _drawableInfo = null);
     Entity.Bind <IImageComponent>(c => _obj   = c, _ => _obj = null);
     Entity.Bind <IScaleComponent>(c => _scale = c, _ => _scale = null);
     Entity.Bind <IPixelPerfectComponent>(c => _pixelPerfect = c, _ => _pixelPerfect = null);
     Entity.Bind <IBoundingBoxComponent>(c => _boundingBox   = c, _ => _boundingBox = null);
 }
Esempio n. 5
0
 public override void Init()
 {
     base.Init();
     Entity.Bind <IBoundingBoxComponent>(
         c => { _box = c; c.OnBoundingBoxesChanged.Subscribe(refresh); refresh(); },
         c => { _box = null; c.OnBoundingBoxesChanged.Unsubscribe(refresh); });
     Entity.Bind <IImageComponent>(
         c => { _image = c; c.PropertyChanged += onImagePropertyChanged; refresh(); },
         c => { _image = null; c.PropertyChanged -= onImagePropertyChanged; });
 }
 public override void Init(IEntity entity)
 {
     base.Init(entity);
     entity.Bind <IBoundingBoxComponent>(
         c => { _box = c; c.OnBoundingBoxesChanged.Subscribe(refresh); refresh(); },
         _ => _box = null);
     entity.Bind <IImageComponent>(
         c => { _image = c; c.PropertyChanged += onImagePropertyChanged; refresh(); },
         _ => _image = null);
 }
Esempio n. 7
0
 public override void Init(IEntity entity)
 {
     base.Init(entity);
     _entity = entity;
     entity.Bind <IDrawableInfoComponent>(c => _drawableInfo = c, _ => _drawableInfo = null);
     entity.Bind <IAnimationComponent>(c => _obj             = c, _ => _obj = null);
     entity.Bind <IScaleComponent>(c => _scale = c, _ => _scale = null);
     entity.Bind <IPixelPerfectComponent>(c => _pixelPerfect = c, _ => _pixelPerfect = null);
     entity.Bind <IBoundingBoxComponent>(c => _boundingBox   = c, _ => _boundingBox = null);
 }
Esempio n. 8
0
 private void bindGraphics(IObject graphics)
 {
     if (graphics == null)
     {
         return;
     }
     graphics.Bind <IBoundingBoxComponent>(c => { _boundingBox = c; c.OnBoundingBoxesChanged.Subscribe(refresh); },
                                           c => { _boundingBox = null; c.OnBoundingBoxesChanged.Unsubscribe(refresh); });
     graphics.Bind <IScaleComponent>(c => { _scale = c; c.PropertyChanged += onScaleChanged; },
                                     c => { _scale = null; c.PropertyChanged -= onScaleChanged; });
 }
Esempio n. 9
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);
 }
Esempio n. 10
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; });
 }
Esempio n. 11
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);
 }
Esempio n. 13
0
        public override void Init()
        {
            base.Init();
            addResizeHandles(Entity, Direction.Right, Direction.Left, Direction.Up, Direction.Down,
                             Direction.UpRight, Direction.UpLeft, Direction.DownRight, Direction.DownLeft);
            addRotateHandles(Entity, Direction.UpRight, Direction.UpLeft, Direction.DownRight, Direction.DownLeft);
            addPivotHandle(Entity);
            addDragHandle(Entity);

            Entity.Bind <IScaleComponent>(setScale, _ => setScale(null));
            Entity.Bind <IRotateComponent>(setRotate, _ => setRotate(null));
            Entity.Bind <IImageComponent>(setImage, _ => setImage(null));
            Entity.Bind <ITranslateComponent>(setTranslate, _ => setTranslate(null));
            Entity.Bind <IDrawableInfoComponent>(setDrawable, _ => setDrawable(null));

            Entity.Bind <IBoundingBoxComponent>(
                c => { _box = c; c.OnBoundingBoxesChanged.Subscribe(onBoundingBoxChanged); _pivotHandle?.SetBox(c); _dragHandle?.SetBox(c); updatePositions(); },
                c => { _box = null; c.OnBoundingBoxesChanged.Unsubscribe(onBoundingBoxChanged); _pivotHandle?.SetBox(null); _dragHandle?.SetBox(null); });

            Entity.Bind <EditorUIEvents>(c => c.MouseClicked.Subscribe(onMouseClicked), c => c.MouseClicked.Unsubscribe(onMouseClicked));

            _events.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute);
        }
Esempio n. 14
0
        public static void ExpandAroundGameObject(AGSEditor editor, IBoundingBoxComponent boxComponent, IDrawableInfoComponent drawable,
                                                  IImageComponent image, IObject objToExpand, bool updatePosition)
        {
            if (boxComponent == null || image == null)
            {
                return;
            }
            var box = boxComponent.WorldBoundingBox;

            objToExpand.Pivot = image.Pivot;
            var x = MathUtils.Lerp(0f, box.MinX, 1f, box.MaxX, image.Pivot.X);
            var y = MathUtils.Lerp(0f, box.MinY, 1f, box.MaxY, image.Pivot.Y);

            (x, y) = editor.ToEditorResolution(x, y, drawable);

            (var minX, var minY) = editor.ToEditorResolution(box.MinX, box.MinY, drawable);
            (var maxX, var maxY) = editor.ToEditorResolution(box.MaxX, box.MaxY, drawable);

            if (updatePosition)
            {
                objToExpand.Position = (x, y);
            }
            objToExpand.BaseSize = new SizeF(maxX - minX, maxY - minY);
        }
Esempio n. 15
0
 public void SetBox(IBoundingBoxComponent box)
 {
     _boundingBox = box;
     setVisible();
 }
Esempio n. 16
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);