Skip to content

Suggestion: Hide captured beasts from overlay #7

@dovlabu

Description

@dovlabu

Suggesting from temp333 on ownedcore to better handle clearing found beasts from overlay.

Hello I would like to suggest this change so beasts that are already captured don't get highlighted. When a beast is captured they are still highlighted for like 10 seconds without this change.
Edit: add null checks to DrawBeastsWindow to prevent error spam when the entity disappears.
Looking for a way to delete the entity when going outside of range.

beasts.render.cs

    private void DrawInGameBeasts()
    {
        foreach (var trackedBeast in _trackedBeasts
                    .Select(x => new
                    {
                        Positioned = x.Value.GetComponent<Positioned>(),
                        Beast = BeastsDatabase.AllBeasts.FirstOrDefault(b => x.Value.Metadata == b.Path),
                        Buffs = x.Value.Buffs
                    })
                    .Where(x => x.Positioned != null && x.Beast != null && Settings.Beasts.Any(s => s.Path == x.Beast.Path)))
        {
            if(trackedBeast.Buffs.Find(b => b.Name == "capture_monster_trapped") != null)
            {
                continue;
            }

            var beast = trackedBeast.Beast;
            var pos = GameController.IngameState.Data.ToWorldWithTerrainHeight(trackedBeast.Positioned.GridPosition);

            Graphics.DrawText(beast.DisplayName, GameController.IngameState.Camera.WorldToScreen(pos), Color.White,
                FontAlign.Center);

            DrawFilledCircleInWorldPosition(pos, 50, GetSpecialBeastColor(beast.DisplayName));
        }
    }

    private void DrawBeastsWindow()
    {
        ImGui.SetNextWindowSize(new Vector2(0, 0));
        ImGui.SetNextWindowBgAlpha(0.6f);
        ImGui.Begin("Beasts Window", ImGuiWindowFlags.NoDecoration);

        if (ImGui.BeginTable("Beasts Table", 2,
                ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter | ImGuiTableFlags.BordersV))
        {
            ImGui.TableSetupColumn("Price", ImGuiTableColumnFlags.WidthFixed, 48);
            ImGui.TableSetupColumn("Beast");

            foreach (var (beast,beastMetadata) in _trackedBeasts
                         .Select(trackedBeast => trackedBeast.Value)
                         .Select(beast => (beast, metadata: Settings.Beasts.Find(b => b.Path == beast.Metadata)))
                         .Where(b => b.metadata != null))
            {
                if (beast?.Buffs?.Find(b => b.Name == "capture_monster_trapped") != null)
                {
                    continue;
                }

                ImGui.TableNextRow();

                ImGui.TableNextColumn();

                ImGui.Text(Settings.BeastPrices.TryGetValue(beastMetadata.DisplayName, out var price)
                    ? $"{price.ToString(CultureInfo.InvariantCulture)}c"
                    : "0c");

                ImGui.TableNextColumn();

                ImGui.Text(beastMetadata.DisplayName);
                foreach (var craft in beastMetadata.Crafts)
                {
                    ImGui.Text(craft);
                }
            }

            ImGui.EndTable();
        }

        ImGui.End();
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions