Skip to main content

UtiSnapshot

Struct UtiSnapshot 

Source
pub struct UtiSnapshot<'a> { /* private fields */ }
Expand description

Snapshot view over a Uti, resolved against a per-scope context.

Built by UtiProjection::snapshot (or Uti::snapshot as a single-scope shortcut). Holds the projection’s typed DecodedProperty variants plus the cached resolutions the view’s query methods need.

All query methods take &self and read from this cached snapshot. The snapshot does not retain the TwoDaCache borrow once constructed; to query under a different scope, build a fresh snapshot from the same projection.

Combat / equip queries (is_weapon, is_consumable, equip_slot_mask, model_type) read against a cached baseitems.2da row taken at snapshot time. When that 2DA is unavailable or the item’s base_item does not resolve to a row, those queries return false / None as appropriate.

Implementations§

Source§

impl<'a> UtiSnapshot<'a>

Source

pub fn properties(&self) -> &[DecodedProperty]

Returns the typed-variant decoded properties as a borrowed slice.

The order matches the source Uti::properties ordering; callers that need a particular property look it up by index or filter the slice.

Source

pub fn is_armor(&self) -> bool

Returns true when the source UTI’s BaseItem belongs to the canonical armor base-item set.

Pure delegation to Uti::is_armor – the underlying check is a const lookup against the hardcoded armor base-item id set and needs no 2DA cache. Re-exposed here so callers that only hold a UtiSnapshot do not have to reach back to the source Uti.

Source

pub fn is_weapon(&self) -> bool

Returns true when the item’s baseitems.2da row marks it as a wielded weapon (weaponwield > 0).

Returns false when baseitems.2da is unavailable, the base_item does not resolve to a row, or the cell is missing / unparseable.

Source

pub fn is_consumable(&self) -> bool

Returns true when the item is consumable, defined by the engine’s signal stacking > 1 (stim packs, grenades, med kits all stack; equipment does not).

Returns false when baseitems.2da is unavailable, the base_item does not resolve to a row, or the cell is missing / unparseable.

Source

pub fn equip_slot_mask(&self) -> Option<u32>

Returns the item’s equipable-slot bitmask from baseitems.2da#equipableslots, parsed from its hex-string form.

Returns None when baseitems.2da is unavailable, the base_item does not resolve to a row, or the cell is missing / unparseable.

Source

pub fn model_type(&self) -> Option<u8>

Returns the item’s model-type id from baseitems.2da#modeltype.

The value gates whether the engine consults the UTI’s TextureVar field (only when model_type == 1 per the UTI engine audit). Returns None when baseitems.2da is unavailable, the base_item does not resolve to a row, or the cell is missing / unparseable.

Source

pub fn has_property_kind(&self, filter: PropertyKindFilter) -> bool

Returns true when any decoded property on this item falls into the given PropertyKindFilter family.

Unknown variants never match any filter; consumers wanting to inspect unknown property kinds should walk Self::properties directly. For exact-variant queries (a specific kind rather than a family), pattern-match against the typed DecodedProperty variants directly.

Source

pub fn ability_bonuses(&self) -> impl Iterator<Item = (u16, i32)> + '_

Iterates this item’s DecodedProperty::AbilityBonus properties, yielding (subtype_id, magnitude) pairs.

subtype_id indexes into iprp_abilities.2da (vanilla rows 0..=5 cover STR/DEX/CON/INT/WIS/CHA). magnitude is the resolved bonus value from iprp_bonuscost.2da#Value at row cost_value, per the cost-table magnitude resolution subsection of docs/src/formats/gff/uti.md. The cost-table index is hardcoded by the engine handler for this kind, so the property’s cost_table field is ignored.

Properties whose magnitude could not be resolved at snapshot time are silently skipped.

Source

pub fn damage_bonuses(&self) -> impl Iterator<Item = (u16, i32)> + '_

Iterates this item’s DecodedProperty::DamageBonus properties, yielding (subtype_id, magnitude) pairs.

subtype_id indexes into iprp_damagetype.2da. magnitude is cost_value taken directly: per the audit, the engine’s ApplyDamageBonus handler bypasses cost-table dispatch and reads CostValue as the damage amount.

Properties whose magnitude could not be resolved at snapshot time are silently skipped.

Source

pub fn damage_immunities(&self) -> impl Iterator<Item = (u16, i32)> + '_

Iterates this item’s DecodedProperty::DamageImmunity properties, yielding (subtype_id, magnitude) pairs.

subtype_id indexes into iprp_damagetype.2da (which damage type the immunity applies to). magnitude is read by walking the dynamic cost-table dispatch chain (iprp_costtable.2da[cost_table]#Name -> per-cost 2DA at row cost_value, column Value), per the cost-table magnitude resolution subsection of docs/src/formats/gff/uti.md. The cost-table index is read from each property’s cost_table field, so mod-extended cost tables resolve through the same path.

Properties whose magnitude could not be resolved at snapshot time are silently skipped.

Trait Implementations§

Source§

impl<'a> Debug for UtiSnapshot<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for UtiSnapshot<'a>

§

impl<'a> RefUnwindSafe for UtiSnapshot<'a>

§

impl<'a> Send for UtiSnapshot<'a>

§

impl<'a> Sync for UtiSnapshot<'a>

§

impl<'a> Unpin for UtiSnapshot<'a>

§

impl<'a> UnsafeUnpin for UtiSnapshot<'a>

§

impl<'a> UnwindSafe for UtiSnapshot<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.