pub struct LevelDataManager {
path: Option<PathBuf>,
data: LevelData,
dirty: bool,
}Expand description
Manages level data persistence for a world.
Fields§
§path: Option<PathBuf>Path to the level.toml file.
data: LevelDataCached level data.
dirty: boolWhether data has been modified since last save.
Implementations§
Source§impl LevelDataManager
impl LevelDataManager
Sourcepub async fn new(
world_dir: Option<impl AsRef<Path>>,
seed: i64,
difficulty: Difficulty,
generation: WorldGenerationSettings,
) -> Result<Self>
pub async fn new( world_dir: Option<impl AsRef<Path>>, seed: i64, difficulty: Difficulty, generation: WorldGenerationSettings, ) -> Result<Self>
Creates a new level data manager for the given world directory.
If level.toml exists, it will be loaded (the provided seed is ignored).
Otherwise, new data will be created with the provided seed.
Sourcepub async fn load_seed_or_default(
world_dir: Option<impl AsRef<Path>>,
default_seed: i64,
) -> Result<i64>
pub async fn load_seed_or_default( world_dir: Option<impl AsRef<Path>>, default_seed: i64, ) -> Result<i64>
Loads the saved world seed from level.toml, or returns the provided default.
Sourcepub const fn data_mut(&mut self) -> &mut LevelData
pub const fn data_mut(&mut self) -> &mut LevelData
Gets a mutable reference to the level data and marks it as dirty.
Sourcepub const fn is_dirty(&self) -> bool
pub const fn is_dirty(&self) -> bool
Returns whether the data has been modified since last save.
Sourcepub const fn mark_dirty(&mut self)
pub const fn mark_dirty(&mut self)
Marks the data as dirty (needs saving).
Sourcepub async fn save(&mut self) -> Result<()>
pub async fn save(&mut self) -> Result<()>
Saves the level data to disk if it has been modified.
Sourcepub const fn set_game_time(&mut self, time: i64)
pub const fn set_game_time(&mut self, time: i64)
Sets the game time.
Sourcepub(crate) const fn world_clocks(&self) -> &WorldClockManager
pub(crate) const fn world_clocks(&self) -> &WorldClockManager
Returns this world’s clock manager.
Sourcepub(crate) const fn world_clocks_mut(&mut self) -> &mut WorldClockManager
pub(crate) const fn world_clocks_mut(&mut self) -> &mut WorldClockManager
Returns this world’s mutable clock manager and marks level data dirty.
Sourcepub const fn clear_weather_time(&self) -> i32
pub const fn clear_weather_time(&self) -> i32
Gets the clear weather time
Sourcepub const fn set_clear_weather_time(&mut self, time: i32)
pub const fn set_clear_weather_time(&mut self, time: i32)
Sets the clear weather time
Sourcepub const fn set_rain_time(&mut self, time: i32)
pub const fn set_rain_time(&mut self, time: i32)
Sets the rain time
Sourcepub const fn thunder_time(&self) -> i32
pub const fn thunder_time(&self) -> i32
Gets the thunder time
Sourcepub const fn set_thunder_time(&mut self, time: i32)
pub const fn set_thunder_time(&mut self, time: i32)
Sets the thunder time
Sourcepub const fn is_raining(&self) -> bool
pub const fn is_raining(&self) -> bool
Checks if it’s raining
Sourcepub const fn set_raining(&mut self, raining: bool)
pub const fn set_raining(&mut self, raining: bool)
Sets whether it’s raining
Sourcepub const fn is_thundering(&self) -> bool
pub const fn is_thundering(&self) -> bool
Checks if it’s thundering
Sourcepub const fn set_thundering(&mut self, thundering: bool)
pub const fn set_thundering(&mut self, thundering: bool)
Sets whether it’s thundering
Auto Trait Implementations§
impl !RefUnwindSafe for LevelDataManager
impl !UnwindSafe for LevelDataManager
impl Freeze for LevelDataManager
impl Send for LevelDataManager
impl Sync for LevelDataManager
impl Unpin for LevelDataManager
impl UnsafeUnpin for LevelDataManager
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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 moreArc<SyncMutex<>>