pub struct TuningProfile {
pub rules: u32,
pub motion: MotionTuning,
pub difficulty: f32,
pub assists: Assists,
}Fields§
§rules: u32Host-authored rules identity. Different games must use different IDs.
motion: MotionTuning§difficulty: f32Host difficulty multiplier; never a graphics-quality setting.
assists: AssistsImplementations§
Source§impl TuningProfile
impl TuningProfile
pub const fn rally() -> TuningProfile
pub const fn arena() -> TuningProfile
pub fn validated(self) -> Result<TuningProfile, SaveError>
Sourcepub fn diff(
&self,
candidate: &TuningProfile,
) -> Result<TuningDiff, TuningDiffError>
pub fn diff( &self, candidate: &TuningProfile, ) -> Result<TuningDiff, TuningDiffError>
Preview changes from this profile to candidate, without mutating either.
Validates the current profile, then the candidate, then checks matching
rules IDs. Errors identify the failed step in that order. Unlike
Self::replace, which may repair an invalid current profile, this method
requires both sides to be valid so every reported value is in range.
The preview owns copies; it neither applies changes nor schedules them. Hosts still choose an appropriate restart/checkpoint for replacement.
use ferravex_play::tuning::{TuningChange, TuningField, TuningProfile};
let mut current = TuningProfile::rally();
let mut candidate = current;
candidate.assists.steering = 0.5;
let preview = current.diff(&candidate).unwrap();
assert!(!preview.is_empty());
assert_eq!(preview.changes().collect::<Vec<_>>(), vec![TuningChange {
field: TuningField::Steering,
before: 0.0,
after: 0.5,
}]);
assert_eq!(current.assists.steering, 0.0);
// At a host-selected restart/checkpoint, after reviewing the changes:
current.replace(candidate).unwrap();
assert!(current.diff(&candidate).unwrap().is_empty());use ferravex_play::tuning::{TuningDiffError, TuningProfile};
let current = TuningProfile::rally();
assert!(matches!(current.diff(&TuningProfile::arena()),
Err(TuningDiffError::RulesMismatch { current: 1, candidate: 2 })));
let mut invalid = current;
invalid.assists.aim = f32::NAN;
assert!(matches!(current.diff(&invalid), Err(TuningDiffError::InvalidCandidate)));Sourcepub fn replace(&mut self, candidate: TuningProfile) -> Result<(), SaveError>
pub fn replace(&mut self, candidate: TuningProfile) -> Result<(), SaveError>
Transactional replacement; reject profiles belonging to another ruleset.
Sourcepub fn fingerprint(self) -> Result<u64, SaveError>
pub fn fingerprint(self) -> Result<u64, SaveError>
Include in record/replay contexts so assisted or differently tuned runs cannot silently replace records made under different handling rules.
Trait Implementations§
Source§impl Clone for TuningProfile
impl Clone for TuningProfile
Source§fn clone(&self) -> TuningProfile
fn clone(&self) -> TuningProfile
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more