pub struct VmfFile {
pub path: Option<String>,
pub versioninfo: VersionInfo,
pub visgroups: VisGroups,
pub viewsettings: ViewSettings,
pub world: World,
pub entities: Entities,
pub hiddens: Entities,
pub cameras: Cameras,
pub cordons: Cordons,
}Expand description
Represents a parsed VMF file.
Fields§
§path: Option<String>The path to the VMF file, if known.
versioninfo: VersionInfoThe version info of the VMF file.
visgroups: VisGroupsThe visgroups in the VMF file.
viewsettings: ViewSettingsThe view settings in the VMF file.
world: WorldThe world data in the VMF file.
entities: EntitiesThe entities in the VMF file.
The hidden entities in the VMF file.
cameras: CamerasThe camera data in the VMF file.
cordons: CordonsThe cordon data in the VMF file.
Implementations§
Source§impl VmfFile
impl VmfFile
Sourcepub fn parse(content: &str) -> VmfResult<Self>
pub fn parse(content: &str) -> VmfResult<Self>
Parses a VMF file from a string.
§Arguments
content- The string content of the VMF file.
§Returns
A VmfResult containing the parsed VmfFile or a VmfError if parsing fails.
§Examples
use vmf_forge::VmfFile;
let vmf_content = r#"
versioninfo
{
"editorversion" "400"
"editorbuild" "8000"
"mapversion" "1"
"formatversion" "100"
"prefab" "0"
}
"#;
let vmf_file = VmfFile::parse(vmf_content);
assert!(vmf_file.is_ok());Sourcepub fn parse_file(file: &mut impl Read) -> VmfResult<Self>
pub fn parse_file(file: &mut impl Read) -> VmfResult<Self>
Parses a VMF file from a File.
§Arguments
file- TheFileto read from.
§Returns
A VmfResult containing the parsed VmfFile or a VmfError if parsing fails.
§Examples
use vmf_forge::VmfFile;
use std::fs::File;
let mut file = File::open("your_map.vmf").unwrap();
let vmf_file = VmfFile::parse_file(&mut file);
assert!(vmf_file.is_ok());Sourcepub fn save(&self, path: impl AsRef<Path>) -> VmfResult<()>
pub fn save(&self, path: impl AsRef<Path>) -> VmfResult<()>
Saves the VmfFile to a file at the specified path.
§Arguments
path- The path to save the VMF file to.
§Returns
A VmfResult indicating success or a VmfError if an error occurs.
§Examples
use vmf_forge::VmfFile;
let vmf_file = VmfFile::open("your_map.vmf").unwrap();
let result = vmf_file.save("new_map.vmf");
assert!(result.is_ok());Source§impl VmfFile
impl VmfFile
Sourcepub fn merge(&mut self, other: VmfFile)
pub fn merge(&mut self, other: VmfFile)
Merges the contents of another VmfFile into this one.
This method combines the visgroups, world solids (both visible and hidden),
entities, hiddens, and cordons from the other VmfFile into the
current VmfFile. versioninfo, viewsettings, and cameras are
not merged; the original values in self are retained.
This method is experimental and its behavior may change in future versions. It does not handle potential ID conflicts between the two VMF files.
§Arguments
other- TheVmfFileto merge into this one.
§Example
use vmf_forge::prelude::*;
let mut vmf1 = VmfFile::open("map1.vmf").unwrap();
let vmf2 = VmfFile::open("map2.vmf").unwrap();
vmf1.merge(vmf2);
// vmf1 now contains the combined contents of both files.Source§impl VmfFile
impl VmfFile
Sourcepub fn get_entities_in_visgroup(
&self,
group_id: i32,
include_children: bool,
) -> Option<impl Iterator<Item = &Entity> + '_>
pub fn get_entities_in_visgroup( &self, group_id: i32, include_children: bool, ) -> Option<impl Iterator<Item = &Entity> + '_>
Returns an iterator over entities (including hidden ones) belonging to the specified VisGroup ID.
§Arguments
group_id- The ID of the target VisGroup.include_children- If true, includes entities from all child VisGroups recursively.
§Returns
An Option containing an iterator yielding references to the matching Entity objects.
Returns None if no VisGroup with the given group_id is found.
Sourcepub fn get_entities_in_visgroup_mut(
&mut self,
group_id: i32,
include_children: bool,
) -> Option<impl Iterator<Item = &mut Entity> + '_>
pub fn get_entities_in_visgroup_mut( &mut self, group_id: i32, include_children: bool, ) -> Option<impl Iterator<Item = &mut Entity> + '_>
Returns a mutable iterator over entities (including hidden ones) belonging to the specified VisGroup ID.
§Arguments
group_id- The ID of the target VisGroup.include_children- If true, includes entities from all child VisGroups recursively.
§Returns
An Option containing an iterator yielding mutable references to the matching Entity objects.
Returns None if no VisGroup with the given group_id is found.
Sourcepub fn get_solids_in_visgroup(
&self,
group_id: i32,
include_children: bool,
) -> Option<impl Iterator<Item = &Solid> + '_>
pub fn get_solids_in_visgroup( &self, group_id: i32, include_children: bool, ) -> Option<impl Iterator<Item = &Solid> + '_>
Returns an iterator over world solids (visible and hidden) belonging to the specified VisGroup ID.
§Arguments
group_id- The ID of the target VisGroup.include_children- If true, includes solids from all child VisGroups recursively.
§Returns
An Option containing an iterator yielding references to the matching Solid objects.
Returns None if no VisGroup with the given group_id is found.
Sourcepub fn get_solids_in_visgroup_mut(
&mut self,
group_id: i32,
include_children: bool,
) -> Option<impl Iterator<Item = &mut Solid> + '_>
pub fn get_solids_in_visgroup_mut( &mut self, group_id: i32, include_children: bool, ) -> Option<impl Iterator<Item = &mut Solid> + '_>
Returns a mutable iterator over world solids (visible and hidden) belonging to the specified VisGroup ID.
§Arguments
group_id- The ID of the target VisGroup.include_children- If true, includes solids from all child VisGroups recursively.
§Returns
An Option containing an iterator yielding mutable references to the matching Solid objects.
Returns None if no VisGroup with the given group_id is found.