GithubHelp home page GithubHelp logo

arroui / bevy_steamworks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from houraiteahouse/bevy_steamworks

0.0 0.0 0.0 2.94 MB

A Bevy plugin for integrating with the Steamworks SDK

License: Apache License 2.0

Rust 100.00%

bevy_steamworks's Introduction

bevy-steamworks

crates.io Documentation License

This crate provides a Bevy plugin for integrating with the Steamworks SDK.

Installation

Add the following to your Cargo.toml:

[dependencies]
bevy-steamworks = "0.11"

The steamworks crate comes bundled with the redistributable dynamic libraries of a compatible version of the SDK. Currently it's v158a.

If you wish to enable serde support add the following:

[dependencies]
bevy-steamworks = { version = "0.9", features = ["serde"] }

Usage

To add the plugin to your app, simply add the SteamworksPlugin to your App. This will require the AppId provided to you by Valve for initialization.

use bevy::prelude::*;
use bevy_steamworks::*;

fn main() {
  // Use the demo Steam AppId for SpaceWar
  App::new()
      // it is important to add the plugin before `RenderPlugin` that comes with `DefaultPlugins`
      .add_plugins(SteamworksPlugin::init_app(480).unwrap())
      .add_plugins(DefaultPlugins)
      .run()
}

The plugin adds Client as a Bevy ECS resource, which can be accessed like any other resource in Bevy. The client implements Send and Sync and can be used to make requests via the SDK from any of Bevy's threads.

The plugin will automatically call SingleClient::run_callbacks on the Bevy every tick in the First schedule, so there is no need to run it manually.

All callbacks are forwarded as Events and can be listened to in the a Bevy idiomatic way:

use bevy::prelude::*;
use bevy_steamworks::*;

fn steam_system(steam_client: Res<Client>) {
  for friend in steam_client.friends().get_friends(FriendFlags::IMMEDIATE) {
    println!("Friend: {:?} - {}({:?})", friend.id(), friend.name(), friend.state());
  }
}

fn main() {
  // Use the demo Steam AppId for SpaceWar
  App::new()
      // it is important to add the plugin before `RenderPlugin` that comes with `DefaultPlugins`
      .add_plugins(SteamworksPlugin::init_app(480).unwrap())
      .add_plugins(DefaultPlugins)
      .add_systems(Startup, steam_system)
      .run()
}

Bevy Version Supported

Bevy Version bevy_steamworks
0.13 0.10, 0.11
0.12 0.9
0.11 0.8
0.10 0.7
0.9 0.6
0.8 0.5
0.7 0.4
0.6 0.2, 0.3
0.5 0.1

bevy_steamworks's People

Contributors

james7132 avatar dependabot[bot] avatar aeropolian avatar arendjr avatar emmettjayhart avatar trustnooneelse avatar sdesya74 avatar zwazel avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.