pub struct MapManager { /* private fields */ }Expand description
A manager struct that can read and write celeste maps.
Implementations§
Source§impl MapManager
impl MapManager
pub fn default_parsers(&mut self)
Source§impl MapManager
impl MapManager
Sourcepub fn new(reader: impl Read) -> Result<Self, MapReadError>
pub fn new(reader: impl Read) -> Result<Self, MapReadError>
Creates a new MapManager reading in a celeste map from the passed reader
Sourcepub fn parse_map(&self) -> Result<MapRoot, MapElementParsingError>
pub fn parse_map(&self) -> Result<MapRoot, MapElementParsingError>
Parse the map passed in the constructor using any registered parsers when needed
Sourcepub fn verbose_parse(&self) -> Result<MapRoot, MapElementParsingError>
pub fn verbose_parse(&self) -> Result<MapRoot, MapElementParsingError>
Same as parse_map but when compiled with debug_assertions will
print debug information about the parser
Sourcepub fn encode_map(&mut self, name: impl ToString, root: &MapRoot)
pub fn encode_map(&mut self, name: impl ToString, root: &MapRoot)
Encode the map data back into a RawMap. The raw map is stored in the manager itself.
Sourcepub fn add_parser<T: MapElement>(&mut self)
pub fn add_parser<T: MapElement>(&mut self)
Allows the MapManager to parse a new type of MapElement.
All MapElement implementations in this crate can be added via MapManager::default_parsers.
This is used exclusively for parsing DynMapElements during calls to MapParser::parse_any_element any calls to MapParser::parse_element or MapParser::parse_all_elements will work even if a parser is never registered.
This generally should not be called with any Option<T>, as that will conflict with the parser for T.
There is no place in the vanilla elements where having a DynMapElement be optional makes sense and so
no Option<T> impls are registered by default.
Sourcepub fn add_entity_parser<T: Entity>(&mut self)
pub fn add_entity_parser<T: Entity>(&mut self)
Allows the MapManager to parse a new type of Entity
Acts the same as (add_parser)MapManager::add_parser but for entities
Sourcepub fn map(&self) -> &RawMap
pub fn map(&self) -> &RawMap
Gets a reference to the RawMap stored in the manager.
This is initialized in the constructor and modified in encode_map
Sourcepub fn add_trigger_parser<T: Trigger>(&mut self)
pub fn add_trigger_parser<T: Trigger>(&mut self)
Allows the MapManager to parse a new type of Trigger
Acts the same as (add_parser)MapManager::add_parser but for triggers