#[non_exhaustive]pub struct NavMeshSet {
pub version: i32,
pub tiles_x: i32,
pub tiles_z: i32,
pub params: NavMeshParams,
pub tiles: Vec<SetTile>,
}Expand description
A .nm file: the mesh parameters and the tile records in file order.
Reading is sequential, as the game does it: the offset table is skipped (its size comes from
maxTiles) and its entries are not used, and numTiles records follow back to back. Writing
always produces version SET_VERSION and recomputes the offset table.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.version: i32The set version read from the file (7 or 9). Writing ignores this field and always writes
SET_VERSION.
tiles_x: i32Grid width in tiles.
tiles_z: i32Grid depth in tiles.
params: NavMeshParamsThe mesh parameters.
tiles: Vec<SetTile>The tile records, in file order.
Implementations§
Sourcepub fn read(r: &mut impl Read) -> Result<Self>
pub fn read(r: &mut impl Read) -> Result<Self>
Reads a set file. Rejects a bad magic, a version other than 7 or 9, numTiles > maxTiles,
negative counts, a record with tileRef == 0 or dataSize <= 0, a record running past the
end of the input, and any tile blob that TileData::parse rejects (spec 9.4).
The input is consumed up to the end of the last record; nothing is allocated from a length field before the input has delivered that many bytes.
§Errors
Returns an error for any of the rejections above, or when the reader fails.
Sourcepub fn write(&self, w: &mut impl Write) -> Result<()>
pub fn write(&self, w: &mut impl Write) -> Result<()>
Writes the file: version SET_VERSION, the offset table of spec 9.1 (offsets relative to
the first record, 0xFFFFFFFF for empty slots) and the records in tiles order.
§Errors
Returns an error, before writing anything, for a negative maxTiles, more tiles than
maxTiles, a tile_ref of 0, a tile whose slot is >= maxTiles or used twice, or offsets
above 0xFFFFFFFE; or when the writer fails.
Sourcepub fn write_atomic(&self, path: &Path) -> Result<()>
pub fn write_atomic(&self, path: &Path) -> Result<()>
Writes the file atomically (spec 9.6, ruling 11): into a uniquely named temporary file in the
target’s directory, then sync_all, then a rename over path. An interrupted or failed
write leaves the previous file untouched and removes the temporary file.
§Errors
Returns an error when NavMeshSet::write fails or the file cannot be created, synced or
renamed.
Trait Implementations§
Source§fn clone(&self) -> NavMeshSet
fn clone(&self) -> NavMeshSet
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§fn default() -> NavMeshSet
fn default() -> NavMeshSet
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().