pub struct GroupFormation { /* private fields */ }Expand description
A single formation definition specifying how units should be arranged.
Each formation includes AI usage criteria, unit requirements, and a set of formation blocks that define where different unit types should be positioned.
Implementations§
Source§impl GroupFormation
impl GroupFormation
Sourcepub fn add_container(
&mut self,
parent_id: Option<u32>,
position: (f32, f32),
format: GroupFormationsFormat,
) -> Result<u32>
pub fn add_container( &mut self, parent_id: Option<u32>, position: (f32, f32), format: GroupFormationsFormat, ) -> Result<u32>
Adds a container with the defaults used by vanilla files at the end of the formation.
§Arguments
parent_id- Block to position the container relative to, orNonefor an absolute container.position- Offset from the parent for relative containers, or position for absolute ones.format- Format of the file, to create a valid entity preference.
§Returns
The id of the new block.
§Errors
Returns an error if the parent doesn’t exist.
Sourcepub fn reparent(
&mut self,
block_id: u32,
parent_id: Option<u32>,
params: &LayoutParams,
) -> Result<()>
pub fn reparent( &mut self, block_id: u32, parent_id: Option<u32>, params: &LayoutParams, ) -> Result<()>
Changes the parent of a container, keeping its simulated position when possible.
§Arguments
block_id- The container to edit.parent_id- The new parent, orNoneto turn it into an absolute container.params- The simulated deployment used to keep the container in place.
§Errors
Returns an error if a block doesn’t exist, the edited block is a span, or the new parent depends on the edited block.
Sourcepub fn move_block(
&mut self,
block_id: u32,
center: (f32, f32),
grid_step: f32,
params: &LayoutParams,
) -> Result<()>
pub fn move_block( &mut self, block_id: u32, center: (f32, f32), grid_step: f32, params: &LayoutParams, ) -> Result<()>
Moves a container so its simulated center lands on the target, snapping its offset or position to a grid.
§Arguments
block_id- The container to move.center- Target position of the container’s center.grid_step- Size of the grid to snap to, or 0 to not snap.params- The simulated deployment used to compute the offset.
§Errors
Returns an error if the block doesn’t exist, is a span, or it or its parent can’t be positioned.
Sourcepub fn move_blocks(
&mut self,
block_ids: &[u32],
delta: (f32, f32),
grid_step: f32,
params: &LayoutParams,
) -> Result<()>
pub fn move_blocks( &mut self, block_ids: &[u32], delta: (f32, f32), grid_step: f32, params: &LayoutParams, ) -> Result<()>
Moves several blocks by the same distance, snapping their offsets or positions to a grid.
Spans are moved by moving their members. Blocks that depend on another moved block already move with it, so they’re left untouched.
§Arguments
block_ids- The blocks to move.delta- Distance to move them.grid_step- Size of the grid to snap to, or 0 to not snap.params- The simulated deployment used to compute the offsets.
§Errors
Returns an error if a block doesn’t exist, or a moved block or its parent can’t be positioned.
Sourcepub fn delete_blocks(
&mut self,
block_ids: &[u32],
params: &LayoutParams,
) -> Result<()>
pub fn delete_blocks( &mut self, block_ids: &[u32], params: &LayoutParams, ) -> Result<()>
Deletes blocks, re-attaching the containers positioned relative to them to their closest surviving ancestor.
Spans left without members are deleted too. Containers left without ancestors become absolute.
§Arguments
block_ids- The blocks to delete.params- The simulated deployment used to keep re-attached containers in place.
§Errors
Returns an error if any of the blocks doesn’t exist.
Sourcepub fn delete_subtree(
&mut self,
block_id: u32,
params: &LayoutParams,
) -> Result<()>
pub fn delete_subtree( &mut self, block_id: u32, params: &LayoutParams, ) -> Result<()>
Deletes a block, all the containers positioned relative to it, recursively, and the spans left without members.
§Arguments
block_id- The root of the subtree to delete.params- The simulated deployment used to keep re-attached containers in place.
§Errors
Returns an error if the block doesn’t exist.
Sourcepub fn sort_blocks(&mut self)
pub fn sort_blocks(&mut self)
Reorders the blocks so each one comes after the blocks it depends on.
Blocks keep their current order when possible, and blocks in reference cycles are moved to the end.
Sourcepub fn depends_on(&self, block_id: u32, target_id: u32) -> bool
pub fn depends_on(&self, block_id: u32, target_id: u32) -> bool
Source§impl GroupFormation
impl GroupFormation
Sourcepub fn layout(&self, params: &LayoutParams) -> HashMap<u32, LayoutRect>
pub fn layout(&self, params: &LayoutParams) -> HashMap<u32, LayoutRect>
Source§impl GroupFormation
impl GroupFormation
Sourcepub fn validate(&self) -> Vec<ValidationIssue>
pub fn validate(&self) -> Vec<ValidationIssue>
Checks the blocks of this formation for consistency problems.
§Returns
A list of the issues found, in block order.
Source§impl GroupFormation
impl GroupFormation
Sourcepub fn ai_priority(&self) -> &f32
pub fn ai_priority(&self) -> &f32
AI priority value for selecting this formation (higher = more preferred).
Sourcepub fn ai_purpose(&self) -> &AIPurpose
pub fn ai_purpose(&self) -> &AIPurpose
Bitflags indicating when this formation should be used (attack, defend, naval, etc.).
Sourcepub fn min_unit_category_percentage(&self) -> &Vec<MinUnitCategoryPercentage>
pub fn min_unit_category_percentage(&self) -> &Vec<MinUnitCategoryPercentage>
Minimum percentage requirements for unit categories in this formation.
Sourcepub fn ai_supported_subcultures(&self) -> &Vec<String>
pub fn ai_supported_subcultures(&self) -> &Vec<String>
List of supported subcultures (introduced in Rome 2).
If non-empty, this formation is only available to armies from these subcultures.
Sourcepub fn ai_supported_factions(&self) -> &Vec<String>
pub fn ai_supported_factions(&self) -> &Vec<String>
List of supported factions (introduced in Rome 2).
If non-empty, this formation is only available to armies from these factions.
Sourcepub fn group_formation_blocks(&self) -> &Vec<GroupFormationBlock>
pub fn group_formation_blocks(&self) -> &Vec<GroupFormationBlock>
Formation blocks defining unit positions and arrangements.
Source§impl GroupFormation
impl GroupFormation
Sourcepub fn ai_priority_mut(&mut self) -> &mut f32
pub fn ai_priority_mut(&mut self) -> &mut f32
AI priority value for selecting this formation (higher = more preferred).
Sourcepub fn ai_purpose_mut(&mut self) -> &mut AIPurpose
pub fn ai_purpose_mut(&mut self) -> &mut AIPurpose
Bitflags indicating when this formation should be used (attack, defend, naval, etc.).
Sourcepub fn min_unit_category_percentage_mut(
&mut self,
) -> &mut Vec<MinUnitCategoryPercentage>
pub fn min_unit_category_percentage_mut( &mut self, ) -> &mut Vec<MinUnitCategoryPercentage>
Minimum percentage requirements for unit categories in this formation.
Sourcepub fn ai_supported_subcultures_mut(&mut self) -> &mut Vec<String>
pub fn ai_supported_subcultures_mut(&mut self) -> &mut Vec<String>
List of supported subcultures (introduced in Rome 2).
If non-empty, this formation is only available to armies from these subcultures.
Sourcepub fn ai_supported_factions_mut(&mut self) -> &mut Vec<String>
pub fn ai_supported_factions_mut(&mut self) -> &mut Vec<String>
List of supported factions (introduced in Rome 2).
If non-empty, this formation is only available to armies from these factions.
Sourcepub fn group_formation_blocks_mut(&mut self) -> &mut Vec<GroupFormationBlock>
pub fn group_formation_blocks_mut(&mut self) -> &mut Vec<GroupFormationBlock>
Formation blocks defining unit positions and arrangements.
Source§impl GroupFormation
impl GroupFormation
Sourcepub fn set_ai_priority(&mut self, val: f32) -> &mut Self
pub fn set_ai_priority(&mut self, val: f32) -> &mut Self
AI priority value for selecting this formation (higher = more preferred).
Sourcepub fn set_ai_purpose(&mut self, val: AIPurpose) -> &mut Self
pub fn set_ai_purpose(&mut self, val: AIPurpose) -> &mut Self
Bitflags indicating when this formation should be used (attack, defend, naval, etc.).
Sourcepub fn set_min_unit_category_percentage(
&mut self,
val: Vec<MinUnitCategoryPercentage>,
) -> &mut Self
pub fn set_min_unit_category_percentage( &mut self, val: Vec<MinUnitCategoryPercentage>, ) -> &mut Self
Minimum percentage requirements for unit categories in this formation.
Sourcepub fn set_ai_supported_subcultures(&mut self, val: Vec<String>) -> &mut Self
pub fn set_ai_supported_subcultures(&mut self, val: Vec<String>) -> &mut Self
List of supported subcultures (introduced in Rome 2).
If non-empty, this formation is only available to armies from these subcultures.
Sourcepub fn set_ai_supported_factions(&mut self, val: Vec<String>) -> &mut Self
pub fn set_ai_supported_factions(&mut self, val: Vec<String>) -> &mut Self
List of supported factions (introduced in Rome 2).
If non-empty, this formation is only available to armies from these factions.
Sourcepub fn set_group_formation_blocks(
&mut self,
val: Vec<GroupFormationBlock>,
) -> &mut Self
pub fn set_group_formation_blocks( &mut self, val: Vec<GroupFormationBlock>, ) -> &mut Self
Formation blocks defining unit positions and arrangements.
Source§impl GroupFormation
impl GroupFormation
Sourcepub fn new(name: &str, format: GroupFormationsFormat) -> Self
pub fn new(name: &str, format: GroupFormationsFormat) -> Self
Trait Implementations§
Source§impl Clone for GroupFormation
impl Clone for GroupFormation
Source§fn clone(&self) -> GroupFormation
fn clone(&self) -> GroupFormation
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 GroupFormation
impl Debug for GroupFormation
Source§impl Default for GroupFormation
impl Default for GroupFormation
Source§fn default() -> GroupFormation
fn default() -> GroupFormation
Source§impl<'de> Deserialize<'de> for GroupFormation
impl<'de> Deserialize<'de> for GroupFormation
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 PartialEq for GroupFormation
impl PartialEq for GroupFormation
Source§impl Serialize for GroupFormation
impl Serialize for GroupFormation
impl StructuralPartialEq for GroupFormation
Auto Trait Implementations§
impl Freeze for GroupFormation
impl RefUnwindSafe for GroupFormation
impl Send for GroupFormation
impl Sync for GroupFormation
impl Unpin for GroupFormation
impl UnsafeUnpin for GroupFormation
impl UnwindSafe for GroupFormation
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.