Jazz2::Editor::TilePrefab struct

A stamp of tiles kept with a tile set under a name, to paint it in any level of the tile set.

Tiles of the tile set are kept by their index, tiles of extra tile sets by the name of their tile set, so they're found in another level that has the same tile set too. Animated tiles and tiles of a tile set the level has in itself belong to a single level, they're left out. Prefabs are kept in the rules of the tile set, Tilesets/<name>.rules, a JSON file found as tile sets are — the user content first — and saved into the user content.

A prefab can have tiles of other layers too, by their position from the layer it's used on, and events, by their offset from its top left corner (see LayeredStamp), those off the grid in pixels, in "offgrid". Older versions read only its tiles, or only the events on the grid.

Public types

struct Tile
Tile of a prefab.
struct LayerTiles
Tiles of another layer.
struct PrefabEvent
Event of a prefab.

Public static functions

static auto Load(StringView tileSet, SmallVectorImpl<TilePrefab>& prefabs) -> bool
Reads the prefabs of a tile set, returns false if it has no rules.
static auto Save(StringView tileSet, const SmallVectorImpl<TilePrefab>& prefabs) -> bool
Writes the prefabs of a tile set into its rules in the user content, keeping the rest of them, nothing if they can't be read.
static auto FromStamp(const LevelDocument& document, const TileStamp& stamp, StringView name) -> TilePrefab
Makes a prefab of a stamp of a level.
static auto FromLayered(const LevelDocument& document, const LayeredStamp& stamp, std::int32_t mainLayer, StringView name) -> TilePrefab
Makes a prefab of a stamp of several layers of a level.

Public functions

auto HasLayers() const -> bool
Returns true if it has tiles of other layers or events, so it's placed as a stamp of several layers.
auto ToStamp(const LevelDocument& document) const -> TileStamp
Makes a stamp of a prefab for a level, tiles of tile sets the level doesn't have are left out.
auto ToLayered(const LevelDocument& document, std::int32_t mainLayer) const -> LayeredStamp
Makes a stamp of several layers of a prefab for a level, used on a layer by its position from the sprite layer.

Public variables

String Name
Name.
std::int32_t Width
Width in tiles.
std::int32_t Height
Height in tiles.
SmallVector<Tile, 0> Tiles
Tiles row by row.
SmallVector<LayerTiles, 0> ExtraLayers
Tiles of other layers.
SmallVector<PrefabEvent, 0> Events
Events.
SmallVector<PrefabEvent, 0> OffGridEvents
Events off the grid, PrefabEvent::Offset in pixels from the top left corner of the prefab.
std::int32_t DroppedTiles
Tiles of the stamp it was made of that were left out, they're of a tile set the level has in itself.

Function documentation

static TilePrefab Jazz2::Editor::TilePrefab::FromLayered(const LevelDocument& document, const LayeredStamp& stamp, std::int32_t mainLayer, StringView name)

Makes a prefab of a stamp of several layers of a level.

mainLayer is the layer the prefab is used on, by its position from the sprite layer, see LayeredStamp::Layer::FromSpriteLayer.

Variable documentation

std::int32_t Jazz2::Editor::TilePrefab::DroppedTiles

Tiles of the stamp it was made of that were left out, they're of a tile set the level has in itself.

Only set by FromStamp() and FromLayered(), it isn't kept with the prefab. Such tiles are of a single level, another level would take its own tiles at their place.