bevy-procedural-generation
БесплатноБез исполняемых скриптовНе проверенBevy ECS skill for procedural generation. Keywords: Bevy, procedural, seed, dungeon, terrain, ECS.
от thedivergentai★ 1 019 звёзд на GitHubОб этом скилле
Bevy procedural generation
When to use
Load this when a level, loot table, or map should be reproducible from a seed, and you need the ECS shape. Spawning the finished layout uses Commands on Startup or a later schedule you already use. Saving the seed belongs on bevy-save-load.
ECS shape
- Components: cell facts you define, spawned with
Commands. - Resources: one
RunSeedfor the whole run. The generator reads it; it does not invent a Bevy RNG type.rand0.9 suppliesStdRng. - Systems: insert the seed on
Startup, then spawn from that data..chain()so the spawn system sees the seed. - Schedule:
Startupfor a one-shot map. A streaming map is a laterUpdatesystem that still reads the same seed.
[dependencies]
bevy = "0.20"
rand = "0.9"
The seed is a resource. The walk is plain data. Entities are spawned only after the seed exists.
use rand::rngs::StdRng;
use rand::{Rng, SeedableRng};
#[derive(Resource)]
struct RunSeed(u64);
#[derive(Component, Clone, Copy)]
struct FloorCell {
x: i32,
y: i32,
}
fn insert_seed(mut commands: Commands) {
commands.insert_resource(RunSeed(42));
}
fn spawn_walk(mut commands: Commands, seed: Res<RunSeed>) {
let mut rng = StdRng::seed_from_u64(seed.0);
let mut x = 0;
let mut y = 0;
for _ in 0..24 {
commands.spawn((
FloorCell { x, y },
Transform::from_xyz(x as f32, y as f32, 0.0),
));
match rng.random_range(0..4) {
0 => x += 1,
1 => x -= 1,
2 => y += 1,
_ => y -= 1,
}
}
}
pub struct DungeonPlugin;
impl Plugin for DungeonPlugin {
fn build(&self, app: &mut App) {
app.add_systems(Startup, (insert_seed, spawn_walk).chain());
}
}
Height samples stay in a resource. The same seed always rebuilds the same grid. Sampling happens once, not every frame.
#[derive(Resource)]
struct HeightGrid {
width: i32,
samples: Vec<f32>,
}
#[derive(Resource)]
struct RunSeed(u64);
fn hash_unit(x: i32, y: i32, seed: u64) -> f32 {
let mut n = seed
.wrapping_mul(0x9E37_79B9_7F4A_7C15)
^ (x as u64).wrapping_mul(0xBF58_476D_1CE4_E5B9)
^ (y as u64).wrapping_mul(0x94D0_49BB_1331_11EB);
n = (n ^ (n >> 30)).wrapping_mul(0xBF58_476D_1CE4_E5B9);
n = (n ^ (n >> 27)).wrapping_mul(0x94D0_49BB_1331_11EB);
n ^= n >> 31;
(n >> 40) as f32 / (1u32 << 24) as f32
}
fn build_heights(mut commands: Commands, seed: Res<RunSeed>) {
let width = 16;
let mut samples = Vec::with_capacity((width * width) as usize);
for y in 0..width {
for x in 0..width {
samples.push(hash_unit(x, y, seed.0));
}
}
commands.insert_resource(HeightGrid { width, samples });
}
Rooms are rectangles carved into a grid you own. Spawn markers only for floor cells.
struct Room {
x: i32,
y: i32,
w: i32,
h: i32,
}
fn carve(width: i32, rooms: &[Room]) -> Vec<bool> {
let mut floor = vec![false; (width * width) as usize];
for room in rooms {
for y in room.y..room.y + room.h {
for x in room.x..room.x + room.w {
if (0..width).contains(&x) && (0..width).contains(&y) {
floor[(y * width + x) as usize] = true;
}
}
}
}
floor
}
#[derive(Component, Clone, Copy)]
struct FloorCell {
x: i32,
y: i32,
}
fn spawn_rooms(mut commands: Commands) {
let rooms = [
Room { x: 1, y: 1, w: 4, h: 3 },
Room { x: 8, y: 6, w: 5, h: 4 },
];
let width = 16;
for (i, open) in carve(width, &rooms).into_iter().enumerate() {
if open {
let x = (i as i32) % width;
let y = (i as i32) / width;
commands.spawn(FloorCell { x, y });
}
}
}
Choose the owner
| Need | Owner |
|---|---|
| Seeded run | A Resource holding a seed you define |
| Chunk or dungeon grid | Your components, spawned with Commands |
| Hash, rooms, or walk | Your functions over a RunSeed. rand::rngs::StdRng is the seeded generator. |
| Floor cells | Entities spawned from the grid. Tilemaps belong on the tile skill. |
| Nav bake after generation | Nav bake after generation belongs on bevy-navigation. |
Scope
- Seeded walks and room carves above use
rand0.9 and your own grid. Bevy does not ship a dungeon solver. - Build the grid on the main schedule, then spawn.
Commandsstay on the system that runs there. - Navigation rebake after a generated map belongs on bevy-navigation.
Expert Knowledge Delta
Target: Bevy 0.20+.
Core ECS types: Component, Resource, Query, Commands, Startup, Update, Fixed / FixedMain (bevy::time), .chain(), Plugin, DefaultPlugins, MinimalPlugins. Messages and observers are an ownership slot. See bevy-events-messaging for their APIs. Systems run in parallel unless .chain() orders the ones th
Установить bevy-procedural-generation в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл bevy-procedural-generation?
Bevy ECS skill for procedural generation. Keywords: Bevy, procedural, seed, dungeon, terrain, ECS.
Как установить скилл bevy-procedural-generation?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл bevy-procedural-generation запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic