--- name: bevy-genre-open-world description: "Route a Bevy 0.20 open world. Use when region membership is a component, the player cell is one resource, and activation runs after the cell write in one chain. Keywords: Bevy, Open world, Resident, PlayerCell, Active, chain, genre." --- # Bevy Open world (thin router) Genre router. Domain work lives in the Bevy skills below. ## When to use Load this for streaming regions and distant actors. Do not invent a world-partition type. ## ECS shape - **Components** hold the genre's per-entity flags as plain data. This file does not name new engine types. - **Resources** hold run-wide counters (score, wave index, seed) via bevy-data-resources. - **Systems** read those components on `Update` or the fixed timestep from bevy-master. Order them with `.chain()` when a later system must see the result. - **Schedule:** gameplay mode changes go through bevy-state-machines. Do not invent a genre plugin. ## Routing - [bevy-asset-scenes](https://github.com/thedivergentai/Game-Dev-Agentic-Skills/blob/main/skills/bevy-asset-scenes/SKILL.md) - Region scenes. - [bevy-3d-world-building](https://github.com/thedivergentai/Game-Dev-Agentic-Skills/blob/main/skills/bevy-3d-world-building/SKILL.md) - Assembly. - [bevy-ai-navigation](https://github.com/thedivergentai/Game-Dev-Agentic-Skills/blob/main/skills/bevy-ai-navigation/SKILL.md) - Ambient actors. - [bevy-quest-system](https://github.com/thedivergentai/Game-Dev-Agentic-Skills/blob/main/skills/bevy-quest-system/SKILL.md) - Objectives. ## Scope Region membership and activation distance are components you own. Mesh LOD stays on bevy-3d-world-building. ## Examples ```toml [package] name = "open-world" version = "0.1.0" edition = "2021" [dependencies] bevy = "0.20" ``` A cell index on the player resource decides which residents are active. One system writes `PlayerCell`; the next inserts or removes `Active`. ```rust #[derive(Component)] struct Player; #[derive(Component)] struct Resident { cell: i32, } #[derive(Component)] struct Active; #[derive(Resource)] struct PlayerCell(i32); fn track_cell(players: Query<&Transform, With>, mut cell: ResMut) { for transform in &players { cell.0 = (transform.translation.x / 64.0).floor() as i32; break; } } fn activate( cell: Res, mut commands: Commands, idle: Query<(Entity, &Resident), Without>, ) { for (entity, resident) in &idle { if (resident.cell - cell.0).abs() <= 1 { commands.entity(entity).insert(Active); } } } fn deactivate( cell: Res, mut commands: Commands, active: Query<(Entity, &Resident), With>, ) { for (entity, resident) in &active { if (resident.cell - cell.0).abs() > 1 { commands.entity(entity).remove::(); } } } pub struct RegionPlugin; impl Plugin for RegionPlugin { fn build(&self, app: &mut App) { app.insert_resource(PlayerCell(0)).add_systems( Update, (track_cell, activate, deactivate).chain(), ); } } ``` Distant actors keep a home point and only move while `Active` is present. ```rust #[derive(Component)] struct Wander { home: Vec3, angle: f32, } fn wander(time: Res