Skip to main content

UnitDef

Struct UnitDef 

Source
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

FieldStruct fieldNotes
ididRequired
namenameRequired
groupgroup
iconicon
modelmodel
behaviourbehaviourAI behaviour name
colcollision_mode
colxrcollision_x_radius
colyrcollision_y_radius
healthhealth
healthchangehealth_change
matmaterial
damagedamage
speedspeed
turnspeedturn_speed
eyeseye_height
storestoreHunger/thirst capacity
maxweightmax_weight
rangeperception_range
attackrangeattack_range
territoryterritory
searchratiosearch_ratio
lootlootMultiple values
sfxsfxSound set name
statestate
alignalign
scalescale
fxfx
colorcolor
alphaalpha
shineshininess
autofadeauto_fade
rideoffsetride_offset
accelerationvehicle
frictionvehicle
steeringvehicle
maxdepthvehicle
flyspeedvehicle
ani_idle1…ani_specialanimations
loopmoveaniloop_move_anim
scriptscriptBlock
descriptiondescriptionBlock
editorin_editor

Fields§

§id: u32

Unique numeric identifier.

§name: String

Display name.

§group: String

Group / category (e.g. "animal", "human").

§icon: Option<String>

Path to the icon texture.

§model: Option<String>

Path to the 3D animated model.

§scale: f32

Uniform scale factor.

§fx: Option<u32>

Blitz3D FX flags.

§color: Option<[u8; 3]>

RGB colour tint.

§alpha: f32

Alpha transparency.

§shininess: Option<f32>

Shininess / specular.

§auto_fade: u32

Auto-fade distance.

§collision_mode: u32

Collision mode.

§collision_x_radius: f32

Collision X radius.

§collision_y_radius: f32

Collision Y radius.

§material: String

Material type.

§health: f32

Maximum hit points.

§health_change: Option<f32>

Health change per tick.

§damage: f32

Attack damage.

§speed: f32

Movement speed.

§turn_speed: f32

Rotation speed.

§eye_height: f32

Eye height (camera position for the player).

§store: f32

Maximum storable food/water capacity (hunger/thirst).

§max_weight: u32

Maximum carry weight.

§behaviour: Option<String>

Behaviour name (e.g. "raptor", "crab", "fish").

§perception_range: u32

Perception / detection range.

§attack_range: u32

Attack range.

§territory: u32

Territory radius.

§search_ratio: f32

Item search ratio.

§loot: Vec<LootEntry>

Items that can be looted from this unit.

§sfx: Option<String>

Sound set name.

§state: UnitState

State mode (same as objects: random or fixed offsets).

§align: u32

Alignment (0 = normal, 1 = water surface, …).

§ride_offset: f32

Vertical offset for the rider’s position.

§vehicle: Option<VehicleParams>

Vehicle physics parameters (only for rideable units).

§animations: UnitAnimations

All animation slots.

§loop_move_anim: bool

Whether to loop the move animation.

§script: Option<String>

Script attached to this unit.

§description: Option<String>

Editor description text.

§in_editor: bool

Whether this unit appears in the map editor.

Implementations§

Source§

impl UnitDef

Source

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.

Source

pub fn with_script(self, script: Option<String>) -> UnitDef

Attach a script (builder-style).

Source

pub fn with_description(self, description: Option<String>) -> UnitDef

Attach a description (builder-style).

Trait Implementations§

Source§

impl Clone for UnitDef

Source§

fn clone(&self) -> UnitDef

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UnitDef

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for UnitDef

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<UnitDef, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for UnitDef

Source§

fn eq(&self, other: &UnitDef) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for UnitDef

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for UnitDef

Auto Trait Implementations§

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> 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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.