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>
impl<'a> UtiSnapshot<'a>
Sourcepub fn properties(&self) -> &[DecodedProperty]
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.
Sourcepub fn is_armor(&self) -> bool
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.
Sourcepub fn is_weapon(&self) -> bool
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.
Sourcepub fn is_consumable(&self) -> bool
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.
Sourcepub fn equip_slot_mask(&self) -> Option<u32>
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.
Sourcepub fn model_type(&self) -> Option<u8>
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.
Sourcepub fn has_property_kind(&self, filter: PropertyKindFilter) -> bool
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.
Sourcepub fn ability_bonuses(&self) -> impl Iterator<Item = (u16, i32)> + '_
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.
Sourcepub fn damage_bonuses(&self) -> impl Iterator<Item = (u16, i32)> + '_
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.
Sourcepub fn damage_immunities(&self) -> impl Iterator<Item = (u16, i32)> + '_
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.