amethyst / amethyst/rustrogueliketutorial

[Chapter 66] Tooltip bug on casting a targeted spell

Đang mở
#231 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Rust
Star
970
Fork
166
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

https://github.com/amethyst/rustrogueliketutorial/blob/33872fe582f226178436847e1f74eafcbf9c0d1a/chapter-66-spells/src/inventory_system/mod.rs#L41
https://github.com/amethyst/rustrogueliketutorial/blob/33872fe582f226178436847e1f74eafcbf9c0d1a/chapter-66-spells/src/gui.rs#L51

When casting a targeted spell (like Zap), a tooltip will be displayed with the `Nameless item (bug)` string.

This is because the tooltip logic will loop on every entity with a `Position` component and try to display it.
However, when spawning a `Particle`, it is expected for it to have a `Position` but no `Name`.
When casting the spell, a `Particle` is spawned on the exact tile the player is hovering, so the `draw_tooltips` logic catches it and tries to display it. But since it has no `Name` (which is expected), it displays this string.

We need to either:
1. Filter entities we pass to `get_item_display_name` differently so particles are omitted
2. Return `None` for an entity with no `Name` component

Additionally, the code for `get_item_display_name` and `obfuscate_name` should be refactored to avoid bugs.
(`get_item_display_name` could simply get the proper stores and call `obfuscate_name`.)

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.