## Description
Solidify the design of `valence_anvil` so that most of the boilerplate
in the anvil example is eliminated. `AnvilLevel` is now a component of
`Instance` and automatically loads and unloads chunks as clients move
around. Events are used to communicate when chunks are loaded and
unloaded.
Also changes the system message API and introduces the `SendMessage`
trait.
Checks off a box in #288
### Known Issues
- Still no support for saving or entities.
- The handling of chunk `min_y` is wrong. I plan to fix this in an
upcoming redesign of instances and chunks.
- Uses one OS thread per anvil level. This could be improved with a
dedicated shared thread pool to parallelize the loading process.
However, it seems decently fast as it is.
- Old benchmark is commented out.
- Could use some tests.
## Description
Basic implementation of world border
World border is not enabled by default. It can be enabled by inserting
`WorldBorderBundle` bundle. Currently, this PR only implements world
borders per instance, I'm considering expanding this per client.
However, the same functionality can be achieved by Visibility Layers
#362
<details>
<summary>Playground:</summary>
```rust
fn border_controls(
mut events: EventReader<ChatMessageEvent>,
mut instances: Query<(Entity, &WorldBorderDiameter, &mut WorldBorderCenter), With<Instance>>,
mut event_writer: EventWriter<SetWorldBorderSizeEvent>,
) {
for x in events.iter() {
let parts: Vec<&str> = x.message.split(' ').collect();
match parts[0] {
"add" => {
let Ok(value) = parts[1].parse::<f64>() else {
return;
};
let Ok(speed) = parts[2].parse::<i64>() else {
return;
};
let Ok((entity, diameter, _)) = instances.get_single_mut() else {
return;
};
event_writer.send(SetWorldBorderSizeEvent {
instance: entity,
new_diameter: diameter.diameter() + value,
speed,
})
}
"center" => {
let Ok(x) = parts[1].parse::<f64>() else {
return;
};
let Ok(z) = parts[2].parse::<f64>() else {
return;
};
instances.single_mut().2 .0 = DVec2 { x, y: z };
}
_ => (),
}
}
}
```
</details>
example: `cargo run --package valence --example world_border`
tests: `cargo test --package valence --lib -- tests::world_border`
**Related**
part of #210