Crates.io | bevy_mod_pies_spacetraders_api |
lib.rs | bevy_mod_pies_spacetraders_api |
version | 0.8.0 |
source | src |
created_at | 2023-06-29 16:57:07.011438 |
updated_at | 2023-11-12 19:11:42.144174 |
description | SpaceTraders API implemented for Bevy the game engine. |
homepage | |
repository | https://github.com/Pieresqi/bevy_mod_pies_spacetraders_api |
max_upload_size | |
id | 903493 |
size | 63,517 |
SpaceTraders API implemented for Bevy the game engine.
Consult official Docs for APIs explanations.
Learm more about Bevy here and about SpaceTraders here.
Issues / Pull requests / criticism / requests welcome.
use bevy::{log::LogPlugin, prelude::*};
use bevy_mod_pies_spacetraders_api::prelude::*;
fn main() {
App::new()
.add_plugins(MinimalPlugins)
.add_plugins(LogPlugin::default())
// we will need this, it sets up stuff
.add_plugins(ClientPlugin)
.add_systems(Startup, (add_token, set_status).chain())
.add_systems(Update, get_status.run_if(/* custom run condition is provided: */response_received::<GetStatus>()))
.run();
}
fn add_token(mut config: ResMut<ClientConnectionConfig>) {
// bearer token, almost every API needs it
config.set_bearer_token("XXX");
}
fn set_status(status: Res<endpoints::GetStatus>) {
// we can send request with this method, each API has it's own impl and will require different args
status.set_request(Rates {
// we will use Burst limiter - up to 10 requests per second over 10 seconds
limit: RateLimit::Burst,
// request will be queued untill wa can send it
strategy: RateStrategy::Queued,
..default()
});
}
// each API is it's own Resource
fn get_status(status: Res<endpoints::GetStatus>) {
for status in status.get_receiver().try_iter() {
match status {
Ok(status) => info!("{:?}", status),
Err(error) => warn!("{:?}", error),
}
}
}
Bevy | Crate |
---|---|
0.12 |
0.8.0 |
0.11 |
0.7.0 , 0.6.1 , 0.6.0 , 0.5.0 , 0.4.0 , 0.3.0 , 0.2.0 |
0.10 |
0.1.1 , 0.1.0 |
Repo is dual licensed under MIT
or Apache-2.0
unless stated othervise.