How to create and register a system
RegenSystem
that increments the current health of all entities that have the Health
component.AttackSystem
that handles the AttackPlayerMsg
message and reduces the health of the target player.system
directory, with each system being its own separate file.
You can easily create a new system and register it to the world by following these steps:
Implement the system function
WorldContext
and returns an error (or nil, if there is none).Register the system in the World
RegisterSystems
function.fmt.Errorf
and include relevant entity IDs and component names in error messages for easier debugging.