pub struct BuildingDef {
pub id: u32,
pub group: BuildingGroup,
pub object_id: Option<u32>,
pub unit_id: Option<u32>,
pub requirements: Vec<BuildingRequirement>,
pub build_space: Option<BuildSpace>,
pub building_site: Option<u32>,
pub at_objects: Vec<u32>,
pub script: Option<String>,
}Expand description
A single building recipe definition.
Represents one entry from a buildings*.inf file.
§.inf structure
id=N
group=...
objectid=N (or unitid=N for units)
req=item_id,count
buildspace=...
atobject=N
buildingsite=N
script=start
...
script=endFields§
§id: u32Unique numeric identifier for this building recipe.
group: BuildingGroupCategory group.
object_id: Option<u32>Object type ID that will be created when built.
Mutually exclusive with unit_id.
unit_id: Option<u32>Unit type ID that will be created when built.
Mutually exclusive with object_id.
requirements: Vec<BuildingRequirement>Materials required to build this structure.
build_space: Option<BuildSpace>Where this building can be placed.
building_site: Option<u32>Object type ID of the building site (buildplace) to use.
at_objects: Vec<u32>Object type IDs that must exist nearby for construction.
script: Option<String>Optional script executed when the building is finished.
Implementations§
Source§impl BuildingDef
impl BuildingDef
Sourcepub fn from_inf_fields(fields: &HashMap<String, Vec<String>>) -> Option<Self>
pub fn from_inf_fields(fields: &HashMap<String, Vec<String>>) -> Option<Self>
Construct a BuildingDef from the raw fields of a parsed .inf
entry.
Unknown or unparseable fields are silently ignored; missing
required fields (id) return None.
Sourcepub fn with_script(self, script: Option<String>) -> Self
pub fn with_script(self, script: Option<String>) -> Self
Attach a script to this building recipe (builder-style).
Trait Implementations§
Source§impl Clone for BuildingDef
impl Clone for BuildingDef
Source§fn clone(&self) -> BuildingDef
fn clone(&self) -> BuildingDef
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more