Exemple #1
0
        public override void Render()
        {
            try
            {
                if (!Settings.Enable.Value || !GameController.InGame || Settings.DrawOnlyOnLargeMap && !largeMap)
                {
                    return;
                }

                if (ingameStateIngameUi.AtlasPanel.IsVisibleLocal || ingameStateIngameUi.DelveWindow.IsVisibleLocal ||
                    ingameStateIngameUi.TreePanel.IsVisibleLocal)
                {
                    return;
                }

                var playerPos             = GameController.Player.GetComponent <Positioned>().GridPos;
                var posZ                  = GameController.Player.GetComponent <Render>().Pos.Z;
                var mapWindowLargeMapZoom = mapWindow.LargeMapZoom;

                var baseIcons = GameController.EntityListWrapper.OnlyValidEntities
                                .SelectWhereF(x => x.GetHudComponent <BaseIcon>(), icon => icon != null).OrderByF(x => x.Priority)
                                .ToList();

                foreach (var icon in baseIcons)
                {
                    if (icon.Entity.Type == EntityType.WorldItem)
                    {
                        continue;
                    }

                    if (!Settings.DrawMonsters && icon.Entity.Type == EntityType.Monster)
                    {
                        continue;
                    }

                    if (icon.HasIngameIcon)
                    {
                        continue;
                    }

                    if (!icon.Show())
                    {
                        continue;
                    }

                    var component = icon?.Entity?.GetComponent <Render>();
                    if (component == null)
                    {
                        continue;
                    }
                    var     iconZ = component.Pos.Z;
                    Vector2 position;

                    if (largeMap)
                    {
                        position = screentCenterCache + MapIcon.DeltaInWorldToMinimapDelta(
                            icon.GridPosition() - playerPos, diag, scale, (iconZ - posZ) / (9f / mapWindowLargeMapZoom));
                    }
                    else
                    {
                        position = screentCenterCache +
                                   MapIcon.DeltaInWorldToMinimapDelta(icon.GridPosition() - playerPos, diag, 240f, (iconZ - posZ) / 20);
                    }

                    HudTexture iconValueMainTexture;
                    iconValueMainTexture = icon.MainTexture;
                    var size     = iconValueMainTexture.Size;
                    var halfSize = size / 2f;
                    icon.DrawRect = new RectangleF(position.X - halfSize, position.Y - halfSize, size, size);
                    Graphics.DrawImage(iconValueMainTexture.FileName, icon.DrawRect, iconValueMainTexture.UV, iconValueMainTexture.Color);

                    if (icon.Hidden())
                    {
                        var s = icon.DrawRect.Width * 0.5f;
                        icon.DrawRect.Inflate(-s, -s);

                        Graphics.DrawImage(icon.MainTexture.FileName, icon.DrawRect,
                                           SpriteHelper.GetUV(MapIconsIndex.LootFilterSmallCyanCircle), Color.White);

                        icon.DrawRect.Inflate(s, s);
                    }

                    if (!string.IsNullOrEmpty(icon.Text))
                    {
                        Graphics.DrawText(icon.Text, position.Translate(0, Settings.ZForText), FontAlign.Center);
                    }
                }

                if (Settings.DrawNotValid)
                {
                    for (var index = 0; index < GameController.EntityListWrapper.NotOnlyValidEntities.Count; index++)
                    {
                        var entity = GameController.EntityListWrapper.NotOnlyValidEntities[index];
                        if (entity.Type == EntityType.WorldItem)
                        {
                            continue;
                        }
                        var icon = entity.GetHudComponent <BaseIcon>();

                        if (icon != null && !entity.IsValid && icon.Show())
                        {
                            if (icon.Entity.Type == EntityType.WorldItem)
                            {
                                continue;
                            }

                            if (!Settings.DrawMonsters && icon.Entity.Type == EntityType.Monster)
                            {
                                continue;
                            }

                            if (icon.HasIngameIcon)
                            {
                                continue;
                            }

                            if (!icon.Show())
                            {
                                continue;
                            }

                            var     iconZ = icon.Entity.Pos.Z;
                            Vector2 position;

                            if (largeMap)
                            {
                                position = screentCenterCache + MapIcon.DeltaInWorldToMinimapDelta(
                                    icon.GridPosition() - playerPos, diag, scale, (iconZ - posZ) / (9f / mapWindowLargeMapZoom));
                            }
                            else
                            {
                                position = screentCenterCache +
                                           MapIcon.DeltaInWorldToMinimapDelta(icon.GridPosition() - playerPos, diag, 240f, (iconZ - posZ) / 20);
                            }

                            HudTexture iconValueMainTexture;
                            iconValueMainTexture = icon.MainTexture;
                            var size     = iconValueMainTexture.Size;
                            var halfSize = size / 2f;
                            icon.DrawRect = new RectangleF(position.X - halfSize, position.Y - halfSize, size, size);
                            Graphics.DrawImage(iconValueMainTexture.FileName, icon.DrawRect, iconValueMainTexture.UV, iconValueMainTexture.Color);

                            if (icon.Hidden())
                            {
                                var s = icon.DrawRect.Width * 0.5f;
                                icon.DrawRect.Inflate(-s, -s);

                                Graphics.DrawImage(icon.MainTexture.FileName, icon.DrawRect,
                                                   SpriteHelper.GetUV(MapIconsIndex.LootFilterSmallCyanCircle), Color.White);

                                icon.DrawRect.Inflate(s, s);
                            }

                            if (!string.IsNullOrEmpty(icon.Text))
                            {
                                Graphics.DrawText(icon.Text, position.Translate(0, Settings.ZForText), FontAlign.Center);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                DebugWindow.LogError($"MinimapIcons.TickLogic: {e.Message}");
            }
        }
Exemple #2
0
        public override void Render()
        {
            if (!Settings.Enable.Value || !GameController.InGame || Settings.DrawOnlyOnLargeMap && !largeMap)
            {
                return;
            }

            if (ingameStateIngameUi.Atlas.IsVisibleLocal || ingameStateIngameUi.DelveWindow.IsVisibleLocal || ingameStateIngameUi.TreePanel.IsVisibleLocal)
            {
                return;
            }

            var playerPositioned = GameController?.Player?.GetComponent <Positioned>();

            if (playerPositioned == null)
            {
                return;
            }
            Vector2 playerPos    = playerPositioned.GridPos;
            var     playerRender = GameController?.Player?.GetComponent <Render>();

            if (playerRender == null)
            {
                return;
            }
            float posZ = playerRender.Pos.Z;

            if (MapWindow == null)
            {
                return;
            }
            var mapWindowLargeMapZoom = MapWindow.LargeMapZoom;

            var baseIcons = GameController?.EntityListWrapper?.OnlyValidEntities
                            .SelectWhereF(x => x.GetHudComponent <BaseIcon>(), icon => icon != null).OrderByF(x => x.Priority)
                            .ToList();

            if (baseIcons == null)
            {
                return;
            }

            foreach (var icon in baseIcons)
            {
                if (icon == null)
                {
                    continue;
                }
                if (icon.Entity == null)
                {
                    continue;
                }

                if (icon.Entity.Type == EntityType.WorldItem)
                {
                    continue;
                }

                if (!Settings.DrawMonsters && icon.Entity.Type == EntityType.Monster)
                {
                    continue;
                }

                if (Ignored.Any(x => icon.Entity.Path.StartsWith(x)))
                {
                    continue;
                }

                if (icon.Entity.Path.StartsWith(
                        "Metadata/Monsters/AtlasExiles/BasiliskInfluenceMonsters/BasiliskBurrowingViper") &&
                    (icon.Entity.Rarity != MonsterRarity.Unique))
                {
                    continue;
                }

                if (icon.HasIngameIcon && !icon.Entity.Path.Contains("Metadata/Terrain/Leagues/Delve/Objects/DelveWall"))
                {
                    continue;
                }

                if (!icon.Show())
                {
                    continue;
                }

                var component = icon?.Entity?.GetComponent <Render>();
                if (component == null)
                {
                    continue;
                }
                var iconZ = component.Pos.Z;

                Vector2 position;

                if (largeMap)
                {
                    position = screentCenterCache + MapIcon.DeltaInWorldToMinimapDelta(
                        icon.GridPosition() - playerPos, Diag, scale, (iconZ - posZ) / (9f / mapWindowLargeMapZoom));
                }
                else
                {
                    position = screentCenterCache +
                               MapIcon.DeltaInWorldToMinimapDelta(icon.GridPosition() - playerPos, Diag, 240f, (iconZ - posZ) / 20);
                }

                HudTexture iconValueMainTexture;
                iconValueMainTexture = icon.MainTexture;
                var size     = iconValueMainTexture.Size;
                var halfSize = size / 2f;
                icon.DrawRect = new RectangleF(position.X - halfSize, position.Y - halfSize, size, size);
                Graphics.DrawImage(iconValueMainTexture.FileName, icon.DrawRect, iconValueMainTexture.UV, iconValueMainTexture.Color);

                if (icon.Hidden())
                {
                    var s = icon.DrawRect.Width * 0.5f;
                    icon.DrawRect.Inflate(-s, -s);

                    Graphics.DrawImage(icon.MainTexture.FileName, icon.DrawRect,
                                       SpriteHelper.GetUV(MapIconsIndex.LootFilterSmallCyanCircle), Color.White);

                    icon.DrawRect.Inflate(s, s);
                }

                if (!string.IsNullOrEmpty(icon.Text))
                {
                    Graphics.DrawText(icon.Text, position.Translate(0, Settings.ZForText), FontAlign.Center);
                }
            }

            if (Settings.DrawNotValid)
            {
                for (var index = 0; index < GameController.EntityListWrapper.NotOnlyValidEntities.Count; index++)
                {
                    var entity = GameController.EntityListWrapper.NotOnlyValidEntities[index];
                    if (entity.Type == EntityType.WorldItem)
                    {
                        continue;
                    }
                    var icon = entity.GetHudComponent <BaseIcon>();

                    if (icon != null && !entity.IsValid && icon.Show())
                    {
                        if (icon.Entity.Type == EntityType.WorldItem)
                        {
                            continue;
                        }

                        if (!Settings.DrawMonsters && icon.Entity.Type == EntityType.Monster)
                        {
                            continue;
                        }

                        if (icon.HasIngameIcon && icon.Entity.Type != EntityType.Monster && icon.Entity.League != LeagueType.Heist)
                        {
                            continue;
                        }

                        if (icon.HasIngameIcon && !icon.Entity.Path.Contains("Metadata/Terrain/Leagues/Delve/Objects/DelveWall"))
                        {
                            continue;
                        }

                        if (!icon.Show())
                        {
                            continue;
                        }

                        var     iconZ = icon.Entity.Pos.Z;
                        Vector2 position;

                        if (largeMap)
                        {
                            position = screentCenterCache + MapIcon.DeltaInWorldToMinimapDelta(
                                icon.GridPosition() - playerPos, Diag, scale, (iconZ - posZ) / (9f / mapWindowLargeMapZoom));
                        }
                        else
                        {
                            position = screentCenterCache +
                                       MapIcon.DeltaInWorldToMinimapDelta(icon.GridPosition() - playerPos, Diag, 240f, (iconZ - posZ) / 20);
                        }

                        var iconValueMainTexture = icon.MainTexture;
                        var size     = iconValueMainTexture.Size;
                        var halfSize = size / 2f;
                        icon.DrawRect = new RectangleF(position.X - halfSize, position.Y - halfSize, size, size);
                        Graphics.DrawImage(iconValueMainTexture.FileName, icon.DrawRect, iconValueMainTexture.UV, iconValueMainTexture.Color);

                        if (icon.Hidden())
                        {
                            var s = icon.DrawRect.Width * 0.5f;
                            icon.DrawRect.Inflate(-s, -s);

                            Graphics.DrawImage(icon.MainTexture.FileName, icon.DrawRect,
                                               SpriteHelper.GetUV(MapIconsIndex.LootFilterSmallCyanCircle), Color.White);

                            icon.DrawRect.Inflate(s, s);
                        }

                        if (!string.IsNullOrEmpty(icon.Text))
                        {
                            Graphics.DrawText(icon.Text, position.Translate(0, Settings.ZForText), FontAlign.Center);
                        }
                    }
                }
            }
        }