pub struct ItemDef {Show 24 fields
pub id: u32,
pub name: String,
pub group: ItemGroup,
pub icon: String,
pub model: Option<String>,
pub material: Material,
pub weight: u32,
pub description: Option<String>,
pub color: Option<[u8; 3]>,
pub scale: Option<f32>,
pub fx: Option<u32>,
pub alpha: Option<f32>,
pub shininess: Option<f32>,
pub blend: Option<u32>,
pub durability: Option<f32>,
pub health_change: Option<f32>,
pub behaviour: Option<String>,
pub damage: Option<String>,
pub speed: Option<f32>,
pub drag: Option<f32>,
pub rate: Option<u32>,
pub weapon_state: Option<String>,
pub radius: Option<f32>,
pub collision: Option<u32>,
}Expand description
Full definition of a single item type.
Represents one entry from an item .inf file, serialisable to/from
RON, JSON, or any serde-compatible format.
Most fields are optional and default to None — only the identity
fields (id, name, icon) are required for construction via
from_inf_fields.
§Construction from .inf fields
use std::collections::HashMap;
use openstranded_common_items::ItemDef;
let mut fields = HashMap::new();
fields.insert("id".into(), vec!["2".into()]);
fields.insert("name".into(), vec!["small Crystal".into()]);
fields.insert("icon".into(), vec!["gfx\\crystal01.bmp".into()]);
fields.insert("group".into(), vec!["material".into()]);
fields.insert("mat".into(), vec!["stone".into()]);
fields.insert("weight".into(), vec!["200".into()]);
let item = ItemDef::from_inf_fields(&fields).unwrap();
assert_eq!(item.id, 2);Fields§
§id: u32Unique numeric identifier.
name: StringDisplay name.
group: ItemGroupCategory group.
icon: StringPath to the icon texture (.png after conversion).
model: Option<String>Path to the 3D model (.glb after conversion).
material: MaterialBase material type.
weight: u32Weight in grams.
description: Option<String>Short description / info text.
color: Option<[u8; 3]>RGB colour tint.
scale: Option<f32>Uniform scale factor.
fx: Option<u32>Blitz3D FX flags.
alpha: Option<f32>Alpha transparency.
shininess: Option<f32>Shininess / specular intensity.
blend: Option<u32>Blend mode.
durability: Option<f32>Item durability / hit points.
health_change: Option<f32>Health change when consumed.
behaviour: Option<String>Behaviour type string (e.g. "throw", "blade", "ammo:51").
damage: Option<String>Damage value (number or formula string).
speed: Option<f32>Projectile speed or weapon range.
drag: Option<f32>Air drag for projectiles.
rate: Option<u32>Fire rate / use cooldown in milliseconds.
weapon_state: Option<String>Weapon state effect (e.g. "intoxication").
radius: Option<f32>Pick radius for collision.
collision: Option<u32>Collision type index.
Implementations§
Source§impl ItemDef
impl ItemDef
Sourcepub fn from_inf_fields(fields: &HashMap<String, Vec<String>>) -> Option<ItemDef>
pub fn from_inf_fields(fields: &HashMap<String, Vec<String>>) -> Option<ItemDef>
Construct an ItemDef from the raw fields of a parsed .inf entry.
This is the main entry point for WASM plugins that receive
registry data in the InfEntry format and want to convert it
to a strongly-typed ItemDef.
Unknown or unparseable fields are silently ignored; missing
required fields (id, name, icon) return None.