Links

Message buffering

As part of the simulation loop, Simulate provides a phase for receiving messages and a phase for sending them. Those are user_state::receive_messages(…) and user_state::send_messages(). However, if there is the need to process messages during the tick phase, there is a solution already implemented to do so. A set of message buffers were implemented inside ecs to store the messages so they could be read and send during tick phase. Using this feature is optional. With the addition of EnTT, the solution has been generalized so it can be used in both places.
The message buffers have been implemented outside ECS. If you do not override receive_messages and send_messages phases, the messages are saved into the incoming_buffer when received and sent from the outgoing_buffer during the send phase.

Migrating existing EnTT ECS code

For an EnTT simulation you will be able to access messages buffers in the tick_phase and use them:
void user_cell_state_impl::cell_tick(
const aether_state_type &aether_state,
float delta_time
) {
// example of message systems
message_system(
registry,
&incoming_message_buffer,
&outgoing_message_buffer
);
}

Migrating existing Hadean Simulate ECS code

The default behaviour is now to store messages in and send messages from the buffer, so you no longer need to define receive_messages and send_messages functions in your ECS code. Unless you want to override the default behaviour, these definitions should be removed.
To use messaging from your ECS code, pass the message buffers into calls to store.tick:
store.tick(
aether_state, delta_time,
incomming_message_buffer, outgoing_message_buffer
);
Alternatively, you can store messages inside the ECS by overriding the receive_messages and send_messages functions:
void user_cell_state_impl::receive_messages(
const aether_state_type& aether_state,
message_reader_type& reader
) {
store.receive_messages(reader); //store messages inside the ECS buffer
}
void user_cell_state_impl::cell_tick(
const aether_state_type &aether_state,
float delta_time
) {
// Leave this function as it is, and write your logic in ECS systems.
store.tick(aether_state, delta_time);
}
void user_cell_state_impl::send_messages(
const aether_state_type& aether_state,
message_writer_type& writer
) {
store.send_messages(writer); //send messages from ECS buffer
}