pub struct AvatarSpec {
pub body_height: f32,
/* private fields */
}Expand description
The resolved, portable description of an avatar: which part id fills each
slot, plus an overall body height. Part id 0 means “empty”. Serialize it
into a save, hand it to an AvatarBuilder to render.
This is the shared wire shape across the whole Pixygon ecosystem — the
same JSON the Unity AvatarSpec/AvatarData bridge and the web
@pixygon/avatar Studio speak (avatar-v0.1):
{ "bodyHeight": 0.5, "parts": { "Body": 11010001, "Jacket": 123456 } }Slot keys are the AvatarSlot names; values are the stable partIds
(AvatarAsset.partId — see manifest). Never key parts by name or
database id.
Fields§
§body_height: f320..1 — lerps the overall body scale.
Implementations§
Source§impl AvatarSpec
impl AvatarSpec
pub fn new() -> Self
Sourcepub fn get(&self, slot: AvatarSlot) -> u32
pub fn get(&self, slot: AvatarSlot) -> u32
Part id in slot, or 0 if empty.
Sourcepub fn set(&mut self, slot: AvatarSlot, part_id: u32)
pub fn set(&mut self, slot: AvatarSlot, part_id: u32)
Place part_id in slot (id 0 clears it).
pub fn has(&self, slot: AvatarSlot) -> bool
pub fn clear(&mut self, slot: AvatarSlot)
Sourcepub fn iter(&self) -> impl Iterator<Item = (AvatarSlot, u32)> + '_
pub fn iter(&self) -> impl Iterator<Item = (AvatarSlot, u32)> + '_
Iterate the filled (slot, part_id) pairs.
Sourcepub fn from_config(config: &HashMap<String, u32>) -> Self
pub fn from_config(config: &HashMap<String, u32>) -> Self
Build a spec from a flat slot-name → partId config (the shape the web
Studio saves and resolveAvatarConfig consumes). Unknown slot names and
zero ids are skipped.
Sourcepub fn to_config(&self) -> HashMap<String, u32>
pub fn to_config(&self) -> HashMap<String, u32>
The flat slot-name → partId view of this spec (filled slots only).