bevy_a5 0.1.2

A Bevy plugin providing A5 geospatial pentagonal cells for floating origin use and spatial queries
Documentation
//! Ergonomic command extensions for spawning A5-anchored entities.
//!
//! Mirrors the `BigSpaceCommands::spawn_big_space` pattern from `big_space`.
//! Add `use bevy_a5::commands_ext::BevyA5Commands;` to bring the extensions
//! into scope.
//!
//! Multi-planet TODO: today there is exactly one global planet (configured
//! via `PlanetSettings`). Once a `Planet` component is introduced, these
//! helpers will gain a `spawn_planet(...)` method that returns a child
//! builder for entities anchored to that specific planet.

use bevy_ecs::prelude::*;
use bevy_ecs::system::EntityCommands;

use crate::cell::GeoCell;
use crate::origin::FloatingOrigin;

/// Extension trait providing ergonomic spawners for A5-anchored entities.
pub trait BevyA5Commands<'w, 's> {
    /// Spawn a [`FloatingOrigin`] entity at `cell` with the default recenter
    /// threshold. Bevy's required-component system auto-inserts a default
    /// `Transform` and `GlobalTransform`.
    fn spawn_floating_origin(&mut self, cell: GeoCell) -> EntityCommands<'_>;

    /// Spawn a cell-anchored entity (no `FloatingOrigin` marker). Useful for
    /// scenery placed at cell centres.
    fn spawn_cell_anchor(&mut self, cell: GeoCell) -> EntityCommands<'_>;
}

impl<'w, 's> BevyA5Commands<'w, 's> for Commands<'w, 's> {
    fn spawn_floating_origin(&mut self, cell: GeoCell) -> EntityCommands<'_> {
        self.spawn((FloatingOrigin::default(), cell))
    }

    fn spawn_cell_anchor(&mut self, cell: GeoCell) -> EntityCommands<'_> {
        self.spawn(cell)
    }
}