Beispiel #1
0
 public AGSButton(string id, Resolver resolver) : base(id, resolver)
 {
     _uIEvents              = AddComponent <IUIEvents>();
     _skinComponent         = AddComponent <ISkinComponent>();
     _hasRoom               = AddComponent <IHasRoom>();
     _animationContainer    = AddComponent <IAnimationContainer>();
     _inObjectTree          = AddComponent <IInObjectTree>();
     _collider              = AddComponent <ICollider>();
     _visibleComponent      = AddComponent <IVisibleComponent>();
     _enabledComponent      = AddComponent <IEnabledComponent>();
     _customProperties      = AddComponent <ICustomPropertiesComponent>();
     _drawableInfo          = AddComponent <IDrawableInfo>();
     _hotspotComponent      = AddComponent <IHotspotComponent>();
     _shaderComponent       = AddComponent <IShaderComponent>();
     _translateComponent    = AddComponent <ITranslateComponent>();
     _imageComponent        = AddComponent <IImageComponent>();
     _scaleComponent        = AddComponent <IScaleComponent>();
     _rotateComponent       = AddComponent <IRotateComponent>();
     _pixelPerfectComponent = AddComponent <IPixelPerfectComponent>();
     _textComponent         = AddComponent <ITextComponent>();
     _buttonComponent       = AddComponent <IButtonComponent>();
     _modelMatrixComponent  = AddComponent <IModelMatrixComponent>();
     beforeInitComponents(resolver);
     InitComponents();
     afterInitComponents(resolver);
 }
 public AGSCharacter(string id, Resolver resolver, IOutfit outfit) : base(id, resolver)
 {
     _hasRoom               = AddComponent <IHasRoom>();
     _animationContainer    = AddComponent <IAnimationContainer>();
     _inObjectTree          = AddComponent <IInObjectTree>();
     _collider              = AddComponent <ICollider>();
     _visibleComponent      = AddComponent <IVisibleComponent>();
     _enabledComponent      = AddComponent <IEnabledComponent>();
     _customProperties      = AddComponent <ICustomPropertiesComponent>();
     _drawableInfo          = AddComponent <IDrawableInfo>();
     _hotspotComponent      = AddComponent <IHotspotComponent>();
     _shaderComponent       = AddComponent <IShaderComponent>();
     _translateComponent    = AddComponent <ITranslateComponent>();
     _imageComponent        = AddComponent <IImageComponent>();
     _scaleComponent        = AddComponent <IScaleComponent>();
     _rotateComponent       = AddComponent <IRotateComponent>();
     _pixelPerfectComponent = AddComponent <IPixelPerfectComponent>();
     _faceDirectionBehavior = AddComponent <IFaceDirectionBehavior>();
     _hasOutfit             = AddComponent <IHasOutfit>();
     _hasInventory          = AddComponent <IHasInventory>();
     _followBehavior        = AddComponent <IFollowBehavior>();
     _modelMatrixComponent  = AddComponent <IModelMatrixComponent>();
     beforeInitComponents(resolver, outfit);
     InitComponents();
     afterInitComponents(resolver, outfit);
 }
Beispiel #3
0
 public override void Init()
 {
     base.Init();
     Entity.Bind <IImageComponent>(c => _image = c, _ => _image = null);
     Entity.Bind <IScaleComponent>(c => { _scale = c; c.PropertyChanged += onScalePropertyChanged; }, c => { _scale = null; c.PropertyChanged -= onScalePropertyChanged; });
     Entity.Bind <IDrawableInfoComponent>(c => { _drawable = c; c.PropertyChanged += onDrawablePropertyChanged; }, c => { _drawable = null; c.PropertyChanged -= onDrawablePropertyChanged; });
     Entity.Bind <ICropSelfComponent>(c => _cropSelf = c, _ => _cropSelf = null);
     Entity.Bind <IModelMatrixComponent>(c => { _matrix = c; c.OnMatrixChanged.Subscribe(onMatrixChanged); }, c => { _matrix = null; c.OnMatrixChanged.Unsubscribe(onMatrixChanged); });
     Entity.Bind <IVisibleComponent>(c => _visible = c, _ => _visible = null);
     _events.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute);
     _pipeline.Subscribe(Entity.ID, this, -10);
 }
Beispiel #4
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);
 }
        private void updateHitTestBox(SizeF size, IDrawableInfoComponent drawable, IModelMatrixComponent matrix)
        {
            var modelMatrices = matrix.GetModelMatrices();
            var modelMatrix   = modelMatrices.InVirtualResolutionMatrix;

            AGSModelMatrixComponent.GetVirtualResolution(false, _settings.VirtualResolution,
                                                         drawable, null, out PointF resolutionFactor, out Size _);

            float width  = size.Width / resolutionFactor.X;
            float height = size.Height / resolutionFactor.Y;

            _intermediateBox = _boundingBoxBuilder.BuildIntermediateBox(width, height, ref modelMatrix);
            _hitTestBox      = _boundingBoxBuilder.BuildHitTestBox(ref _intermediateBox);
        }
Beispiel #6
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);
 }
        public override void Init()
        {
            base.Init();

            Entity.Bind <IModelMatrixComponent>(c => { c.OnMatrixChanged.Subscribe(_onHitTextBoxShouldChangeCallback); _matrix = c; },
                                                c => { c.OnMatrixChanged.Unsubscribe(_onHitTextBoxShouldChangeCallback); _matrix = null; });
            Entity.Bind <ICropSelfComponent>(c => { c.PropertyChanged += _onCropShouldChangeCallback; _crop = c; },
                                             c => { c.PropertyChanged -= _onCropShouldChangeCallback; _crop = null; });
            Entity.Bind <IImageComponent>(c => { _image = c; c.PropertyChanged += _onImageChangedCallback; },
                                          c => { _image = null; c.PropertyChanged -= _onImageChangedCallback; });
            Entity.Bind <IScaleComponent>(c => _scale = c, _ => _scale = null);
            Entity.Bind <IDrawableInfoComponent>(c => { c.PropertyChanged += _onDrawableChangedCallback; _drawable = c; },
                                                 c => { c.PropertyChanged -= _onDrawableChangedCallback; _drawable = null; });
            Entity.Bind <ITextureOffsetComponent>(c => { c.PropertyChanged += _onTextureOffsetChangedCallback; _textureOffset = c; onAllViewportsShouldChange(); },
                                                  c => { c.PropertyChanged -= _onTextureOffsetChangedCallback; _textureOffset = null; onAllViewportsShouldChange(); });
        }
        public override void Init(IEntity entity)
        {
            _entity = entity;
            base.Init(entity);

            entity.Bind <IModelMatrixComponent>(c => { c.OnMatrixChanged.Subscribe(onHitTextBoxShouldChange); _matrix = c; },
                                                c => { c.OnMatrixChanged.Unsubscribe(onHitTextBoxShouldChange); _matrix = null; });
            entity.Bind <ICropSelfComponent>(c => { c.PropertyChanged += onCropShouldChange; _crop = c; },
                                             c => { c.PropertyChanged -= onCropShouldChange; _crop = null; });
            entity.Bind <IImageComponent>(c => c.PropertyChanged += onImageChanged,
                                          c => c.PropertyChanged -= onImageChanged);
            entity.Bind <IAnimationComponent>(c => _animation     = c, _animation => _animation = null);
            entity.Bind <IDrawableInfoComponent>(c => { c.PropertyChanged += onDrawableChanged; _drawable = c; },
                                                 c => { c.PropertyChanged -= onDrawableChanged; _drawable = null; });
            entity.Bind <ITextureOffsetComponent>(c => { c.PropertyChanged += onTextureOffsetChanged; _textureOffset = c; onAllViewportsShouldChange(); },
                                                  c => { c.PropertyChanged -= onTextureOffsetChanged; _textureOffset = null; onAllViewportsShouldChange(); });
        }
        private void updateHitTestBox(IAnimationComponent animation, IDrawableInfoComponent drawable, IModelMatrixComponent matrix)
        {
            var modelMatrices = matrix.GetModelMatrices();
            var modelMatrix   = modelMatrices.InVirtualResolutionMatrix;

            Size   resolution;
            PointF resolutionFactor;
            bool   resolutionMatches = AGSModelMatrixComponent.GetVirtualResolution(false, _settings.VirtualResolution,
                                                                                    drawable, null, out resolutionFactor, out resolution);

            var   sprite = animation.Animation.Sprite;
            float width  = sprite.BaseSize.Width / resolutionFactor.X;
            float height = sprite.BaseSize.Height / resolutionFactor.Y;

            _intermediateBox = _boundingBoxBuilder.BuildIntermediateBox(width, height, ref modelMatrix);
            _hitTestBox      = _boundingBoxBuilder.BuildHitTestBox(ref _intermediateBox);
        }