pub struct Map { /* private fields */ }Expand description
A Wolf RPG Editor map (.mps) file.
Contains all information needed for rendering a level, from the single tiles to the events set to happen.
§Examples
use wolfrpg_map_parser::Map;
use std::fs;
match fs::read("filepath.mps") {
Ok(bytes) => {
let map: Map = Map::parse(&bytes);
// Data manipulation ...
}
Err(_) => {
// Error handling ...
}
}Implementations§
Source§impl Map
impl Map
Sourcepub fn parse(bytes: &[u8]) -> Self
pub fn parse(bytes: &[u8]) -> Self
Parse raw bytes into a Map struct.
This is the main driver that should be used when loading a .mps file. Using other methods is highly discouraged, unless you know what you are doing and need that extra bit of speed.
§Panics
This function will panic if the given bytes do not represent a valid map structure.
This might be caused by corrupt files, incompatible format updates and library bugs. In each of these cases, feel free to report an issue on GitHub.
§Examples
use wolfrpg_map_parser::Map;
use std::fs;
match fs::read("filepath.mps") {
Ok(bytes) => {
let map: Map = Map::parse(&bytes);
// Data manipulation ...
}
Err(_) => {
// Error handling ...
}
}Sourcepub fn tileset_mut(&mut self) -> &mut u32
pub fn tileset_mut(&mut self) -> &mut u32
Mutable reference accessor for Map::tileset.
Sourcepub fn width_mut(&mut self) -> &mut u32
pub fn width_mut(&mut self) -> &mut u32
Mutable reference accessor for Map::width.
Sourcepub fn height_mut(&mut self) -> &mut u32
pub fn height_mut(&mut self) -> &mut u32
Mutable reference accessor for Map::height.
Sourcepub fn layer1(&self) -> &Vec<u32>
pub fn layer1(&self) -> &Vec<u32>
The bottom-most layer of tiles.
Each layer is painted above the lower ones.
Sourcepub fn layer1_mut(&mut self) -> &mut Vec<u32>
pub fn layer1_mut(&mut self) -> &mut Vec<u32>
Mutable reference accessor for Map::layer1.
Sourcepub fn layer2(&self) -> &Vec<u32>
pub fn layer2(&self) -> &Vec<u32>
The middle layer of tiles.
Each layer is painted above the lower ones.
Sourcepub fn layer2_mut(&mut self) -> &mut Vec<u32>
pub fn layer2_mut(&mut self) -> &mut Vec<u32>
Mutable reference accessor for Map::layer2.
Sourcepub fn layer3(&self) -> &Vec<u32>
pub fn layer3(&self) -> &Vec<u32>
The top-most layer of tiles.
Each layer is painted above the lower ones.
Sourcepub fn layer3_mut(&mut self) -> &mut Vec<u32>
pub fn layer3_mut(&mut self) -> &mut Vec<u32>
Mutable reference accessor for Map::layer3.
Sourcepub fn events(&self) -> &Vec<Event>
pub fn events(&self) -> &Vec<Event>
A collection of all the events set on this map.
Events are painted above each other based on the following priority:
- If
Page::options::above_heroistrue, then the event has the highest priority. - If
Page::options::above_heroisfalseandPage::options::slip_throughisfalse, then the event has the second-highest priority. - if
Page::options::above_heroisfalseandPage::options::slip_throughistrue, then the event has the lowest-priority.
When events have the same priority, they are displayed in order of Event::id.
Sourcepub fn events_mut(&mut self) -> &mut Vec<Event>
pub fn events_mut(&mut self) -> &mut Vec<Event>
Mutable reference accessor for Map::events.