amethyst / amethyst/specs

How to visualize the storage while debugging?

Open
#715 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
2.6k
Forks
215
PR merge metrics
No merged PRs in 30d

Description

First of all, this is a wonderful crate. I loved working on it and it forces me to follow the ECS principles. Thanks for your contribution,

My Setup:
I have N entities and I modify components using couple of systems independently using Dispatchers. Once it is completed, I have to pick some entities and derive some metrics (see below).

// For example, after dispatcher I wanted to get the total heath and then end the program
let health_storage = world.read_component::();
let pl1_health = health_storage.get(pl1).unwrap(); // I want to avoid this
let pl2_health = health_storage.get(pl2).unwrap(); // I want to avoid this
let total_health = pl1_health + pl2_health;
println!("{}", total_health);
// Since I am working with multiple entities, I didnt do these lines as a system
// When I set breakpoint, health_storage is shown as pointers

Now the challenge is, if I debug this using Visual C++ or llvm in VSCode, the health_storage is not showing the values. It only shows pointers and I have to use `get(Entity)` to visualise. I would have been happy if I can execute the command directly while debugging (like watch commands) but Rust has issues with calling trait functions.

Recently, I came to know about NatViz which help in improving visualisation while using Visual C++ debugger. In fact, I modified it to support NDArray and it works like a charm. I wanted to do the same with Storage but don't know how to list the entities-component pair. Can you help me?

![image](https://user-images.githubusercontent.com/16543422/101239051-9ab9ca80-370a-11eb-8edc-a1896c4625ad.png)

One more question, how do you guys debug? Do you use println!?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.