spacetimedb
add bevy_spacetimedb init spacetimedb module
This commit is contained in:
parent
7cbe10c19e
commit
dedeb39304
17 changed files with 3355 additions and 49 deletions
46
jongline/src/lib.rs
Normal file
46
jongline/src/lib.rs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
use spacetimedb::{ReducerContext, Table};
|
||||
|
||||
#[spacetimedb::table(name = player, public)]
|
||||
pub struct Player {
|
||||
name: String,
|
||||
}
|
||||
|
||||
#[spacetimedb::table(name = table, public)]
|
||||
pub struct Table {}
|
||||
|
||||
#[spacetimedb::table(name = wall)]
|
||||
pub struct Wall {}
|
||||
|
||||
#[spacetimedb::table(name = hand)]
|
||||
pub struct Hand {}
|
||||
|
||||
#[spacetimedb::table(name = drawn)]
|
||||
pub struct Drawn {}
|
||||
|
||||
#[spacetimedb::reducer(init)]
|
||||
pub fn init(_ctx: &ReducerContext) {
|
||||
// Called when the module is initially published
|
||||
}
|
||||
|
||||
#[spacetimedb::reducer(client_connected)]
|
||||
pub fn identity_connected(_ctx: &ReducerContext) {
|
||||
// Called everytime a new client connects
|
||||
}
|
||||
|
||||
#[spacetimedb::reducer(client_disconnected)]
|
||||
pub fn identity_disconnected(_ctx: &ReducerContext) {
|
||||
// Called everytime a client disconnects
|
||||
}
|
||||
|
||||
#[spacetimedb::reducer]
|
||||
pub fn add(ctx: &ReducerContext, name: String) {
|
||||
ctx.db.players().insert(Player { name });
|
||||
}
|
||||
|
||||
// #[spacetimedb::reducer]
|
||||
// pub fn say_hello(ctx: &ReducerContext) {
|
||||
// for person in ctx.db.person().iter() {
|
||||
// log::info!("Hello, {}!", person.name);
|
||||
// }
|
||||
// log::info!("Hello, World!");
|
||||
// }
|
||||
Loading…
Add table
Add a link
Reference in a new issue