pub struct DataRegistry { /* private fields */ }Expand description
Registry of game data loaded from RON files.
Currently supports unit templates. Will expand to buildings, tech trees, weapons, etc.
Implementations§
Source§impl DataRegistry
impl DataRegistry
Sourcepub fn load_units_from_dir(dir: &Path) -> Result<Self, Box<DataLoadError>>
pub fn load_units_from_dir(dir: &Path) -> Result<Self, Box<DataLoadError>>
Load all unit templates from RON files in the given directory.
Each .ron file in the directory is parsed as a UnitTemplate.
The filename (without extension) becomes the lookup key.
Sourcepub fn load_unit_from_str(
key: &str,
ron_str: &str,
) -> Result<Self, Box<DataLoadError>>
pub fn load_unit_from_str( key: &str, ron_str: &str, ) -> Result<Self, Box<DataLoadError>>
Load a single unit template from a RON string.
Sourcepub fn unit(&self, name: &str) -> Option<&UnitTemplate>
pub fn unit(&self, name: &str) -> Option<&UnitTemplate>
Get a unit template by name.
Sourcepub fn unit_count(&self) -> usize
pub fn unit_count(&self) -> usize
Returns the number of loaded unit templates.
Sourcepub fn merge(&mut self, other: DataRegistry)
pub fn merge(&mut self, other: DataRegistry)
Merge another registry into this one.
Trait Implementations§
Source§impl Debug for DataRegistry
impl Debug for DataRegistry
Auto Trait Implementations§
impl Freeze for DataRegistry
impl RefUnwindSafe for DataRegistry
impl Send for DataRegistry
impl Sync for DataRegistry
impl Unpin for DataRegistry
impl UnsafeUnpin for DataRegistry
impl UnwindSafe for DataRegistry
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
Mutably borrows from an owned value. Read more