Working with Bevy
This section provides detailed guidance on working with the Bevy game engine in the Rummage project. Bevy is a data-driven game engine built in Rust that uses an Entity Component System (ECS) architecture, which is particularly well-suited for building complex game systems like those required for a Magic: The Gathering implementation.
Table of Contents
Introduction
Rummage uses Bevy 0.15.x as its foundation, leveraging Bevy's modular design and performant ECS to create a robust MTG Commander game engine. This section explains how we use Bevy, our architecture patterns, and best practices for working with Bevy components, systems, and resources.
Key Bevy Concepts
Before diving into Rummage-specific patterns, it's important to understand these core Bevy concepts:
- Entity: A unique ID that can have components attached to it
- Component: Data attached to entities (e.g.,
Card
,Player
,Battlefield
) - System: Logic that operates on components (e.g., drawing cards, resolving abilities)
- Resource: Global data not tied to any specific entity (e.g.,
GameState
,RngResource
) - Plugin: A collection of systems, components, and resources that can be added to the app
- Query: A way to access entities and their components in systems
- Events: Message-passing mechanism between systems
Rummage Bevy Patterns
Rummage follows these patterns for Bevy implementation:
- Domain-Specific Plugins: Each game domain (cards, player, zones, etc.) has its own plugin
- Component-Heavy Design: Game state is represented primarily through components
- Event-Driven Interactions: Game actions are often communicated via events
- State-Based Architecture: Game flow is controlled through Bevy's state system
- Clean Resource Management: Resources are used judiciously for truly global state
Bevy Version Considerations
Rummage uses Bevy 0.15.x, which introduces some important changes from earlier versions:
- Deprecated UI Components:
Text2dBundle
,SpriteBundle
, andNodeBundle
are deprecated in favor ofText2d
,Sprite
, andNode
respectively - App Initialization: Modified approach to app configuration and plugin registration
- System Sets: Updated system ordering mechanism
- Asset Loading: Enhanced asset loading system
- Time Management: Improved time and timer APIs
Always check for and fix any compiler warnings that might indicate usage of deprecated APIs.
Detailed Guides
For more detailed information on working with Bevy in the Rummage project, explore these specific topics:
- Entity Component System - Detailed guide on how Rummage uses ECS architecture
- Plugin Architecture - How plugins are organized and composed in Rummage
- Rendering - Card rendering, UI, and visual effects implementation
- Camera Management - Camera setup, management, and common issues
- Random Number Generation - Using bevy_rand for entity-attached RNGs and networked state sharing
Next: Entity Component System