bevy-ecs
ما الذي تفعله
تشرح هذه المهارة كيفية تنظيم لعبة Bevy مكتوبة بلغة Rust، باستخدام نظام الكيانات والمكوّنات. وهي مناسبة للمطوّرين الذين يبنون ألعابًا في Bevy.
متى تستخدمها
- ✓عندما تبدأ تطبيق Bevy بلغة Rust أو تعدّله.
- ✓عندما تحتاج إلى كتابة أنظمة تقرأ كائنات اللعبة أو تغيّرها باستخدام الاستعلامات.
- ✓عندما يُظهر Bevy أخطاء تعارض في الاستعارة، أو تكون الحركة مرتبطة بعدد الإطارات في الثانية.
رابط المهارة
https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/other-engines/bevy-ecs/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“اصنع لاعبًا في Bevy يتحرك بمفاتيح الأسهم بالسرعة نفسها على أي حاسوب.”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
تُظهر المهارة كيفية بناء التطبيق من الإضافات، وتعريف البيانات كمكوّنات وموارد، وكتابة أنظمة تعمل بترتيب محدد، واستخدام مورد الوقت لحركة سلسة.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من GitHub.
Bevy ECS
Structure a Bevy game in Rust around the Entity Component System: the App and
plugins, components and resources, systems with queries, scheduling, and
frame-rate-independent updates. New examples target Bevy 0.20. If the project
already pins another release, keep that release and use its matching migration guide.
When to use
- Use when wiring a Bevy
App, definingComponent/Resourcetypes, writing systems that query entities, ordering/filtering systems, or fixing borrow-conflict panics and frame-dependent movement. - Use when
Cargo.tomldepends onbevyand code callsApp::new(),add_systems,Query, orCommands.
When not to use: this is the ECS core. Deep rendering, custom shaders/
pipelines, UI layout, and audio are separate concerns. For engine-agnostic AI or
procedural algorithms, pair with game-ai / procedural-gen.
Core workflow
- Detect and pin the version. Read
Cargo.tomlandCargo.lockfirst. For a new project usebevy = "0.20"; never silently migrate an existing project across a Bevy minor release. Treat the matching docs and migration guides as truth. - Build the
App.App::new().add_plugins(DefaultPlugins)gives windowing, input, rendering, time, etc. Register systems into schedules:Startup(once) andUpdate(every frame). - Model data as components, globals as resources.
#[derive(Component)]for per-entity data;#[derive(Resource)]for one-of-a-kind data (score, settings, theTimeclock). Since 0.19ResourceextendsComponentand each resource is stored on its own entity, so do not derive both. - Write systems as plain functions. Parameters declare data access:
Query<...>for entities,Res<T>/ResMut<T>for resources,Commandsfor deferred spawn/despawn. Systems run in parallel when their accesses don't conflict. - Drive motion by
time.delta_secs()so speed is frame-rate independent. - Order only what must be ordered with
.chain()or explicit constraints; gate systems withrun_if. Group related setup intoPlugins. Build withcargo runand read the panics — Bevy reports conflicting queries at startup.
Patterns
1. Cargo.toml + minimal App
# Cargo.toml — pin the version; the API differs across minor releases.
[dependencies]
bevy = "0.20"
// main.rs
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins) // window, input, render, time, ...
.add_systems(Startup, setup) // runs once at startup
.add_systems(Update, move_players) // runs every frame
.run();
}
2. Components, resources, and spawning
#[derive(Component)]
struct Player;
#[derive(Component)]
struct Velocity(Vec2);
#[derive(Resource)]
struct Score(u32);
fn setup(mut commands: Commands) {
commands.insert_resource(Score(0));
// Camera2d is a component with required components (bundles removed in 0.16);
// spawning it pulls in Transform, Camera, etc. automatically.
commands.spawn(Camera2d);
// Spawn an entity as a tuple of components.
commands.spawn((
Player,
Velocity(Vec2::new(150.0, 0.0)),
Transform::from_xyz(0.0, 0.0, 0.0),
));
}
3. A system with a query + the Time resource
// Iterate every entity that has BOTH Velocity and Transform; mutate Transform.
fn move_players(time: Res<Time>, mut query: Query<(&Velocity, &mut Transform)>) {
for (velocity, mut transform) in &mut query {
// delta_secs() is f32 seconds (renamed from delta_seconds() in 0.16).
transform.translation += velocity.0.extend(0.0) * time.delta_secs();
}
}
4. Query filters (With / Without / Changed)
// Only entities tagged Player (the Player component itself isn't read).
fn aim_player(mut q: Query<&mut Transform, With<Player>>) { /* ... */ }
// Disjoint two mutable Transform queries so they don't conflict at runtime.
fn separate(
mut players: Query<&mut Transform, With<Player>>,
mut enemies: Query<&mut Transform, Without<Player>>,
) { /* ... */ }
// React only when Health changed since last run (change detection).
fn on_health_change(q: Query<&Health, Changed<Health>>) {
for health in &q { /* update the HUD, etc. */ }
}
5. Resources: read and write
fn add_points(mut score: ResMut<Score>) {
score.0 += 10; // ResMut = write access
}
fn
الأسئلة الشائعة
ما هو نظام الكيانات والمكوّنات؟
هو طريقة لبناء الألعاب حيث تكون الكائنات معرّفات بسيطة مرتبطة ببيانات، والأنظمة تتولى المنطق.
هل ستحدّث هذه المهارة نسخة Bevy لدي؟
لا. تنص المهارة على الإبقاء على نسخة Bevy التي يستخدمها المشروع، بدل ترقيتها دون علم.
هل تغطي العرض أو الـShaders؟
ليس بعمق. العرض والـShaders والواجهة والصوت مواضيع منفصلة.
التفاصيل
الوصف الأصلي من المؤلف
Structure a Bevy app around its Entity Component System: build the App with plugins, define Component/Resource types, write systems with Query/Res/Commands, filter and order systems, and use the Time resource for frame-rate-independent motion. Use when building or debugging a Bevy game in Rust — when the user mentions Bevy, ECS, App::new, add_systems, Query, Commands, components/systems, or a Cargo.toml depending on bevy.
الشعبية
- نجوم GitHub
- 6.6k
- الترتيب
- #13832
- الترخيص
- Apache-2.0
- آخر تحديث
- 28/10/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
router
6.6kيساعد وكيلك على اختيار مهارة تطوير الألعاب المناسبة لطلبك، بعد التعرف على المحرك ونوع المهمة التي تحتاجها.
ai-behavior-trees-utility-ai
6.6kيساعد وكيلك على بناء شجرة سلوك ونظام ذكاء اصطناعي بالتقييم لأعداء اللعبة والشخصيات، فتختار الإجراء حسب الأولوية والنقاط.
audio-design
6.6kيعلّم وكيلك مزج صوت اللعبة: المسارات، والديسيبل، وخفض الموسيقى تحت الحوار، والموسيقى المتكيفة، وتنويع المؤثرات الصوتية.
camera-systems
6.6kيساعد وكيلك على بناء كاميرات للألعاب تتبع اللاعب بسلاسة، وتبقى داخل حدود المرحلة، وتدور حول الشخصية أو تنظر حولها في ثلاثة أبعاد.
مهارات مشابهة
diffs
394kيتيح لوكيلك إنتاج فرق تعديلات حقيقي يمكن مشاركته، كرابط عرض أو ملف صورة، بدلاً من ملخص مكتوب يدوياً.
coding-agent
394kيساعد وكيلك على تسليم مهمة برمجة كبيرة إلى Codex أو Claude Code أو OpenCode كعامل في الخلفية، ثم متابعة تقدمها.
gh-issues
394kيساعد وكيلك على إيجاد مشكلات GitHub واختيار ما ستعمل عليه، وفتح طلبات سحب بالإصلاحات، ومتابعة تعليقات المراجعة.