# fusion-guest-bevy: Fusion's Bevy plugin (v0)

A game made with [Bevy](https://bevyengine.org) (0.19) joins Fusion as a guest by adding one
plugin and marking things with components. Its own systems keep running every mechanic; the
plugin only shows Fusion what the game has ([`docs/guest-sdk.md`](https://steonmod.com/docs/guest-sdk), BUILD.md step 5.9).

```rust
App::new()
    .add_plugins(DefaultPlugins)
    .add_plugins(FusionGuestPlugin { game_id: "mygame".into(), ..default() })
    // ...
commands.spawn((Camera3d::default(), FusionCamera));              // draws for Fusion
commands.spawn((floor_mesh, FusionCollider(Vec3::new(15.0, 0.25, 15.0))));   // solid (half size)
commands.spawn((npc_mesh, FusionEntity { kind: "mygame.npc".into(), name: "Bob".into(),
    health: 10.0, max_health: 10.0, size: Vec3::splat(0.8) }));    // in Fusion's entity registry
```

- `FusionCamera`: the plugin moves it to Fusion's camera every frame, renders it into an image on
  a transparent background (where the game draws nothing, Fusion's world shows), reads it back
  and sends it as the game's picture.
- `FusionCollider(half_size)`: an axis-aligned box sent to Fusion's Collision Hub (sent again
  only when one moves), so Fusion's player and props stand on it.
- `FusionEntity`: listed in Fusion's entity registry five times a second (its box is centered on
  its transform, like Bevy's meshes).
- `FusionRequest` messages: Fusion's actions, spawns and questions; answer with
  `NonSendMut<FusionGuest>` `.reply(id, ok)` / `.answer(id, ok, text)`.
- The game connects when Fusion asks for it (it retries every half second), and exits when
  Fusion ends the session.

**Example:** `examples/world.rs` (a floor, two crates and a wandering cube; about 50 lines), its
router `routers/bevy-example` and scenario `scenarios/bevy-yard.toml`:

```
cargo build --example world        # here, in sdks/bevy (its own workspace: Bevy is a big build)
tools/godot-checks.sh bevy_world   # from the repo: Fusion starts it and checks it
```

**v0 limits:** the picture's depth is "far" wherever the game drew, so Fusion's props always draw
in front of it (real depth needs Bevy's depth texture read back too); colliders are boxes.
