Keyslam-Group / Concord

A feature-complete ECS library
MIT License
221 stars 28 forks source link

Debugger / Inspector #75

Open pablomayobre opened 1 year ago

pablomayobre commented 1 year ago

Idea

Can we make a debugger or inspector to help with the development with Concord by grabbing internal data from the World at runtime?

Events

Use World:beforeEmit and World:afterEmit to detect start and end times of events, report the listeners and arguments and prevent propagation.

Preventing propagation can enable the debugger to freeze the code entirely without letting systems act based on any event fired by the World.

We could potentially re-emit events but this could prove difficult depending on the arguments passed to the event.

Systems

We can have a complete list of all the Systems.

We can show their Pools, with details on what Components the Filter uses, and the current number of Entities in each pool.

We can also have a list of all registered event listeners for a given System.

We can enable/disable the System remotely.

Entities

We can query the World with a given Filter, the debugger can easily list all available Components and allow you to add them to the Filter. We can use this information to list a subset of all available Entities

Alternatively the World knows about all the Entities with an ID.

With an Entity we can inspect the current set of Components given to it, and we can see which Pools contain this Entity.

If Components are serializable, we could easily show the current data for a given Component and serialize/deserialize it's state entirely or partially.

We can easily destroy Entities, and if we have previously serialized an Entity we could easily create one based on that serialized data.

This could allow us to perform dynamic mutations to Entities.

Components

If we had a way to tell the inspector about the shape of Components, we could show specific UI for a given component and allow the user to tweak values remotely.

We can easily give a Component to an Entity currently selected in the UI, users of the library can the use this components to render a box or other information in-game to tell the Entity apart.

pablomayobre commented 1 month ago

I have made some progress figuring out the relationships and features I'd like to implement for this debugger, and explored some ideas on this FigJam

I have also started to code some of the interfaces needed to communicate from and to Concord, but I don't have anything to show yet.