# Bevy Game Loop Harvest

Bevy ECS harvest loop: Crop stage on Time<Fixed>, season scale, catch-up from a...

- Repository: https://github.com/thedivergentai/Game-Dev-Agentic-Skills (917 stars)
- Category: Marketing
- 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-harvest -g -a claude-code -y`
Codex: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-game-loop-harvest -g -a codex -y`
Cursor: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-game-loop-harvest -g -a cursor -y`
Gemini CLI: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-game-loop-harvest -g -a gemini-cli -y`

## Description

Bevy ECS harvest loop: Crop stage on Time<Fixed>, season scale, catch-up from a LastVisit resource, Harvested messages. Use when growth must finish before the yield message. Keywords: Bevy, harvest, crop, FixedUpdate, season, catch-up.

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

# Bevy harvest loop

## When to use

Load this when crops advance on a timer and a harvest message records the yield.

## ECS shape

- **Components:** growth elapsed and a stage index you define.
- **Resources:** the last visit and the season scale live in resources (bevy-data-resources).
- **Systems:** step growth on `FixedUpdate`. Use `.chain()` so harvest reads the stage growth just wrote.
- **Messages:** `Harvested` is the one-shot yield fact. Inventory applies it in bevy-inventory-system.

## Idioms

| Need | Bevy shape |
| --- | --- |
| Growth | Elapsed time on a component, stepped on the fixed clock. |
| Extract | A `Harvested` message. Inventory consumes it. |
| Season | A resource scale. No calendar type was opened. |

## Scope

- A crop component stores stage and elapsed time. Growth steps on `Time<Fixed>`.
- Offline catch-up reads `Time::elapsed_secs` against a resource that remembers the last visit.

## Examples

```toml
[package]
name = "harvest"
version = "0.1.0"
edition = "2021"

[dependencies]
bevy = "0.20"
```

Growth advances one stage per interval. Harvest only fires when the last stage is ready.

```rust
#[derive(Component)]
struct Crop {
    stage: u8,
    elapsed: f32,
    stage_seconds: f32,
    stages: u8,
}

#[derive(Message)]
struct Harvested {
    plot: Entity,
    yield_item: u32,
}

fn grow(time: Res<Time<Fixed>>, mut crops: Query<&mut Crop>) {
    let dt = time.delta_secs();
    for mut crop in &mut crops {
        if crop.stage + 1 >= crop.stages {
            continue;
        }
        crop.elapsed += dt;
        if crop.elapsed >= crop.stage_seconds {
            crop.elapsed = 0.0;
            crop.stage += 1;
        }
    }
}

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