@metaverse-systems/input-component
v1.1.0
Published
This library implements a lightweight component for representing input events within an ECS-based architecture. Each component captures:
Readme
@metaverse-systems/input-component
This library implements a lightweight component for representing input events within an ECS-based architecture. Each component captures:
- event – a string identifier for the input event type
- content – arbitrary JSON payload associated with the event
- sequence – a monotonically increasing sequence number for ordering
Usage
Creating a component
ComponentLoader comp_loader;
auto world = ECS->Container();
auto entity = world->Entity();
nlohmann::json config;
config["event"] = "left_click";
config["content"] = { {"x", 100}, {"y", 200} };
config["sequence"] = 42;
entity->Component(comp_loader.Create("@metaverse-systems/input-component", &config).release());
Exporting to JSON
nlohmann::json data = comp.Export();
// data contains: { "event": "...", "content": { ... }, "sequence": ... }API Reference
| Member | Type | Description |
| --- | --- | --- |
| event | std::string | Event type identifier |
| content | nlohmann::json | Event payload data |
| sequence | uint64_t | Sequence number (default: 0) |
License
MIT License — see COPYING for details.
Author
Tim Schwartz — [email protected] | metaverse.systems
