# Bevy Game Loop Collection

Bevy 0.20 collection loop: pickup markers, a quota resource, one score per entity per...

- Repository: https://github.com/thedivergentai/Game-Dev-Agentic-Skills (917 stars)
- Category: Engineering
- License: LGPL-3.0
- Last updated: 2026-10-16
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-game-loop-collection -g -a claude-code -y`
Codex: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-game-loop-collection -g -a codex -y`
Cursor: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-game-loop-collection -g -a cursor -y`
Gemini CLI: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-game-loop-collection -g -a gemini-cli -y`

## Description

Bevy 0.20 collection loop: pickup markers, a quota resource, one score per entity per pass, and NextState when the quota is met. Use when the run is about collecting objects. Keywords: Bevy, collection, pickup, quota, NextState, ECS.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Bevy collection loop

## When to use

Load this when the run is about picking up objects and reaching a count.

## ECS shape

- **Components:** a collected flag and a quota resource you define.
- **Resources:** run-wide tables live in a resource (bevy-data-resources), not an autoload.
- **Systems:** mutate those components on `Update` or 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 |
| --- | --- |
| Pickup | A component marker. Detection waits on spatial queries. |
| Quota | A resource count. |
| Win | A state change via bevy-state-machines. |

## Scope

A collectible is a marker component. Overlap is a distance check you own until a physics skill supplies contacts. Mark each entity once per pass: `Commands::despawn` applies later, so a second collector would otherwise score the same pickup. The quota is a resource. Reaching it writes `NextState`, which the state schedule applies after this system.

```toml
[dependencies]
bevy = "0.20"
```

```rust
#[derive(Component)]
struct Collectible {
    points: u32,
}

#[derive(Component)]
struct Collector;

#[derive(Resource)]
struct CollectionScore {
    points: u32,
    quota: u32,
}

#[derive(States, Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
enum RunState {
    #[default]
    Playing,
    Won,
}

The rest: https://github.com/thedivergentai/Game-Dev-Agentic-Skills/blob/HEAD/skills/bevy-game-loop-collection/SKILL.md
