10个版本 (破坏性更新)
| 0.8.0 | 2023年11月12日 | 
|---|---|
| 0.6.1 | 2023年10月12日 | 
| 0.3.0 | 2023年7月20日 | 
#1128 in 游戏开发
每月66次下载
64KB
 1.5K  SLoC
非官方的Bevy SpaceTraders API
为Bevy游戏引擎实现的SpaceTraders API。
请参考官方文档以了解API说明。
了解更多关于Bevy 这里 和关于SpaceTraders 这里。
欢迎提出问题 / 代码请求 / 批评 / 请求。
功能
- 简单且易用的API
- 集成速率限制器
- 专为Bevy设计
- 轻松创建新的API(端点)
简单示例
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 | Crates | 
|---|---|
| 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 | 
许可证
仓库在MIT或Apache-2.0许可证下双许可,除非另有说明。
依赖
~16–31MB
~503K SLoC