vmf_forge/vmf_file/
merge.rs

1use super::VmfFile;
2
3impl VmfFile {
4    /// Merges the contents of another `VmfFile` into this one.
5    ///
6    /// This method combines the `visgroups`, `world` solids (both visible and hidden),
7    /// `entities`, `hiddens`, and `cordons` from the `other` `VmfFile` into the
8    /// current `VmfFile`.  `versioninfo`, `viewsettings`, and `cameras` are
9    /// *not* merged; the original values in `self` are retained.
10    ///
11    /// This method is experimental and its behavior may change in future versions.
12    /// It does not handle potential ID conflicts between the two VMF files.
13    ///
14    /// # Arguments
15    ///
16    /// * `other` - The `VmfFile` to merge into this one.
17    ///
18    /// # Example
19    ///
20    /// ```no_run
21    /// use vmf_forge::prelude::*;
22    ///
23    /// let mut vmf1 = VmfFile::open("map1.vmf").unwrap();
24    /// let vmf2 = VmfFile::open("map2.vmf").unwrap();
25    ///
26    /// vmf1.merge(vmf2);
27    ///
28    /// // vmf1 now contains the combined contents of both files.
29    /// ```
30    pub fn merge(&mut self, other: VmfFile) {
31        self.visgroups.groups.extend(other.visgroups.groups);
32        self.world.solids.extend(other.world.solids);
33        self.world.hidden.extend(other.world.hidden);
34
35        self.entities.extend(other.entities);
36        self.hiddens.extend(other.hiddens);
37
38        self.cordons.extend(other.cordons.cordons);
39    }
40}