pub struct UnitDef {Show 39 fields
pub id: u32,
pub name: String,
pub group: String,
pub icon: Option<String>,
pub model: Option<String>,
pub scale: f32,
pub fx: Option<u32>,
pub color: Option<[u8; 3]>,
pub alpha: f32,
pub shininess: Option<f32>,
pub auto_fade: u32,
pub collision_mode: u32,
pub collision_x_radius: f32,
pub collision_y_radius: f32,
pub material: String,
pub health: f32,
pub health_change: Option<f32>,
pub damage: f32,
pub speed: f32,
pub turn_speed: f32,
pub eye_height: f32,
pub store: f32,
pub max_weight: u32,
pub behaviour: Option<String>,
pub perception_range: u32,
pub attack_range: u32,
pub territory: u32,
pub search_ratio: f32,
pub loot: Vec<LootEntry>,
pub sfx: Option<String>,
pub state: UnitState,
pub align: u32,
pub ride_offset: f32,
pub vehicle: Option<VehicleParams>,
pub animations: UnitAnimations,
pub loop_move_anim: bool,
pub script: Option<String>,
pub description: Option<String>,
pub in_editor: bool,
}Expand description
Full definition of a single unit type (creature, NPC, player, vehicle).
Represents one entry from a units*.inf file.
§.inf fields mapped
| Field | Struct field | Notes |
|---|---|---|
id | id | Required |
name | name | Required |
group | group | |
icon | icon | |
model | model | |
behaviour | behaviour | AI behaviour name |
col | collision_mode | |
colxr | collision_x_radius | |
colyr | collision_y_radius | |
health | health | |
healthchange | health_change | |
mat | material | |
damage | damage | |
speed | speed | |
turnspeed | turn_speed | |
eyes | eye_height | |
store | store | Hunger/thirst capacity |
maxweight | max_weight | |
range | perception_range | |
attackrange | attack_range | |
territory | territory | |
searchratio | search_ratio | |
loot | loot | Multiple values |
sfx | sfx | Sound set name |
state | state | |
align | align | |
scale | scale | |
fx | fx | |
color | color | |
alpha | alpha | |
shine | shininess | |
autofade | auto_fade | |
rideoffset | ride_offset | |
acceleration | vehicle | |
friction | vehicle | |
steering | vehicle | |
maxdepth | vehicle | |
flyspeed | vehicle | |
ani_idle1…ani_special | animations | |
loopmoveani | loop_move_anim | |
script | script | Block |
description | description | Block |
editor | in_editor |
Fields§
§id: u32Unique numeric identifier.
name: StringDisplay name.
group: StringGroup / category (e.g. "animal", "human").
icon: Option<String>Path to the icon texture.
model: Option<String>Path to the 3D animated model.
scale: f32Uniform scale factor.
fx: Option<u32>Blitz3D FX flags.
color: Option<[u8; 3]>RGB colour tint.
alpha: f32Alpha transparency.
shininess: Option<f32>Shininess / specular.
auto_fade: u32Auto-fade distance.
collision_mode: u32Collision mode.
collision_x_radius: f32Collision X radius.
collision_y_radius: f32Collision Y radius.
material: StringMaterial type.
health: f32Maximum hit points.
health_change: Option<f32>Health change per tick.
damage: f32Attack damage.
speed: f32Movement speed.
turn_speed: f32Rotation speed.
eye_height: f32Eye height (camera position for the player).
store: f32Maximum storable food/water capacity (hunger/thirst).
max_weight: u32Maximum carry weight.
behaviour: Option<String>Behaviour name (e.g. "raptor", "crab", "fish").
perception_range: u32Perception / detection range.
attack_range: u32Attack range.
territory: u32Territory radius.
search_ratio: f32Item search ratio.
loot: Vec<LootEntry>Items that can be looted from this unit.
sfx: Option<String>Sound set name.
state: UnitStateState mode (same as objects: random or fixed offsets).
align: u32Alignment (0 = normal, 1 = water surface, …).
ride_offset: f32Vertical offset for the rider’s position.
vehicle: Option<VehicleParams>Vehicle physics parameters (only for rideable units).
animations: UnitAnimationsAll animation slots.
loop_move_anim: boolWhether to loop the move animation.
script: Option<String>Script attached to this unit.
description: Option<String>Editor description text.
in_editor: boolWhether this unit appears in the map editor.
Implementations§
Source§impl UnitDef
impl UnitDef
Sourcepub fn from_inf_fields(fields: &HashMap<String, Vec<String>>) -> Option<UnitDef>
pub fn from_inf_fields(fields: &HashMap<String, Vec<String>>) -> Option<UnitDef>
Construct a UnitDef from raw .inf fields.
Returns None if required fields (id, name) are missing.
Sourcepub fn with_script(self, script: Option<String>) -> UnitDef
pub fn with_script(self, script: Option<String>) -> UnitDef
Attach a script (builder-style).
Sourcepub fn with_description(self, description: Option<String>) -> UnitDef
pub fn with_description(self, description: Option<String>) -> UnitDef
Attach a description (builder-style).