Crate spacetime_tiled

Crate spacetime_tiled 

Source
Expand description

Load Tiled maps into SpacetimeDB.

This library parses TMX files and stores them in SpacetimeDB tables. Since SpacetimeDB modules run in WASM without filesystem access, it includes an in-memory XML parser.

§Quick Start

use spacetimedb::{reducer, ReducerContext};
pub use spacetime_tiled::*;

#[reducer]
pub fn load_map(ctx: &ReducerContext) -> Result<(), String> {
    // Embed the TMX file at compile time
    const MAP_DATA: &str = include_str!("../assets/map.tmx");

    // Parse and store in database
    load_tmx_map_from_str(ctx, "level1", MAP_DATA)?;
    Ok(())
}

§WASM Limitations

SpacetimeDB modules can’t access the filesystem. Use load_tmx_map_from_str() with include_str!() to embed maps at compile time, or have clients send TMX content as reducer parameters.

Structs§

TiledLayer
Represents a layer in a Tiled map
TiledMap
Represents a Tiled map with its core metadata
TiledObject
Represents an object in an object layer
TiledProperty
Represents custom properties on any Tiled element
TiledTile
Represents a single tile in a tile layer
TiledTileset
Represents a tileset used by maps
tiled_layer__TableHandle
tiled_map__TableHandle
tiled_object__TableHandle
tiled_property__TableHandle
tiled_tile__TableHandle
tiled_tileset__TableHandle

Traits§

tiled_layer
tiled_map
tiled_object
tiled_property
tiled_tile
tiled_tileset

Functions§

load_tmx_map
Load a TMX map file into SpacetimeDB tables
load_tmx_map_from_str
Load a TMX map from a string into SpacetimeDB tables