bevy-dialogue-system
БесплатноБез исполняемых скриптовНе проверенBevy 0.20 dialogue data: line tables in a resource, the current line index on a component, and choice flags filtered before the write. Use when lines or…
от thedivergentai★ 1 019 звёзд на GitHubОб этом скилле
Bevy dialogue system
When to use
Load this when lines, choices, or speaker ids advance. Rendering the line is bevy-ui-text.
ECS shape
- Components: a line id and a speaker id that you define.
- Resources: run-wide tables live in a resource (bevy-data-resources), not an autoload.
- Systems: mutate those components on
Updateor the fixed timestep. Use.chain()when damage must land before death. - Messages: one-shot facts (hit, pickup, quest advance) go through bevy-events-messaging. This file does not add a new event type name.
Engine counterparts
| Godot idea | Bevy idiom |
|---|---|
| Line table | A resource of ids and strings. |
| Current line | A component that stores the line index. |
| Portrait | An image handle via bevy-asset-scenes. Layout is bevy-ui-layout. |
Scope
Dialogue data is a resource of lines plus a component that stores the current line index. Rich text rendering belongs on bevy-ui-text.
[dependencies]
bevy = "0.20"
#[derive(Clone)]
struct LineDef {
speaker: &'static str,
text: &'static str,
next: Option<usize>,
}
#[derive(Resource)]
struct DialogueTable {
lines: Vec<LineDef>,
}
#[derive(Component)]
struct LineMark {
index: usize,
open: bool,
}
fn advance_line(
keys: Res<ButtonInput<KeyCode>>,
table: Res<DialogueTable>,
mut marks: Query<&mut LineMark>,
) {
if !keys.just_pressed(KeyCode::Space) {
return;
}
for mut mark in &mut marks {
if !mark.open {
continue;
}
let Some(line) = table.lines.get(mark.index) else {
mark.open = false;
continue;
};
match line.next {
Some(next) => mark.index = next,
None => mark.open = false,
}
}
}
fn spawn_conversation(mut commands: Commands) {
commands.insert_resource(DialogueTable {
lines: vec![
LineDef {
speaker: "guide",
text: "The gate opens at dusk.",
next: Some(1),
},
LineDef {
speaker: "guide",
text: "Bring the key.",
next: None,
},
],
});
commands.spawn(LineMark {
index: 0,
open: true,
});
}
pub struct DialoguePlugin;
impl Plugin for DialoguePlugin {
fn build(&self, app: &mut App) {
app.add_systems(Startup, spawn_conversation)
.add_systems(Update, advance_line);
}
}
Choices are data on the line. Hide a choice when its required flag is absent.
#[derive(Clone)]
struct ChoiceDef {
label: &'static str,
next: usize,
requires_flag: Option<&'static str>,
}
#[derive(Resource)]
struct ChoiceList {
choices: Vec<ChoiceDef>,
}
#[derive(Resource, Default)]
struct StoryFlags {
names: Vec<&'static str>,
}
#[derive(Component)]
struct LineMark {
index: usize,
}
fn shown_choices(flags: &StoryFlags, list: &ChoiceList) -> Vec<usize> {
list.choices
.iter()
.enumerate()
.filter_map(|(index, choice)| match choice.requires_flag {
Some(flag) if !flags.names.iter().any(|name| *name == flag) => None,
_ => Some(index),
})
.collect()
}
fn choose_first(
keys: Res<ButtonInput<KeyCode>>,
flags: Res<StoryFlags>,
list: Res<ChoiceList>,
mut marks: Query<&mut LineMark>,
) {
if !keys.just_pressed(KeyCode::Digit1) {
return;
}
let Some(choice_index) = shown_choices(&flags, &list).first().copied() else {
return;
};
let next = list.choices[choice_index].next;
for mut mark in &mut marks {
mark.index = next;
}
}
fn open_choice(mut commands: Commands) {
commands.spawn(LineMark { index: 0 });
}
pub struct ChoicePlugin;
impl Plugin for ChoicePlugin {
fn build(&self, app: &mut App) {
app.insert_resource(StoryFlags {
names: vec!["has_key"],
})
.insert_resource(ChoiceList {
choices: vec![
ChoiceDef {
label: "Open the gate",
next: 2,
requires_flag: Some("has_key"),
},
ChoiceDef {
label: "Leave",
next: 3,
requires_flag: None,
},
],
})
.add_systems(Startup, open_choice)
.add_systems(Update, choose_first);
}
}
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 that conflict.
Who owns state
| Piece | Owner | Who may mutate | Schedule |
|---|---|---|---|
| Dat |
Установить bevy-dialogue-system в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл bevy-dialogue-system?
Bevy 0.20 dialogue data: line tables in a resource, the current line index on a component, and choice flags filtered before the write. Use when lines or choices advance. Keywords: Bevy, dialogue, line index, choices, ECS.
Как установить скилл bevy-dialogue-system?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл bevy-dialogue-system запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic