Skip to main content

GameData

Trait GameData 

Source
pub trait GameData {
    type Tileset: TilesetTrait;
    type Map: MapTrait;
    type Palette: PaletteTrait;
    type TileMeta: TileMetaTrait;
    type Move: Copy + Eq + Hash + Debug;
    type Item: Copy + Eq + Hash + Debug;
    type Species: Copy + Eq + Hash + Debug;

    // Required methods
    fn tileset_provider(&self) -> &dyn TilesetProvider<Self::Tileset>;
    fn map_provider(&self) -> &dyn MapProvider<Self::Map>;
    fn palette_provider(&self) -> &dyn PaletteProvider<Self::Palette>;
    fn tile_metadata(&self) -> &dyn TileMetadata<Self::TileMeta>;
    fn render_data(
        &self,
    ) -> &dyn RenderData<Move = Self::Move, Item = Self::Item, Species = Self::Species>;
}
Expand description

Master trait that provides access to all game data subsystems.

GameData is the central dependency-injection point for the engine. Implementations supply concrete types for tilesets, maps, palettes, tile metadata, moves, items, and species, along with provider objects that serve the corresponding data.

§Type Parameters

  • Tileset — A TilesetTrait implementation (typically an enum of tileset IDs).
  • Map — A MapTrait implementation (typically an enum of map IDs).
  • Palette — A PaletteTrait implementation (typically an enum of palette IDs).
  • TileMeta — A TileMetaTrait implementation for tile collision lookups.
  • Move — The move/ability ID type (Copy + Eq + Hash + Debug).
  • Item — The item ID type (Copy + Eq + Hash + Debug).
  • Species — The species/monster ID type (Copy + Eq + Hash + Debug).

§Example

struct MonsterGameData;

impl GameData for MonsterGameData {
    type Tileset = TilesetId;
    type Map = MapId;
    type Palette = PaletteId;
    type TileMeta = TileMetaId;
    type Move = MoveId;
    type Item = ItemId;
    type Species = SpeciesId;

    fn tileset_provider(&self) -> &dyn TilesetProvider<Self::Tileset> {
        &MY_TILESET_PROVIDER
    }
    // ... etc
}

Required Associated Types§

Source

type Tileset: TilesetTrait

The tileset identifier type.

Source

type Map: MapTrait

The map identifier type.

Source

type Palette: PaletteTrait

The palette identifier type.

Source

type TileMeta: TileMetaTrait

The tile metadata identifier type.

Source

type Move: Copy + Eq + Hash + Debug

The move (ability/skill) identifier type.

Source

type Item: Copy + Eq + Hash + Debug

The item identifier type.

Source

type Species: Copy + Eq + Hash + Debug

The species (monster/character) identifier type.

Required Methods§

Source

fn tileset_provider(&self) -> &dyn TilesetProvider<Self::Tileset>

Returns a reference to the tileset data provider.

Source

fn map_provider(&self) -> &dyn MapProvider<Self::Map>

Returns a reference to the map data provider.

Source

fn palette_provider(&self) -> &dyn PaletteProvider<Self::Palette>

Returns a reference to the palette data provider.

Source

fn tile_metadata(&self) -> &dyn TileMetadata<Self::TileMeta>

Returns a reference to the tile metadata provider.

Source

fn render_data( &self, ) -> &dyn RenderData<Move = Self::Move, Item = Self::Item, Species = Self::Species>

Returns a reference to the render data provider.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§