pub struct Fac {
pub factions: Vec<FacFaction>,
pub reputations: Vec<FacReputation>,
}Expand description
Typed FAC model built from/to [Gff] data.
Fields§
§factions: Vec<FacFaction>Faction roster (FactionList). A faction’s id is its index here.
reputations: Vec<FacReputation>Stored pairwise standings (RepList). Sparse: see Fac::reputation.
Implementations§
Source§impl Fac
impl Fac
Sourcepub fn reputation(&self, source: u32, target: u32) -> u8
pub fn reputation(&self, source: u32, target: u32) -> u8
Returns how source regards target.
Applies the sparse-matrix rule: a pair with no stored entry is
DEFAULT_REPUTATION. Ids are faction indices into
Self::factions; an id no faction occupies still answers with the
baseline, matching the engine rebuilding its matrix before applying
overrides.
Sourcepub fn reaction(&self, source: u32, target: u32) -> FacReaction
pub fn reaction(&self, source: u32, target: u32) -> FacReaction
Returns how source reacts to target.
Sourcepub fn faction(&self, id: u32) -> Option<&FacFaction>
pub fn faction(&self, id: u32) -> Option<&FacFaction>
Returns the faction at id, when the roster has one.
Sourcepub fn from_gff(gff: &Gff) -> Result<Self, FacError>
pub fn from_gff(gff: &Gff) -> Result<Self, FacError>
Builds typed FAC data from a parsed GFF container.
§Errors
Returns an error when the container is not a FAC (or generic GFF), or
when FactionList / RepList are present but are not lists.
Sourcepub fn to_gff(&self) -> Gff
pub fn to_gff(&self) -> Gff
Converts this typed FAC value into a GFF container.
Writes the table the way the engine’s own writer does, which means pairs at the default standing are dropped rather than emitted. The two forms are identical to the engine, but other tools read these files too, and a diff against a vanilla save should not show pairs the game would never have written.
Only pairs whose effective standing is the default are dropped, so a deliberately out-of-range value is still written out.