Exemplo n.º 1
0
        public static unsafe void Initialize()
        {
            if (_static_infos != null)
            {
                return;
            }

            _static_infos = new RawList <static_animation_info>();
            UOFile file = AnimDataLoader.Instance.AnimDataFile;

            if (file == null)
            {
                return;
            }

            long startAddr = file.StartAddress.ToInt64();
            uint lastaddr  = (uint)(startAddr + file.Length - sizeof(AnimDataFrame2));

            for (int i = 0; i < TileDataLoader.Instance.StaticData.Length; i++)
            {
                if (TileDataLoader.Instance.StaticData[i]
                    .IsAnimated)
                {
                    uint addr   = (uint)(i * 68 + 4 * (i / 8 + 1));
                    uint offset = (uint)(startAddr + addr);

                    if (offset <= lastaddr)
                    {
                        _static_infos.Add
                        (
                            new static_animation_info
                        {
                            index    = (ushort)i,
                            is_field = StaticFilters.IsField((ushort)i)
                        }
                        );
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override bool Draw(Batcher2D batcher, Vector3 position, MouseOverList objectList)
        {
            if (IsDisposed)
            {
                return(false);
            }

            if (AnimationGraphic == Graphic.INVALID)
            {
                return(false);
            }

            Hue hue = Hue;

            if (Source is Item i)
            {
                if (Engine.Profile.Current.FieldsType == 1 && StaticFilters.IsField(AnimationGraphic))
                {
                    AnimIndex = 0;
                }
                else if (Engine.Profile.Current.FieldsType == 2)
                {
                    if (StaticFilters.IsFireField(Graphic))
                    {
                        AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x0020;
                    }
                    else if (StaticFilters.IsParalyzeField(Graphic))
                    {
                        AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x0058;
                    }
                    else if (StaticFilters.IsEnergyField(Graphic))
                    {
                        AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x0070;
                    }
                    else if (StaticFilters.IsPoisonField(Graphic))
                    {
                        AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x0044;
                    }
                    else if (StaticFilters.IsWallOfStone(Graphic))
                    {
                        AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x038A;
                    }
                }
                else if (i.IsHidden)
                {
                    hue = 0x038E;
                }
            }

            if ((AnimationGraphic != _displayedGraphic || Texture == null || Texture.IsDisposed) && AnimationGraphic != Graphic.INVALID)
            {
                _displayedGraphic = AnimationGraphic;
                Texture           = FileManager.Art.GetTexture(AnimationGraphic);
                Bounds            = new Rectangle((Texture.Width >> 1) - 22, Texture.Height - 44, Texture.Width, Texture.Height);
            }

            Bounds.X = (Texture.Width >> 1) - 22 - (int)Offset.X;
            Bounds.Y = Texture.Height - 44 + (int)(Offset.Z - Offset.Y);

            StaticTiles data = FileManager.TileData.StaticData[_displayedGraphic];

            bool isPartial     = data.IsPartialHue;
            bool isTransparent = data.IsTranslucent;

            if (Engine.Profile.Current.NoColorObjectsOutOfRange && Distance > World.ViewRange)
            {
                HueVector = new Vector3(Constants.OUT_RANGE_COLOR, 1, HueVector.Z);
            }
            else if (World.Player.IsDead && Engine.Profile.Current.EnableBlackWhiteEffect)
            {
                HueVector = new Vector3(Constants.DEAD_RANGE_COLOR, 1, HueVector.Z);
            }
            else
            {
                HueVector = ShaderHuesTraslator.GetHueVector(hue, isPartial, isTransparent ? .5f : 0, false);
            }

            switch (Blend)
            {
            case GraphicEffectBlendMode.Multiply:
                batcher.SetBlendState(_multiplyBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.Screen:
            case GraphicEffectBlendMode.ScreenMore:
                batcher.SetBlendState(_screenBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.ScreenLess:
                batcher.SetBlendState(_screenLessBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.NormalHalfTransparent:
                batcher.SetBlendState(_normalHalfBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.ShadowBlue:
                batcher.SetBlendState(_shadowBlueBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            default:
                base.Draw(batcher, position, objectList);
                break;
            }

            Engine.DebugInfo.EffectsRendered++;

            return(true);
        }
Exemplo n.º 3
0
        public override bool Draw(UltimaBatcher2D batcher, int posX, int posY)
        {
            if (!AllowedToDraw || IsDestroyed)
            {
                return(false);
            }

            Engine.DebugInfo.ItemsRendered++;

            ResetHueVector();

            if (IsCorpse)
            {
                return(DrawCorpse(batcher, posX, posY - 3));
            }


            ushort hue = Hue;

            if (Engine.Profile.Current.FieldsType == 1 && StaticFilters.IsField(Graphic)) // static
            {
                unsafe
                {
                    _originalGraphic = (Graphic)(Graphic + _animDataFrame.FrameData[_animDataFrame.FrameCount >> 1]);
                }

                _force = false;
            }
            else if (Engine.Profile.Current.FieldsType == 2)
            {
                if (StaticFilters.IsFireField(Graphic))
                {
                    _originalGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                    hue = 0x0020;
                }
                else if (StaticFilters.IsParalyzeField(Graphic))
                {
                    _originalGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                    hue = 0x0058;
                }
                else if (StaticFilters.IsEnergyField(Graphic))
                {
                    _originalGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                    hue = 0x0070;
                }
                else if (StaticFilters.IsPoisonField(Graphic))
                {
                    _originalGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                    hue = 0x0044;
                }
                else if (StaticFilters.IsWallOfStone(Graphic))
                {
                    _originalGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                    hue = 0x038A;
                }
            }

            if (_originalGraphic != DisplayedGraphic || _force || Texture == null || Texture.IsDisposed)
            {
                if (_originalGraphic == 0)
                {
                    _originalGraphic = DisplayedGraphic;
                }

                Texture       = FileManager.Art.GetTexture(_originalGraphic);
                Bounds.X      = (Texture.Width >> 1) - 22;
                Bounds.Y      = Texture.Height - 44;
                Bounds.Width  = Texture.Width;
                Bounds.Height = Texture.Height;

                _force = false;
            }

            if (ItemData.IsFoliage)
            {
                if (CharacterIsBehindFoliage)
                {
                    if (AlphaHue != Constants.FOLIAGE_ALPHA)
                    {
                        ProcessAlpha(Constants.FOLIAGE_ALPHA);
                    }
                }
                else
                {
                    if (AlphaHue != 0xFF)
                    {
                        ProcessAlpha(0xFF);
                    }
                }
            }

            if (Engine.Profile.Current.HighlightGameObjects && SelectedObject.LastObject == this)
            {
                HueVector.X = 0x0023;
                HueVector.Y = 1;
            }
            else if (Engine.Profile.Current.NoColorObjectsOutOfRange && Distance > World.ClientViewRange)
            {
                HueVector.X = Constants.OUT_RANGE_COLOR;
                HueVector.Y = 1;
            }
            else if (World.Player.IsDead && Engine.Profile.Current.EnableBlackWhiteEffect)
            {
                HueVector.X = Constants.DEAD_RANGE_COLOR;
                HueVector.Y = 1;
            }
            else
            {
                bool isPartial = ItemData.IsPartialHue;

                if (SelectedObject.LastObject == this && !IsLocked && !IsMulti)
                {
                    isPartial = ItemData.Weight == 255;
                    hue       = 0x0035;
                }
                else if (IsHidden)
                {
                    hue = 0x038E;
                }

                ShaderHuesTraslator.GetHueVector(ref HueVector, hue, isPartial, ItemData.IsTranslucent ? .5f : 0);
            }

            if (!IsCorpse && !IsMulti && Amount > 1 && ItemData.IsStackable && DisplayedGraphic == Graphic && _originalGraphic == Graphic)
            {
                base.Draw(batcher, posX - 5, posY - 5);
            }

            if (ItemData.IsLight)
            {
                Engine.SceneManager.GetScene <GameScene>()
                .AddLight(this, this, posX + 22, posY + 22);
            }

            if (!Serial.IsValid && IsMulti && TargetManager.TargetingState == CursorTarget.MultiPlacement)
            {
                HueVector.Z = 0.5f;
            }

            return(base.Draw(batcher, posX, posY));
        }
Exemplo n.º 4
0
        public override bool Draw(Batcher2D batcher, Vector3 position, MouseOverList objectList)
        {
            if (IsDestroyed)
            {
                return(false);
            }

            if (AnimationGraphic == Graphic.INVALID)
            {
                return(false);
            }

            Hue hue = Hue;

            if (Source is Item i)
            {
                if (Engine.Profile.Current.FieldsType == 1 && StaticFilters.IsField(AnimationGraphic))
                {
                    AnimIndex = 0;
                }
                else if (Engine.Profile.Current.FieldsType == 2)
                {
                    if (StaticFilters.IsFireField(Graphic))
                    {
                        AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x0020;
                    }
                    else if (StaticFilters.IsParalyzeField(Graphic))
                    {
                        AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x0058;
                    }
                    else if (StaticFilters.IsEnergyField(Graphic))
                    {
                        AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x0070;
                    }
                    else if (StaticFilters.IsPoisonField(Graphic))
                    {
                        AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x0044;
                    }
                    else if (StaticFilters.IsWallOfStone(Graphic))
                    {
                        AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x038A;
                    }
                }
                else if (i.IsHidden)
                {
                    hue = 0x038E;
                }
            }

            if ((AnimationGraphic != _displayedGraphic || Texture == null || Texture.IsDisposed) && AnimationGraphic != Graphic.INVALID)
            {
                _displayedGraphic = AnimationGraphic;
                Texture           = FileManager.Art.GetTexture(AnimationGraphic);

                if (Source != null)
                {
                    Source.Texture = Texture;
                }
                Bounds = new Rectangle((Texture.Width >> 1) - 22, Texture.Height - 44, Texture.Width, Texture.Height);
            }

            if (Texture != null)
            {
                Bounds.X = (Texture.Width >> 1) - 22 - (int)Offset.X;
                Bounds.Y = Texture.Height - 44 + (int)(Offset.Z - Offset.Y);
            }

            ref readonly StaticTiles data = ref FileManager.TileData.StaticData[Graphic];
Exemplo n.º 5
0
        public override bool Draw(UltimaBatcher2D batcher, int posX, int posY)
        {
            if (!AllowedToDraw || IsDestroyed)
            {
                return(false);
            }

            //Engine.DebugInfo.ItemsRendered++;

            ResetHueVector();


            posX += (int)Offset.X;
            posY += (int)(Offset.Y + Offset.Z);


            if (IsCorpse)
            {
                return(DrawCorpse(batcher, posX, posY - 3));
            }


            ushort hue = Hue;

            if (ProfileManager.Current.FieldsType == 1 && StaticFilters.IsField(Graphic)) // static
            {
                unsafe
                {
                    IntPtr ptr = AnimDataLoader.Instance.GetAddressToAnim(Graphic);

                    if (ptr != IntPtr.Zero)
                    {
                        AnimDataFrame2 *animData = (AnimDataFrame2 *)ptr;

                        if (animData->FrameCount != 0)
                        {
                            _originalGraphic = (ushort)(Graphic + animData->FrameData[animData->FrameCount >> 1]);
                        }
                    }
                }

                _force = false;
            }
            else if (ProfileManager.Current.FieldsType == 2)
            {
                if (StaticFilters.IsFireField(Graphic))
                {
                    _originalGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                    hue = 0x0020;
                }
                else if (StaticFilters.IsParalyzeField(Graphic))
                {
                    _originalGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                    hue = 0x0058;
                }
                else if (StaticFilters.IsEnergyField(Graphic))
                {
                    _originalGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                    hue = 0x0070;
                }
                else if (StaticFilters.IsPoisonField(Graphic))
                {
                    _originalGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                    hue = 0x0044;
                }
                else if (StaticFilters.IsWallOfStone(Graphic))
                {
                    _originalGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                    hue = 0x038A;
                }
            }

            if (_originalGraphic != DisplayedGraphic || _force || Texture == null || Texture.IsDisposed)
            {
                if (_originalGraphic == 0)
                {
                    _originalGraphic = DisplayedGraphic;
                }

                Texture       = ArtLoader.Instance.GetTexture(_originalGraphic);
                Bounds.X      = (Texture.Width >> 1) - 22;
                Bounds.Y      = Texture.Height - 44;
                Bounds.Width  = Texture.Width;
                Bounds.Height = Texture.Height;

                _force = false;
            }

            if (ProfileManager.Current.HighlightGameObjects && SelectedObject.LastObject == this)
            {
                HueVector.X = 0x0023;
                HueVector.Y = 1;
            }
            else if (ProfileManager.Current.NoColorObjectsOutOfRange && Distance > World.ClientViewRange)
            {
                HueVector.X = Constants.OUT_RANGE_COLOR;
                HueVector.Y = 1;
            }
            else if (World.Player.IsDead && ProfileManager.Current.EnableBlackWhiteEffect)
            {
                HueVector.X = Constants.DEAD_RANGE_COLOR;
                HueVector.Y = 1;
            }
            else
            {
                bool isPartial = ItemData.IsPartialHue;

                if (SelectedObject.LastObject == this && !IsLocked && !IsMulti)
                {
                    isPartial = ItemData.Weight == 255;
                    hue       = 0x0035;
                }
                else if (IsHidden)
                {
                    hue = 0x038E;
                }

                ShaderHuesTraslator.GetHueVector(ref HueVector, hue, isPartial, ItemData.IsTranslucent ? .5f : 0);
            }

            if (!IsMulti && !IsCoin && Amount > 1 && ItemData.IsStackable)
            {
                base.Draw(batcher, posX - 5, posY - 5);
            }

            if (ItemData.IsLight)
            {
                Client.Game.GetScene <GameScene>()
                .AddLight(this, this, posX + 22, posY + 22);
            }

            if (!SerialHelper.IsValid(Serial) && IsMulti && TargetManager.TargetingState == CursorTarget.MultiPlacement)
            {
                HueVector.Z = 0.5f;
            }

            return(base.Draw(batcher, posX, posY));
        }