Example #1
0
        public override bool CheckMouseSelection()
        {
            if (!(SelectedObject.Object == this || FoliageIndex != -1 && Client.Game.GetScene <GameScene>().FoliageIndex == FoliageIndex))
            {
                ushort graphic = Graphic;

                bool isTree = StaticFilters.IsTree(graphic, out _);

                if (isTree && ProfileManager.CurrentProfile.TreeToStumps)
                {
                    graphic = Constants.TREE_REPLACE_GRAPHIC;
                }

                ref UOFileIndex index = ref ArtLoader.Instance.GetValidRefEntry(graphic + 0x4000);

                Point position = RealScreenPosition;
                position.X -= index.Width;
                position.Y -= index.Height;

                return(ArtLoader.Instance.PixelCheck
                       (
                           graphic,
                           SelectedObject.TranslatedMousePositionByViewport.X - position.X,
                           SelectedObject.TranslatedMousePositionByViewport.Y - position.Y
                       ));
            }
Example #2
0
        public override bool Draw(UltimaBatcher2D batcher, int posX, int posY, float depth)
        {
            if (!AllowedToDraw || IsDestroyed)
            {
                return(false);
            }

            ushort graphic = Graphic;
            ushort hue     = Hue;
            bool   partial = ItemData.IsPartialHue;

            if (ProfileManager.CurrentProfile.HighlightGameObjects && SelectedObject.LastObject == this)
            {
                hue     = Constants.HIGHLIGHT_CURRENT_OBJECT_HUE;
                partial = false;
            }
            else if (ProfileManager.CurrentProfile.NoColorObjectsOutOfRange && Distance > World.ClientViewRange)
            {
                hue     = Constants.OUT_RANGE_COLOR;
                partial = false;
            }
            else if (World.Player.IsDead && ProfileManager.CurrentProfile.EnableBlackWhiteEffect)
            {
                hue     = Constants.DEAD_RANGE_COLOR;
                partial = false;
            }

            Vector3 hueVec = ShaderHueTranslator.GetHueVector(hue, partial, AlphaHue / 255f);

            bool isTree = StaticFilters.IsTree(graphic, out _);

            if (isTree && ProfileManager.CurrentProfile.TreeToStumps)
            {
                graphic = Constants.TREE_REPLACE_GRAPHIC;
            }

            DrawStaticAnimated
            (
                batcher,
                graphic,
                posX,
                posY,
                hueVec,
                ProfileManager.CurrentProfile.ShadowsEnabled && ProfileManager.CurrentProfile.ShadowsStatics && (isTree || ItemData.IsFoliage || StaticFilters.IsRock(graphic)),
                depth
            );

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

            return(true);
        }
Example #3
0
        private void AddTileToRenderList(GameObject obj, int worldX, int worldY, bool useObjectHandles, int maxZ)
        {
            for (; obj != null; obj = obj.Right)
            {
                if (obj.CurrentRenderIndex == _renderIndex || obj.IsDisposed)
                {
                    continue;
                }

                if (_updateDrawPosition && obj.CurrentRenderIndex != _renderIndex || obj.IsPositionChanged)
                {
                    obj.UpdateRealScreenPosition(_offset);
                }

                //obj.UseInRender = 0xFF;

                float drawX = obj.RealScreenPosition.X;
                float drawY = obj.RealScreenPosition.Y;

                if (drawX < _minPixel.X || drawX > _maxPixel.X)
                {
                    break;
                }

                int z          = obj.Z;
                int maxObjectZ = obj.PriorityZ;

                bool mounted  = false;
                bool ismobile = false;

                StaticTiles itemData     = default;
                bool        changinAlpha = false;

                switch (obj)
                {
                case Mobile mob:
                    maxObjectZ += Constants.DEFAULT_CHARACTER_HEIGHT;
                    ismobile    = true;
                    mounted     = mob.IsMounted;
                    break;

                default:

                    if (GameObjectHelper.TryGetStaticData(obj, out itemData))
                    {
                        if (obj is Static st)
                        {
                            if (StaticFilters.IsCave(st.OriginalGraphic))
                            {
                                if (Engine.Profile.Current.EnableCaveBorder && !st.IsBordered())
                                {
                                    st.SetBorder(true);
                                }
                                else if (!Engine.Profile.Current.EnableCaveBorder && st.IsBordered())
                                {
                                    st.SetBorder(false);
                                }
                            }
                            else if (StaticFilters.IsTree(st.OriginalGraphic))
                            {
                                if (Engine.Profile.Current.TreeToStumps && st.Graphic != Constants.TREE_REPLACE_GRAPHIC)
                                {
                                    st.SetGraphic(Constants.TREE_REPLACE_GRAPHIC);
                                }
                                else if (st.OriginalGraphic != st.Graphic && !Engine.Profile.Current.TreeToStumps)
                                {
                                    st.RestoreOriginalGraphic();
                                }
                            }
                        }

                        if (_noDrawRoofs && itemData.IsRoof)
                        {
                            if (_alphaChanged)
                            {
                                changinAlpha = obj.ProcessAlpha(0);
                            }
                            else
                            {
                                changinAlpha = obj.AlphaHue != 0;
                            }


                            if (!changinAlpha)
                            {
                                continue;
                            }
                        }

                        if ((Engine.Profile.Current.TreeToStumps && itemData.IsFoliage) || (Engine.Profile.Current.HideVegetation && StaticFilters.IsVegetation(obj.Graphic)))
                        {
                            continue;
                        }

                        maxObjectZ += itemData.Height;
                    }
                    break;
                }

                if (maxObjectZ > maxZ)
                {
                    break;
                }

                obj.CurrentRenderIndex = _renderIndex;

                bool iscorpse = !ismobile && obj is Item item && item.IsCorpse;

                if (!ismobile && !iscorpse && itemData.IsInternal)
                {
                    continue;
                }

                bool island = !ismobile && !iscorpse && obj is Land;

                if (!island && z >= _maxZ)
                {
                    if (!changinAlpha)
                    {
                        if (_alphaChanged)
                        {
                            changinAlpha = obj.ProcessAlpha(0);
                        }
                        else
                        {
                            changinAlpha = obj.AlphaHue != 0;
                        }

                        if (!changinAlpha)
                        {
                            continue;
                        }
                    }
                }

                int testMinZ = (int)drawY + z * 4;
                int testMaxZ = (int)drawY;

                if (island)
                {
                    Land t = obj as Land;
                    if (t.IsStretched)
                    {
                        testMinZ -= t.MinZ * 4;
                    }
                    else
                    {
                        testMinZ = testMaxZ;
                    }
                }
                else
                {
                    testMinZ = testMaxZ;
                }

                if (testMinZ < _minPixel.Y || testMaxZ > _maxPixel.Y)
                {
                    continue;
                }


                if (obj.Overheads != null && obj.Overheads.Count != 0)
                {
                    int offY;

                    if (ismobile && !mounted || iscorpse)
                    {
                        offY = -22;
                    }
                    else
                    {
                        switch (obj)
                        {
                        case Multi _:
                        case Static _: offY = -44;

                            break;
                        //case Item _:
                        //    offY = 44;

                        //break;
                        default: offY = 0;

                            break;
                        }
                    }

                    for (int i = 0; i < obj.Overheads.Count; i++)
                    {
                        TextOverhead v = obj.Overheads[i];
                        v.Bounds.X      = (v.Texture.Width >> 1) - 22;
                        v.Bounds.Y      = offY + v.Texture.Height;
                        v.Bounds.Width  = v.Texture.Width;
                        v.Bounds.Height = v.Texture.Height;
                        Overheads.AddOverhead(v);
                        offY += v.Texture.Height;

                        if (_alphaChanged)
                        {
                            if (v.TimeToLive > 0 && v.TimeToLive <= Constants.TIME_FADEOUT_TEXT)
                            {
                                if (!v.IsOverlapped)
                                {
                                    v.ProcessAlpha(0);
                                }
                            }
                            else if (!v.IsOverlapped && v.AlphaHue != 0xFF)
                            {
                                v.ProcessAlpha(0xFF);
                            }
                        }
                    }
                }


                if (ismobile || iscorpse)
                {
                    AddOffsetCharacterTileToRenderList(obj, useObjectHandles);
                }
                else if (itemData.IsFoliage)
                {
                    if (obj is Static st)
                    {
                        bool check = World.Player.X <= worldX && World.Player.Y <= worldY;

                        if (!check)
                        {
                            check = World.Player.Y <= worldY && World.Player.Position.X <= worldX + 1;

                            if (!check)
                            {
                                check = World.Player.X <= worldX && World.Player.Y <= worldY + 1;
                            }
                        }

                        if (check)
                        {
                            Rectangle rect = new Rectangle((int)drawX - st.FrameInfo.X,
                                                           (int)drawY - st.FrameInfo.Y,
                                                           st.FrameInfo.Width,
                                                           st.FrameInfo.Height);


                            check = rect.InRect(World.Player.GetOnScreenRectangle());
                        }

                        st.CharacterIsBehindFoliage = check;
                    }
                    else if (obj is Multi m)
                    {
                        bool check = World.Player.X <= worldX && World.Player.Y <= worldY;

                        if (!check)
                        {
                            check = World.Player.Y <= worldY && World.Player.Position.X <= worldX + 1;

                            if (!check)
                            {
                                check = World.Player.X <= worldX && World.Player.Y <= worldY + 1;
                            }
                        }

                        if (check)
                        {
                            Rectangle rect = new Rectangle((int)drawX - m.FrameInfo.X,
                                                           (int)drawY - m.FrameInfo.Y,
                                                           m.FrameInfo.Width,
                                                           m.FrameInfo.Height);


                            check = rect.InRect(World.Player.GetOnScreenRectangle());
                        }

                        m.CharacterIsBehindFoliage = check;
                    }
                }

                if (_alphaChanged && !changinAlpha)
                {
                    if (itemData.IsTranslucent)
                    {
                        obj.ProcessAlpha(178);
                    }
                    else if (!itemData.IsFoliage && obj.AlphaHue != 0xFF)
                    {
                        obj.ProcessAlpha(0xFF);
                    }
                }

                if (_renderListCount >= _renderList.Length)
                {
                    int newsize = _renderList.Length + 1000;
                    Array.Resize(ref _renderList, newsize);
                }

                if (useObjectHandles)
                {
                    obj.UseObjectHandles = (ismobile || iscorpse || obj is Item it && !it.IsLocked && !it.IsMulti) && !obj.ClosedObjectHandles;
                    _objectHandlesCount++;
                }
                else if (obj.ClosedObjectHandles)
                {
                    obj.ClosedObjectHandles = false;
                    obj.ObjectHandlesOpened = false;
                }
                else if (obj.UseObjectHandles)
                {
                    obj.ObjectHandlesOpened = false;
                    obj.UseObjectHandles    = false;
                }


                _renderList[_renderListCount] = obj;
                //obj.UseInRender = (byte) _renderIndex;
                _renderListCount++;
            }
        }
        private void AddTileToRenderList(GameObject obj, int worldX, int worldY, bool useObjectHandles, int maxZ)
        {
            for (; obj != null; obj = obj.Right)
            {
                if (obj.CurrentRenderIndex == _renderIndex || obj.IsDisposed)
                {
                    continue;
                }

                if (_updateDrawPosition && obj.CurrentRenderIndex != _renderIndex || obj.IsPositionChanged)
                {
                    obj.UpdateRealScreenPosition(_offset);
                }

                //obj.UseInRender = 0xFF;

                float drawX = obj.RealScreenPosition.X;
                float drawY = obj.RealScreenPosition.Y;

                if (drawX < _minPixel.X || drawX > _maxPixel.X)
                {
                    break;
                }

                int z          = obj.Z;
                int maxObjectZ = obj.PriorityZ;

                bool ismobile = false;

                StaticTiles itemData = default;

                switch (obj)
                {
                case Mobile _:
                    maxObjectZ += Constants.DEFAULT_CHARACTER_HEIGHT;
                    ismobile    = true;

                    break;

                default:

                    if (GameObjectHelper.TryGetStaticData(obj, out itemData))
                    {
                        if (obj is Static st)
                        {
                            if (StaticFilters.IsTree(st.OriginalGraphic))
                            {
                                if (Engine.Profile.Current.TreeToStumps && st.Graphic != Constants.TREE_REPLACE_GRAPHIC)
                                {
                                    st.SetGraphic(Constants.TREE_REPLACE_GRAPHIC);
                                }
                                else if (st.OriginalGraphic != st.Graphic && !Engine.Profile.Current.TreeToStumps)
                                {
                                    st.RestoreOriginalGraphic();
                                }
                            }
                        }

                        if (_noDrawRoofs && itemData.IsRoof || (Engine.Profile.Current.TreeToStumps && itemData.IsFoliage) || (Engine.Profile.Current.HideVegetation && StaticFilters.IsVegetation(obj.Graphic)))
                        {
                            continue;
                        }
                        maxObjectZ += itemData.Height;
                    }
                    break;
                }

                if (maxObjectZ > maxZ)
                {
                    break;
                }

                obj.CurrentRenderIndex = _renderIndex;

                bool iscorpse = !ismobile && obj is Item item && item.IsCorpse;

                if (!ismobile && !iscorpse && itemData.IsInternal)
                {
                    continue;
                }

                bool island = !ismobile && !iscorpse && obj is Land;

                if (!island && z >= _maxZ)
                {
                    continue;
                }

                int testMinZ = (int)drawY + z * 4;
                int testMaxZ = (int)drawY;

                if (island)
                {
                    Land t = obj as Land;
                    if (t.IsStretched)
                    {
                        testMinZ -= t.MinZ * 4;
                    }
                    else
                    {
                        testMinZ = testMaxZ;
                    }
                }
                else
                {
                    testMinZ = testMaxZ;
                }

                if (testMinZ < _minPixel.Y || testMaxZ > _maxPixel.Y)
                {
                    continue;
                }

                if (ismobile || iscorpse)
                {
                    AddOffsetCharacterTileToRenderList(obj, useObjectHandles);
                }


                if (_renderListCount >= _renderList.Length)
                {
                    int newsize = _renderList.Length + 1000;
                    Array.Resize(ref _renderList, newsize);
                }

                _renderList[_renderListCount] = obj;
                //obj.UseInRender = (byte) _renderIndex;
                _renderListCount++;
            }
        }
Example #5
0
        public override bool Draw(UltimaBatcher2D batcher, int posX, int posY)
        {
            if (!AllowedToDraw || IsDestroyed)
            {
                return(false);
            }

            ushort graphic = Graphic;
            ushort hue     = Hue;
            bool   partial = ItemData.IsPartialHue;

            ResetHueVector();

            if (ProfileManager.CurrentProfile.HighlightGameObjects && SelectedObject.LastObject == this)
            {
                hue     = Constants.HIGHLIGHT_CURRENT_OBJECT_HUE;
                partial = false;
            }
            else if (ProfileManager.CurrentProfile.NoColorObjectsOutOfRange && Distance > World.ClientViewRange)
            {
                hue     = Constants.OUT_RANGE_COLOR;
                partial = false;
            }
            else if (World.Player.IsDead && ProfileManager.CurrentProfile.EnableBlackWhiteEffect)
            {
                hue     = Constants.DEAD_RANGE_COLOR;
                partial = false;
            }

            ShaderHueTranslator.GetHueVector(ref HueVector, hue, partial, 0);

            //Engine.DebugInfo.StaticsRendered++;

            //if ((StaticFilters.IsTree(Graphic) || ItemData.IsFoliage || StaticFilters.IsRock(Graphic)))
            //{
            //    batcher.DrawSpriteShadow(Texture, posX - Bounds.X, posY - Bounds.Y /*- 10*/, false);
            //}

            if (StaticFilters.IsTree(graphic, out _))
            {
                graphic = Constants.TREE_REPLACE_GRAPHIC;
            }


            if (AlphaHue != 255)
            {
                HueVector.Z = 1f - AlphaHue / 255f;
            }

            DrawStaticAnimated(batcher, graphic, posX, posY, ref HueVector, ref DrawTransparent);

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

            if (!(SelectedObject.Object == this ||
                  FoliageIndex != -1 && Client.Game.GetScene <GameScene>().FoliageIndex == FoliageIndex))
            {
                if (DrawTransparent)
                {
                    return(true);
                }

                ref UOFileIndex index = ref ArtLoader.Instance.GetValidRefEntry(graphic + 0x4000);

                posX -= index.Width;
                posY -= index.Height;

                if (SelectedObject.IsPointInStatic(ArtLoader.Instance.GetTexture(graphic), posX, posY))
                {
                    SelectedObject.Object = this;
                }
            }
Example #6
0
        public override bool Draw(UltimaBatcher2D batcher, int posX, int posY)
        {
            if (!AllowedToDraw || IsDestroyed)
            {
                return(false);
            }

            ushort graphic = Graphic;

            ResetHueVector();

            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
            {
                ShaderHuesTraslator.GetHueVector(ref HueVector, Hue, ItemData.IsPartialHue, 0);
            }

            //Engine.DebugInfo.StaticsRendered++;

            //if ((StaticFilters.IsTree(Graphic) || ItemData.IsFoliage || StaticFilters.IsRock(Graphic)))
            //{
            //    batcher.DrawSpriteShadow(Texture, posX - Bounds.X, posY - Bounds.Y /*- 10*/, false);
            //}

            if (StaticFilters.IsTree(graphic, out _))
            {
                graphic = Constants.TREE_REPLACE_GRAPHIC;
            }

            if (DrawTransparent)
            {
                int maxDist = ProfileManager.Current.CircleOfTransparencyRadius + 44;
                int fx      = (int)(World.Player.RealScreenPosition.X + World.Player.Offset.X);
                int fy      = (int)(World.Player.RealScreenPosition.Y + (World.Player.Offset.Y - World.Player.Offset.Z));

                fx -= posX;
                fy -= posY;

                int dist = (int)Math.Sqrt(fx * fx + fy * fy);

                if (dist <= maxDist)
                {
                    switch (ProfileManager.Current.CircleOfTransparencyType)
                    {
                    default:
                    case 0:
                        HueVector.Z = 0.75f;
                        break;

                    case 1:
                        HueVector.Z = MathHelper.Lerp(1f, 0f, (dist / (float)maxDist));
                        break;
                    }

                    DrawStaticAnimated(batcher, graphic, posX, posY, ref HueVector);

                    if (AlphaHue != 255)
                    {
                        HueVector.Z = 1f - AlphaHue / 255f;
                    }
                    else
                    {
                        HueVector.Z = 0;
                    }

                    batcher.SetStencil(StaticTransparentStencil.Value);
                    DrawStaticAnimated(batcher, graphic, posX, posY, ref HueVector);
                    batcher.SetStencil(null);
                }
                else
                {
                    if (AlphaHue != 255)
                    {
                        HueVector.Z = 1f - AlphaHue / 255f;
                    }

                    DrawStaticAnimated(batcher, graphic, posX, posY, ref HueVector);
                }
            }
            else
            {
                if (AlphaHue != 255)
                {
                    HueVector.Z = 1f - AlphaHue / 255f;
                }

                DrawStaticAnimated(batcher, graphic, posX, posY, ref HueVector);
            }


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

            if (!(SelectedObject.Object == this ||
                  (FoliageIndex != -1 &&
                   Client.Game.GetScene <GameScene>().FoliageIndex == FoliageIndex)))
            {
                if (DrawTransparent)
                {
                    int d    = Distance;
                    int maxD = ProfileManager.Current.CircleOfTransparencyRadius + 1;

                    if (d <= maxD && d <= 3)
                    {
                        return(true);
                    }
                }

                ref var index = ref ArtLoader.Instance.GetValidRefEntry(graphic + 0x4000);

                posX -= index.Width;
                posY -= index.Height;

                if (SelectedObject.IsPointInStatic(ArtLoader.Instance.GetTexture(graphic), posX, posY))
                {
                    SelectedObject.Object = this;
                }
            }
        private void AddTileToRenderList(GameObject obj, int worldX, int worldY, bool useObjectHandles, int maxZ)
        {
            for (; obj != null; obj = obj.Right)
            {
                if (obj.CurrentRenderIndex == _renderIndex || obj.IsDestroyed || !obj.AllowedToDraw)
                {
                    continue;
                }

                if (_updateDrawPosition && obj.CurrentRenderIndex != _renderIndex || obj.IsPositionChanged)
                {
                    obj.UpdateRealScreenPosition(_offset);
                }

                //obj.UseInRender = 0xFF;

                float drawX = obj.RealScreenPosition.X;
                float drawY = obj.RealScreenPosition.Y;

                if (drawX < _minPixel.X || drawX > _maxPixel.X)
                {
                    break;
                }

                int z          = obj.Z;
                int maxObjectZ = obj.PriorityZ;

                bool ismobile = false;

                StaticTiles itemData     = default;
                bool        changinAlpha = false;

                switch (obj)
                {
                case Mobile _:
                    maxObjectZ += Constants.DEFAULT_CHARACTER_HEIGHT;
                    ismobile    = true;
                    break;

                default:

                    if (GameObjectHelper.TryGetStaticData(obj, out itemData))
                    {
                        if (obj is Static st)
                        {
                            if (StaticFilters.IsCave(st.OriginalGraphic))
                            {
                                if (Engine.Profile.Current.EnableCaveBorder && !st.IsBordered())
                                {
                                    st.SetBorder(true);
                                }
                                else if (!Engine.Profile.Current.EnableCaveBorder && st.IsBordered())
                                {
                                    st.SetBorder(false);
                                }
                            }
                            else if (StaticFilters.IsTree(st.OriginalGraphic))
                            {
                                if (Engine.Profile.Current.TreeToStumps && st.Graphic != Constants.TREE_REPLACE_GRAPHIC)
                                {
                                    st.SetGraphic(Constants.TREE_REPLACE_GRAPHIC);
                                }
                                else if (st.OriginalGraphic != st.Graphic && !Engine.Profile.Current.TreeToStumps)
                                {
                                    st.RestoreOriginalGraphic();
                                }
                            }
                        }

                        if (_noDrawRoofs && itemData.IsRoof)
                        {
                            if (_alphaChanged)
                            {
                                changinAlpha = obj.ProcessAlpha(0);
                            }
                            else
                            {
                                changinAlpha = obj.AlphaHue != 0;
                            }


                            if (!changinAlpha)
                            {
                                continue;
                            }
                        }

                        if ((Engine.Profile.Current.TreeToStumps && itemData.IsFoliage) || (Engine.Profile.Current.HideVegetation && StaticFilters.IsVegetation(obj.Graphic)))
                        {
                            continue;
                        }

                        maxObjectZ += itemData.Height;
                    }
                    break;
                }

                if (maxObjectZ > maxZ)
                {
                    break;
                }

                obj.CurrentRenderIndex = _renderIndex;

                bool iscorpse = !ismobile && obj is Item item && item.IsCorpse;

                if (!ismobile && !iscorpse && itemData.IsInternal)
                {
                    continue;
                }

                bool island = !ismobile && !iscorpse && obj is Land;

                if (!island && z >= _maxZ)
                {
                    if (!changinAlpha)
                    {
                        if (_alphaChanged)
                        {
                            changinAlpha = obj.ProcessAlpha(0);
                        }
                        else
                        {
                            changinAlpha = obj.AlphaHue != 0;
                        }

                        if (!changinAlpha)
                        {
                            continue;
                        }
                    }
                }

                int testMinZ = (int)drawY + z * 4;
                int testMaxZ = (int)drawY;

                if (island)
                {
                    Land t = obj as Land;
                    if (t.IsStretched)
                    {
                        testMinZ -= t.MinZ * 4;
                    }
                    else
                    {
                        testMinZ = testMaxZ;
                    }
                }
                else
                {
                    testMinZ = testMaxZ;
                }

                if (testMinZ < _minPixel.Y || testMaxZ > _maxPixel.Y)
                {
                    continue;
                }


                if (obj.OverheadMessageContainer != null && !obj.OverheadMessageContainer.IsEmpty)
                {
                    _overheadManager.AddOverhead(obj.OverheadMessageContainer);
                }

                if (ismobile || iscorpse)
                {
                    AddOffsetCharacterTileToRenderList(obj, useObjectHandles);
                }
                else if (itemData.IsFoliage)
                {
                    bool check = World.Player.X <= worldX && World.Player.Y <= worldY;

                    if (!check)
                    {
                        check = World.Player.Y <= worldY && World.Player.Position.X <= worldX + 1;

                        if (!check)
                        {
                            check = World.Player.X <= worldX && World.Player.Y <= worldY + 1;
                        }
                    }

                    if (check)
                    {
                        Rectangle rect = new Rectangle((int)drawX - obj.FrameInfo.X,
                                                       (int)drawY - obj.FrameInfo.Y,
                                                       obj.FrameInfo.Width,
                                                       obj.FrameInfo.Height);

                        Rectangle r = World.Player.GetOnScreenRectangle();
                        check = Exstentions.InRect(ref rect, ref r);
                    }

                    if (obj is Static st)
                    {
                        st.CharacterIsBehindFoliage = check;
                    }
                    else if (obj is Multi m)
                    {
                        m.CharacterIsBehindFoliage = check;
                    }
                    else if (obj is Item it)
                    {
                        it.CharacterIsBehindFoliage = check;
                    }
                }

                if (_alphaChanged && !changinAlpha)
                {
                    if (itemData.IsTranslucent)
                    {
                        obj.ProcessAlpha(178);
                    }
                    else if (!itemData.IsFoliage && obj.AlphaHue != 0xFF)
                    {
                        obj.ProcessAlpha(0xFF);
                    }
                }

                if (_renderListCount >= _renderList.Length)
                {
                    int newsize = _renderList.Length + 1000;
                    //_renderList.Resize(newsize);
                    Array.Resize(ref _renderList, newsize);
                }

                if (useObjectHandles)
                {
                    obj.UseObjectHandles = (ismobile || iscorpse || obj is Item it && !it.IsLocked && !it.IsMulti) && !obj.ClosedObjectHandles;
                    _objectHandlesCount++;
                }
                else if (obj.ClosedObjectHandles)
                {
                    obj.ClosedObjectHandles = false;
                    obj.ObjectHandlesOpened = false;
                }
                else if (obj.UseObjectHandles)
                {
                    obj.ObjectHandlesOpened = false;
                    obj.UseObjectHandles    = false;
                }


                //ref var weak = ref _renderList[_renderListCount];

                //if (weak == null)
                //    weak = new WeakReference<GameObject>(obj);
                //else
                //    weak.SetTarget(obj);

                _renderList[_renderListCount] = obj;
                //_renderList.Enqueue(obj);
                //obj.UseInRender = (byte) _renderIndex;
                _renderListCount++;
            }
        }
Example #8
0
        public override bool Draw(UltimaBatcher2D batcher, int posX, int posY, ref Vector3 hueVec)
        {
            if (!AllowedToDraw || IsDestroyed)
            {
                return(false);
            }

            ushort graphic = Graphic;
            ushort hue     = Hue;
            bool   partial = ItemData.IsPartialHue;

            hueVec = Vector3.Zero;

            if (ProfileManager.CurrentProfile.HighlightGameObjects && SelectedObject.LastObject == this)
            {
                hue     = Constants.HIGHLIGHT_CURRENT_OBJECT_HUE;
                partial = false;
            }
            else if (ProfileManager.CurrentProfile.NoColorObjectsOutOfRange && Distance > World.ClientViewRange)
            {
                hue     = Constants.OUT_RANGE_COLOR;
                partial = false;
            }
            else if (World.Player.IsDead && ProfileManager.CurrentProfile.EnableBlackWhiteEffect)
            {
                hue     = Constants.DEAD_RANGE_COLOR;
                partial = false;
            }

            ShaderHueTranslator.GetHueVector(ref hueVec, hue, partial, 0);

            bool isTree = StaticFilters.IsTree(graphic, out _);

            if (isTree && ProfileManager.CurrentProfile.TreeToStumps)
            {
                graphic = Constants.TREE_REPLACE_GRAPHIC;
            }

            if (AlphaHue != 255)
            {
                hueVec.Z = 1f - AlphaHue / 255f;
            }

            DrawStaticAnimated
            (
                batcher,
                graphic,
                posX,
                posY,
                ref hueVec,
                ref DrawTransparent,
                ProfileManager.CurrentProfile.ShadowsEnabled && ProfileManager.CurrentProfile.ShadowsStatics && (isTree || ItemData.IsFoliage || StaticFilters.IsRock(graphic))
            );

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

            if (!(SelectedObject.Object == this || FoliageIndex != -1 && Client.Game.GetScene <GameScene>().FoliageIndex == FoliageIndex))
            {
                if (DrawTransparent)
                {
                    return(true);
                }

                ref UOFileIndex index = ref ArtLoader.Instance.GetValidRefEntry(graphic + 0x4000);

                posX -= index.Width;
                posY -= index.Height;

                if (ArtLoader.Instance.PixelCheck
                    (
                        graphic,
                        SelectedObject.TranslatedMousePositionByViewport.X - posX,
                        SelectedObject.TranslatedMousePositionByViewport.Y - posY
                    ))
                {
                    SelectedObject.Object = this;
                }
            }
Example #9
0
        private void AddTileToRenderList(GameObject obj, int worldX, int worldY, bool useObjectHandles, int maxZ /*, GameObject entity*/)
        {
            /*sbyte HeightChecks = 0;
             * if(entity != null)
             * {
             *  if(entity.X < worldX && entity.Y > worldY)
             *  {
             *      HeightChecks = 1;
             *  }
             *  else if (entity.Y < worldY && entity.X > worldX)
             *  {
             *      HeightChecks = -1;
             *  }
             * }*/

            for (; obj != null; obj = obj.Right)
            {
                if (obj.CurrentRenderIndex == _renderIndex || !obj.AllowedToDraw)
                {
                    continue;
                }

                if (UpdateDrawPosition && obj.CurrentRenderIndex != _renderIndex || obj.IsPositionChanged)
                {
                    obj.UpdateRealScreenPosition(_offset.X, _offset.Y);
                }

                obj.UseInRender = 0xFF;

                int drawX = obj.RealScreenPosition.X;
                int drawY = obj.RealScreenPosition.Y;

                if (drawX < _minPixel.X || drawX > _maxPixel.X)
                {
                    break;
                }

                int maxObjectZ = obj.PriorityZ;


                StaticTiles itemData = _emptyStaticTiles;

                bool changinAlpha = false;
                bool island       = false;
                bool iscorpse     = false;
                bool ismobile     = false;

                switch (obj)
                {
                case Mobile _:
                    maxObjectZ += Constants.DEFAULT_CHARACTER_HEIGHT;
                    ismobile    = true;

                    break;

                case Land _:
                    island = true;
                    goto SKIP_HANDLES_CHECK;

                case Item it when it.IsCorpse:
                    iscorpse = true;
                    goto default;

                default:

                    if (GameObjectHelper.TryGetStaticData(obj, out itemData))
                    {
                        if (itemData.IsFoliage && World.Season >= Seasons.Winter)
                        {
                            continue;
                        }

                        if (obj is Static st)
                        {
                            if (StaticFilters.IsTree(st.OriginalGraphic))
                            {
                                if (Engine.Profile.Current.TreeToStumps && st.Graphic != Constants.TREE_REPLACE_GRAPHIC)
                                {
                                    st.SetGraphic(Constants.TREE_REPLACE_GRAPHIC);
                                }
                                else if (st.OriginalGraphic != st.Graphic && !Engine.Profile.Current.TreeToStumps)
                                {
                                    st.RestoreOriginalGraphic();
                                }
                            }
                        }

                        if (_noDrawRoofs && itemData.IsRoof)
                        {
                            if (_alphaChanged)
                            {
                                changinAlpha = obj.ProcessAlpha(0);
                            }
                            else
                            {
                                changinAlpha = obj.AlphaHue != 0;
                            }

                            if (!changinAlpha)
                            {
                                continue;
                            }
                        }

                        if (Engine.Profile.Current.TreeToStumps && itemData.IsFoliage || Engine.Profile.Current.HideVegetation && StaticFilters.IsVegetation(obj.Graphic))
                        {
                            continue;
                        }

                        //if (HeightChecks <= 0 && (!itemData.IsBridge || ((itemData.Flags & TileFlag.StairBack | TileFlag.StairRight) != 0) || itemData.IsWall))
                        {
                            maxObjectZ += itemData.Height;
                        }
                    }

                    break;
                }


                if (useObjectHandles && NameOverHeadManager.IsAllowed(obj as Entity))
                {
                    obj.UseObjectHandles = (ismobile ||
                                            iscorpse ||
                                            obj is Item it && (!it.IsLocked || it.IsLocked && itemData.IsContainer) && !it.IsMulti) &&
                                           !obj.ClosedObjectHandles && _objectHandlesCount <= 400;
                    if (obj.UseObjectHandles)
                    {
                        _objectHandlesCount++;
                    }
                }
                else if (obj.ClosedObjectHandles)
                {
                    obj.ClosedObjectHandles = false;
                    obj.ObjectHandlesOpened = false;
                }
                else if (obj.UseObjectHandles)
                {
                    obj.ObjectHandlesOpened = false;
                    obj.UseObjectHandles    = false;
                }


SKIP_HANDLES_CHECK:

                if (maxObjectZ > maxZ)
                {
                    break;
                }

                obj.CurrentRenderIndex = _renderIndex;

                if (!island)
                {
                    obj.UpdateTextCoords();
                }
                else
                {
                    goto SKIP_INTERNAL_CHECK;
                }

                if (!ismobile && !iscorpse && !island && itemData.IsInternal)
                {
                    continue;
                }

SKIP_INTERNAL_CHECK:

                int z = obj.Z;

                if (!island && z >= _maxZ)
                {
                    if (!changinAlpha)
                    {
                        if (_alphaChanged)
                        {
                            changinAlpha = obj.ProcessAlpha(0);
                        }
                        else
                        {
                            changinAlpha = obj.AlphaHue != 0;
                        }

                        if (!changinAlpha)
                        {
                            obj.UseInRender = (byte)_renderIndex;
                            continue;
                        }
                    }
                }

                int testMaxZ = drawY;

                if (testMaxZ > _maxPixel.Y)
                {
                    continue;
                }

                int testMinZ = drawY + (z << 2);

                if (island)
                {
                    Land t = obj as Land;

                    if (t.IsStretched)
                    {
                        testMinZ -= t.MinZ << 2;
                    }
                    else
                    {
                        testMinZ = testMaxZ;
                    }
                }
                else
                {
                    testMinZ = testMaxZ;
                }

                if (testMinZ < _minPixel.Y)
                {
                    continue;
                }

                if (ismobile || iscorpse)
                {
                    AddOffsetCharacterTileToRenderList(obj, useObjectHandles);
                }
                else if (!island && itemData.IsFoliage)
                {
                    bool check = World.Player.X <= worldX && World.Player.Y <= worldY;

                    if (!check)
                    {
                        check = World.Player.Y <= worldY && World.Player.X <= worldX + 1;

                        if (!check)
                        {
                            check = World.Player.X <= worldX && World.Player.Y <= worldY + 1;
                        }
                    }

                    if (check)
                    {
                        _rectangleObj.X      = drawX - obj.FrameInfo.X;
                        _rectangleObj.Y      = drawY - obj.FrameInfo.Y;
                        _rectangleObj.Width  = obj.FrameInfo.Width;
                        _rectangleObj.Height = obj.FrameInfo.Height;

                        check = Exstentions.InRect(ref _rectangleObj, ref _rectanglePlayer);
                    }

                    switch (obj)
                    {
                    case Static st:
                        st.CharacterIsBehindFoliage = check;

                        break;

                    case Multi m:
                        m.CharacterIsBehindFoliage = check;

                        break;

                    case Item it:
                        it.CharacterIsBehindFoliage = check;

                        break;
                    }
                }

                if (!island && _alphaChanged && !changinAlpha)
                {
                    if (itemData.IsTranslucent)
                    {
                        obj.ProcessAlpha(178);
                    }
                    else if (!itemData.IsFoliage && obj.AlphaHue != 0xFF)
                    {
                        obj.ProcessAlpha(0xFF);
                    }
                }

                if (_renderListCount >= _renderList.Length)
                {
                    int newsize = _renderList.Length + 1000;
                    Array.Resize(ref _renderList, newsize);
                }

                _renderList[_renderListCount++] = obj;
                obj.UseInRender = (byte)_renderIndex;
            }
        }
Example #10
0
        public override bool Draw(UltimaBatcher2D batcher, int posX, int posY)
        {
            if (!AllowedToDraw || IsDestroyed)
            {
                return(false);
            }

            ushort graphic = Graphic;
            ushort hue     = Hue;
            bool   partial = ItemData.IsPartialHue;

            ResetHueVector();

            if (ProfileManager.CurrentProfile.HighlightGameObjects && SelectedObject.LastObject == this)
            {
                hue     = Constants.HIGHLIGHT_CURRENT_OBJECT_HUE;
                partial = false;
            }
            else if (ProfileManager.CurrentProfile.NoColorObjectsOutOfRange && Distance > World.ClientViewRange)
            {
                hue     = Constants.OUT_RANGE_COLOR;
                partial = false;
            }
            else if (World.Player.IsDead && ProfileManager.CurrentProfile.EnableBlackWhiteEffect)
            {
                hue     = Constants.DEAD_RANGE_COLOR;
                partial = false;
            }

            ShaderHueTranslator.GetHueVector(ref HueVector, hue, partial, 0);

            // ## BEGIN - END ## //
            if (ProfileManager.CurrentProfile.HighlightTileAtRange && Distance == ProfileManager.CurrentProfile.HighlightTileAtRangeRange)
            {
                HueVector.X = ProfileManager.CurrentProfile.HighlightTileRangeHue;
                HueVector.Y = 1;
            }
            if (ProfileManager.CurrentProfile.HighlightTileAtRangeSpell)
            {
                if (GameCursor._spellTime >= 1 && Distance == ProfileManager.CurrentProfile.HighlightTileAtRangeRangeSpell)
                {
                    HueVector.X = ProfileManager.CurrentProfile.HighlightTileRangeHueSpell;
                    HueVector.Y = 1;
                }
            }
            if (ProfileManager.CurrentProfile.PreviewFields)
            {
                if (UOClassicCombatCollection.StaticFieldPreview(this))
                {
                    HueVector.X = 0x0040;
                    HueVector.Y = 1;
                }
                if (SelectedObject.LastObject == this)
                {
                    HueVector.X = 0x0023;
                    HueVector.Y = 1;
                }
            }
            // ## BEGIN - END ## //
            // ## BEGIN - END ## // ORIG

            /*
             * bool isTree = StaticFilters.IsTree(graphic, out _);
             *
             * if (isTree && ProfileManager.CurrentProfile.TreeToStumps)
             * {
             *  graphic = Constants.TREE_REPLACE_GRAPHIC;
             * }
             */
            // ## BEGIN - END ## // ORIG
            graphic = UOClassicCombatCollection.ArtloaderFilters(graphic);

            bool isTree = StaticFilters.IsTree(graphic, out _);

            // ## BEGIN - END ## //

            if (AlphaHue != 255)
            {
                HueVector.Z = 1f - AlphaHue / 255f;
            }

            DrawStaticAnimated(batcher, graphic, posX, posY, ref HueVector, ref DrawTransparent, ProfileManager.CurrentProfile.ShadowsEnabled && ProfileManager.CurrentProfile.ShadowsStatics && (isTree || ItemData.IsFoliage || StaticFilters.IsRock(graphic)));

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

            if (!(SelectedObject.Object == this ||
                  FoliageIndex != -1 && Client.Game.GetScene <GameScene>().FoliageIndex == FoliageIndex))
            {
                if (DrawTransparent)
                {
                    return(true);
                }

                ref UOFileIndex index = ref ArtLoader.Instance.GetValidRefEntry(graphic + 0x4000);

                posX -= index.Width;
                posY -= index.Height;

                if (SelectedObject.IsPointInStatic(ArtLoader.Instance.GetTexture(graphic), posX, posY))
                {
                    SelectedObject.Object = this;
                }
            }