Crates.io | teloader |
lib.rs | teloader |
version | 0.1.0 |
source | src |
created_at | 2024-08-24 17:02:14.971655 |
updated_at | 2024-08-24 17:02:14.971655 |
description | Loader of Total Editor's level files (*.te3) |
homepage | |
repository | https://github.com/tynberry/total_editor_3_rs |
max_upload_size | |
id | 1350426 |
size | 30,721 |
This crate loads *.te3 files from Total Editor 3.
For examples you can look into the examples/ folder of this repository.
Or you can use this snippet.
use total_editor_rs::{
serde,
tiles::{dense::DenseTiles, sparse::SparseTiles},
};
fn main() {
// Loads the assets paths, entities and raw tiles.
let (entities, raw_tiles, assets) = serde::from_path("path/to/file").unwrap();
// Turns raw tiles into a more usable format.
// Dense format for random tile accesses.
let dense_tiles = DenseTiles::from_raw(&raw_tiles);
// Sparse format for iterations.
let sparse_tiles = SparseTiles::from_raw(&raw_tiles);
}
This snippet first loads entities, asset paths (textures and models) and raw tiles. Raw tiles represent tiles as is in the file and as such is not very useful.
Therefore it must be first converted into one of two structures.
DenseTiles
is a structure which allows O(1) random access of tiles at the cost
of including Empty tiles in its representation. This makes iteration slower
since you need to iterate through Empty tiles as well.
SparseTiles
is a structure which allows quick iteration by ignoring the Empty
tiles. This however slows random access of tiles as they must by found inside
the structure in O(n) time.
This crate has two features specifying what deserialization library you want to use.
Use serde
feature (default) if you want to use serde
and serde_json
.
Use nanoserde
feature if you want to use nanoserde
.
You can use both features and they only affect the underlying backend deserialization.