pub struct AssetVariationDb { /* private fields */ }Expand description
An asset variation database.
Implementations§
Source§impl AssetVariationDb
impl AssetVariationDb
Sourcepub fn to_xml(&self) -> String
pub fn to_xml(&self) -> String
Returns the database in the XML form of the packs: UTF-8, CRLF line ends, tab indentation and single-quoted attributes.
Sourcepub fn from_xml(xml: &str) -> Result<Self>
pub fn from_xml(xml: &str) -> Result<Self>
Reads a database from the XML form of the packs. Whitespace between elements doesn’t matter.
§Errors
Returns RLibError::DecodingAssetVariationDbXml if the XML is malformed, or doesn’t have the structure of the database.
Sourcepub fn from_environment_map(xml: &str) -> Result<Self>
pub fn from_environment_map(xml: &str) -> Result<Self>
Builds a database from its source in the Assembly Kit, raw_data/warscape_asset_variation_db/environment_map.xml.
Each environment_file lists the values it allows per category, comma-separated, and an empty or missing list allows every value.
The database gets the single entry environment. The categories go in a fixed order, with their values sorted:
the bit order the game’s tools use isn’t known, but it doesn’t change what matches.
§Errors
Returns RLibError::DecodingAssetVariationDbXml if the XML is malformed, has no environment_file, or more values than bits.
Source§impl AssetVariationDb
impl AssetVariationDb
Sourcepub fn serialise_version(&self) -> &u16
pub fn serialise_version(&self) -> &u16
Version of the format.
Sourcepub fn categories(&self) -> &Vec<VariationCategory>
pub fn categories(&self) -> &Vec<VariationCategory>
Categories of the conditions of a battle, with their values.
Sourcepub fn entries(&self) -> &Vec<VariationEntry>
pub fn entries(&self) -> &Vec<VariationEntry>
Lists of variations, by key.
Source§impl AssetVariationDb
impl AssetVariationDb
Sourcepub fn serialise_version_mut(&mut self) -> &mut u16
pub fn serialise_version_mut(&mut self) -> &mut u16
Version of the format.
Sourcepub fn categories_mut(&mut self) -> &mut Vec<VariationCategory>
pub fn categories_mut(&mut self) -> &mut Vec<VariationCategory>
Categories of the conditions of a battle, with their values.
Sourcepub fn entries_mut(&mut self) -> &mut Vec<VariationEntry>
pub fn entries_mut(&mut self) -> &mut Vec<VariationEntry>
Lists of variations, by key.
Source§impl AssetVariationDb
impl AssetVariationDb
Sourcepub fn set_serialise_version(&mut self, val: u16) -> &mut Self
pub fn set_serialise_version(&mut self, val: u16) -> &mut Self
Version of the format.
Sourcepub fn set_categories(&mut self, val: Vec<VariationCategory>) -> &mut Self
pub fn set_categories(&mut self, val: Vec<VariationCategory>) -> &mut Self
Categories of the conditions of a battle, with their values.
Sourcepub fn set_entries(&mut self, val: Vec<VariationEntry>) -> &mut Self
pub fn set_entries(&mut self, val: Vec<VariationEntry>) -> &mut Self
Lists of variations, by key.
Source§impl AssetVariationDb
impl AssetVariationDb
Sourcepub fn value_count(&self) -> usize
pub fn value_count(&self) -> usize
Amount of values of all the categories together.
Sourcepub fn category(&self, name: &str) -> Option<&VariationCategory>
pub fn category(&self, name: &str) -> Option<&VariationCategory>
Returns the category with the provided name, if any.
Sourcepub fn entry(&self, key: &str) -> Option<&VariationEntry>
pub fn entry(&self, key: &str) -> Option<&VariationEntry>
Returns the entry with the provided key, if any.
Sourcepub fn bit(&self, category: &str, value: &str) -> u32
pub fn bit(&self, category: &str, value: &str) -> u32
Bit of a value of a category, or 0 if the category or the value don’t exist.
Sourcepub fn query_mask(&self, query: &VariationQuery) -> u32
pub fn query_mask(&self, query: &VariationQuery) -> u32
Bits of a query.
Sourcepub fn matches(&self, key: &str, query: &VariationQuery) -> VariationMatches<'_>
pub fn matches(&self, key: &str, query: &VariationQuery) -> VariationMatches<'_>
Sourcepub fn matches_listed_map(
&self,
key: &str,
query: &VariationQuery,
) -> VariationMatches<'_>
pub fn matches_listed_map( &self, key: &str, query: &VariationQuery, ) -> VariationMatches<'_>
Returns the variations of a key that match a query, treating a map the database doesn’t list as unmatched.
The game adds no bit for a map it doesn’t list, so its first query matches every map. Tools that pick from
a list of maps want the default_map query instead, which this does.
§Arguments
key- Key of the entry, likeenvironment.query- Value chosen for each category.
§Returns
The matches.
Sourcepub fn allowed_values(&self, flags: u32) -> Vec<(&str, Vec<&str>)>
pub fn allowed_values(&self, flags: u32) -> Vec<(&str, Vec<&str>)>
Returns, per category, the values allowed by some flags. Flags 0 allow every value.
Sourcepub fn flags_for(&self, allowed: &BTreeMap<String, Vec<String>>) -> u32
pub fn flags_for(&self, allowed: &BTreeMap<String, Vec<String>>) -> u32
Returns the flags that allow exactly the provided values of each category. Categories left out allow all their values.
Sourcepub fn validate(&self) -> Vec<String>
pub fn validate(&self) -> Vec<String>
Checks the database for what makes it wrong for the game.
§Returns
A description of each problem: more values than bits, repeated names or values, no default_map, flags with bits
of no value, and variations that can never match.
Sourcepub fn add_value(&mut self, category: &str, value: &str) -> Result<()>
pub fn add_value(&mut self, category: &str, value: &str) -> Result<()>
Adds a value to a category, moving the bits of the flags of every variation so they keep allowing the same values.
A variation that allowed every value of the category, without being unconstrained, also allows the new one.
§Errors
Returns RLibError::AssetVariationDbEditRefused if the category doesn’t exist, the value is empty or already
exists, or every bit of the flags is in use.
Sourcepub fn remove_value(&mut self, category: &str, value: &str) -> Result<()>
pub fn remove_value(&mut self, category: &str, value: &str) -> Result<()>
Removes a value from a category, moving the bits of the flags of every variation so they keep allowing the same values.
§Errors
Returns RLibError::AssetVariationDbEditRefused if the category or the value don’t exist, if the value is the
default_map map, or if a variation would allow nothing else, as its flags would become 0, which allows everything.
Sourcepub fn rename_value(
&mut self,
category: &str,
from: &str,
to: &str,
) -> Result<()>
pub fn rename_value( &mut self, category: &str, from: &str, to: &str, ) -> Result<()>
Renames a value of a category. The flags don’t change.
§Errors
Returns RLibError::AssetVariationDbEditRefused if the category or the value don’t exist, or the new name is
empty or already exists.
Trait Implementations§
Source§impl Clone for AssetVariationDb
impl Clone for AssetVariationDb
Source§fn clone(&self) -> AssetVariationDb
fn clone(&self) -> AssetVariationDb
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AssetVariationDb
impl Debug for AssetVariationDb
Source§impl Decodeable for AssetVariationDb
impl Decodeable for AssetVariationDb
Source§impl Default for AssetVariationDb
impl Default for AssetVariationDb
Source§fn default() -> AssetVariationDb
fn default() -> AssetVariationDb
Source§impl<'de> Deserialize<'de> for AssetVariationDb
impl<'de> Deserialize<'de> for AssetVariationDb
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Encodeable for AssetVariationDb
impl Encodeable for AssetVariationDb
Source§fn encode<W: WriteBytes>(
&mut self,
buffer: &mut W,
_extra_data: &Option<EncodeableExtraData<'_>>,
) -> Result<()>
fn encode<W: WriteBytes>( &mut self, buffer: &mut W, _extra_data: &Option<EncodeableExtraData<'_>>, ) -> Result<()>
Source§impl PartialEq for AssetVariationDb
impl PartialEq for AssetVariationDb
Source§impl Serialize for AssetVariationDb
impl Serialize for AssetVariationDb
impl StructuralPartialEq for AssetVariationDb
Auto Trait Implementations§
impl Freeze for AssetVariationDb
impl RefUnwindSafe for AssetVariationDb
impl Send for AssetVariationDb
impl Sync for AssetVariationDb
impl Unpin for AssetVariationDb
impl UnsafeUnpin for AssetVariationDb
impl UnwindSafe for AssetVariationDb
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().impl<T> Scalar for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.