pub struct Unit { /* private fields */ }Expand description
A struct represents a character or other interactive item in a game scene.
Implementations§
Source§impl Unit
impl Unit
Sourcepub fn set_playable(&mut self, val: &dyn IPlayable)
pub fn set_playable(&mut self, val: &dyn IPlayable)
Sets the property that references a “Playable” object for managing the animation state and playback of the “Unit”.
Sourcepub fn get_playable(&self) -> Playable
pub fn get_playable(&self) -> Playable
Gets the property that references a “Playable” object for managing the animation state and playback of the “Unit”.
Sourcepub fn set_detect_distance(&mut self, val: f32)
pub fn set_detect_distance(&mut self, val: f32)
Sets the property that specifies the maximum distance at which the “Unit” can detect other “Unit” or objects.
Sourcepub fn get_detect_distance(&self) -> f32
pub fn get_detect_distance(&self) -> f32
Gets the property that specifies the maximum distance at which the “Unit” can detect other “Unit” or objects.
Sourcepub fn set_attack_range(&mut self, val: &Size)
pub fn set_attack_range(&mut self, val: &Size)
Sets the property that specifies the size of the attack range for the “Unit”.
Sourcepub fn get_attack_range(&self) -> Size
pub fn get_attack_range(&self) -> Size
Gets the property that specifies the size of the attack range for the “Unit”.
Sourcepub fn set_face_right(&mut self, val: bool)
pub fn set_face_right(&mut self, val: bool)
Sets the boolean property that specifies whether the “Unit” is facing right or not.
Sourcepub fn is_face_right(&self) -> bool
pub fn is_face_right(&self) -> bool
Gets the boolean property that specifies whether the “Unit” is facing right or not.
Sourcepub fn set_receiving_decision_trace(&mut self, val: bool)
pub fn set_receiving_decision_trace(&mut self, val: bool)
Sets the boolean property that specifies whether the “Unit” is receiving a trace of the decision tree for debugging purposes.
Sourcepub fn is_receiving_decision_trace(&self) -> bool
pub fn is_receiving_decision_trace(&self) -> bool
Gets the boolean property that specifies whether the “Unit” is receiving a trace of the decision tree for debugging purposes.
Sourcepub fn set_decision_tree(&mut self, val: &str)
pub fn set_decision_tree(&mut self, val: &str)
Sets the string property that specifies the decision tree to use for the “Unit’s” AI behavior. the decision tree object will be searched in The singleton instance Data.store.
Sourcepub fn get_decision_tree(&self) -> String
pub fn get_decision_tree(&self) -> String
Gets the string property that specifies the decision tree to use for the “Unit’s” AI behavior. the decision tree object will be searched in The singleton instance Data.store.
Sourcepub fn is_on_surface(&self) -> bool
pub fn is_on_surface(&self) -> bool
Gets whether the “Unit” is currently on a surface or not.
Sourcepub fn get_ground_sensor(&self) -> Sensor
pub fn get_ground_sensor(&self) -> Sensor
Gets the “Sensor” object for detecting ground surfaces.
Sourcepub fn get_detect_sensor(&self) -> Sensor
pub fn get_detect_sensor(&self) -> Sensor
Gets the “Sensor” object for detecting other “Unit” objects or physics bodies in the game world.
Sourcepub fn get_attack_sensor(&self) -> Sensor
pub fn get_attack_sensor(&self) -> Sensor
Gets the “Sensor” object for detecting other “Unit” objects within the attack senser area.
Sourcepub fn get_unit_def(&self) -> Dictionary
pub fn get_unit_def(&self) -> Dictionary
Gets the “Dictionary” object for defining the properties and behavior of the “Unit”.
Sourcepub fn get_current_action(&self) -> UnitAction
pub fn get_current_action(&self) -> UnitAction
Gets the property that specifies the current action being performed by the “Unit”.
Sourcepub fn get_height(&self) -> f32
pub fn get_height(&self) -> f32
Gets the height of the “Unit”.
Sourcepub fn get_entity(&self) -> Entity
pub fn get_entity(&self) -> Entity
Gets the “Entity” object for representing the “Unit” in the ECS system.
Sourcepub fn attach_action(&mut self, name: &str) -> UnitAction
pub fn attach_action(&mut self, name: &str) -> UnitAction
Sourcepub fn remove_action(&mut self, name: &str)
pub fn remove_action(&mut self, name: &str)
Removes the UnitAction with the specified name from the Unit.
§Arguments
name- The name of theUnitActionto remove.
Sourcepub fn remove_all_actions(&mut self)
pub fn remove_all_actions(&mut self)
Removes all “UnitAction” objects from the “Unit”.
Sourcepub fn get_action(&mut self, name: &str) -> Option<UnitAction>
pub fn get_action(&mut self, name: &str) -> Option<UnitAction>
Sourcepub fn each_action(&mut self, visitor_func: Box<dyn FnMut(&UnitAction)>)
pub fn each_action(&mut self, visitor_func: Box<dyn FnMut(&UnitAction)>)
Calls the specified function for each UnitAction attached to the Unit.
§Arguments
visitorFunc- A function to call for eachUnitAction.
Sourcepub fn new(
unit_def: &Dictionary,
physics_world: &dyn IPhysicsWorld,
entity: &Entity,
pos: &Vec2,
rot: f32,
) -> Unit
pub fn new( unit_def: &Dictionary, physics_world: &dyn IPhysicsWorld, entity: &Entity, pos: &Vec2, rot: f32, ) -> Unit
A method that creates a new Unit object.
§Arguments
unit_def- ADictionaryobject that defines the properties and behavior of theUnit.physics_world- APhysicsWorldobject that represents the physics simulation world.entity- AnEntityobject that represents theUnitin ECS system.pos- AVec2object that specifies the initial position of theUnit.rot- A number that specifies the initial rotation of theUnit.
§Returns
- The newly created
Unitobject.
Sourcepub fn with_store(
unit_def_name: &str,
physics_world_name: &str,
entity: &Entity,
pos: &Vec2,
rot: f32,
) -> Unit
pub fn with_store( unit_def_name: &str, physics_world_name: &str, entity: &Entity, pos: &Vec2, rot: f32, ) -> Unit
A method that creates a new Unit object.
§Arguments
unit_def_name- A string that specifies the name of theUnitdefinition to retrieve fromData.storetable.physics_world_name- A string that specifies the name of thePhysicsWorldobject to retrieve fromData.storetable.entity- AnEntityobject that represents theUnitin ECS system.pos- AVec2object that specifies the initial position of theUnit.rot- An optional number that specifies the initial rotation of theUnit(default is 0.0).
§Returns
- The newly created
Unitobject.
Trait Implementations§
Source§impl IBody for Unit
impl IBody for Unit
Source§fn get_world(&self) -> PhysicsWorld
fn get_world(&self) -> PhysicsWorld
Source§fn get_body_def(&self) -> BodyDef
fn get_body_def(&self) -> BodyDef
Source§fn set_velocity_x(&mut self, val: f32)
fn set_velocity_x(&mut self, val: f32)
Source§fn get_velocity_x(&self) -> f32
fn get_velocity_x(&self) -> f32
Source§fn set_velocity_y(&mut self, val: f32)
fn set_velocity_y(&mut self, val: f32)
Source§fn get_velocity_y(&self) -> f32
fn get_velocity_y(&self) -> f32
Source§fn set_velocity(&mut self, val: &Vec2)
fn set_velocity(&mut self, val: &Vec2)
Vec2.Source§fn get_velocity(&self) -> Vec2
fn get_velocity(&self) -> Vec2
Vec2.Source§fn set_angular_rate(&mut self, val: f32)
fn set_angular_rate(&mut self, val: f32)
Source§fn get_angular_rate(&self) -> f32
fn get_angular_rate(&self) -> f32
Source§fn set_linear_damping(&mut self, val: f32)
fn set_linear_damping(&mut self, val: f32)
Source§fn get_linear_damping(&self) -> f32
fn get_linear_damping(&self) -> f32
Source§fn set_angular_damping(&mut self, val: f32)
fn set_angular_damping(&mut self, val: f32)
Source§fn get_angular_damping(&self) -> f32
fn get_angular_damping(&self) -> f32
Source§fn set_receiving_contact(&mut self, val: bool)
fn set_receiving_contact(&mut self, val: bool)
Source§fn is_receiving_contact(&self) -> bool
fn is_receiving_contact(&self) -> bool
Source§fn apply_linear_impulse(&mut self, impulse: &Vec2, pos: &Vec2)
fn apply_linear_impulse(&mut self, impulse: &Vec2, pos: &Vec2)
Source§fn apply_angular_impulse(&mut self, impulse: f32)
fn apply_angular_impulse(&mut self, impulse: f32)
Source§fn get_sensor_by_tag(&mut self, tag: i32) -> Sensor
fn get_sensor_by_tag(&mut self, tag: i32) -> Sensor
Source§fn remove_sensor_by_tag(&mut self, tag: i32) -> bool
fn remove_sensor_by_tag(&mut self, tag: i32) -> bool
Source§fn remove_sensor(&mut self, sensor: &Sensor) -> bool
fn remove_sensor(&mut self, sensor: &Sensor) -> bool
Source§fn attach(&mut self, fixture_def: &FixtureDef)
fn attach(&mut self, fixture_def: &FixtureDef)
Source§fn attach_sensor(&mut self, tag: i32, fixture_def: &FixtureDef) -> Sensor
fn attach_sensor(&mut self, tag: i32, fixture_def: &FixtureDef) -> Sensor
Source§impl INode for Unit
impl INode for Unit
Source§fn set_angle_x(&mut self, val: f32)
fn set_angle_x(&mut self, val: f32)
Source§fn get_angle_x(&self) -> f32
fn get_angle_x(&self) -> f32
Source§fn set_angle_y(&mut self, val: f32)
fn set_angle_y(&mut self, val: f32)
Source§fn get_angle_y(&self) -> f32
fn get_angle_y(&self) -> f32
Source§fn set_scale_x(&mut self, val: f32)
fn set_scale_x(&mut self, val: f32)
Source§fn get_scale_x(&self) -> f32
fn get_scale_x(&self) -> f32
Source§fn set_scale_y(&mut self, val: f32)
fn set_scale_y(&mut self, val: f32)
Source§fn get_scale_y(&self) -> f32
fn get_scale_y(&self) -> f32
Source§fn set_position(&mut self, val: &Vec2)
fn set_position(&mut self, val: &Vec2)
Source§fn get_position(&self) -> Vec2
fn get_position(&self) -> Vec2
Source§fn set_skew_x(&mut self, val: f32)
fn set_skew_x(&mut self, val: f32)
Source§fn get_skew_x(&self) -> f32
fn get_skew_x(&self) -> f32
Source§fn set_skew_y(&mut self, val: f32)
fn set_skew_y(&mut self, val: f32)
Source§fn get_skew_y(&self) -> f32
fn get_skew_y(&self) -> f32
Source§fn set_visible(&mut self, val: bool)
fn set_visible(&mut self, val: bool)
Source§fn is_visible(&self) -> bool
fn is_visible(&self) -> bool
Source§fn set_anchor(&mut self, val: &Vec2)
fn set_anchor(&mut self, val: &Vec2)
Source§fn get_anchor(&self) -> Vec2
fn get_anchor(&self) -> Vec2
Source§fn set_height(&mut self, val: f32)
fn set_height(&mut self, val: f32)
Source§fn get_height(&self) -> f32
fn get_height(&self) -> f32
Source§fn set_opacity(&mut self, val: f32)
fn set_opacity(&mut self, val: f32)
Source§fn get_opacity(&self) -> f32
fn get_opacity(&self) -> f32
Source§fn set_color3(&mut self, val: &Color3)
fn set_color3(&mut self, val: &Color3)
Source§fn get_color3(&self) -> Color3
fn get_color3(&self) -> Color3
Source§fn set_pass_opacity(&mut self, val: bool)
fn set_pass_opacity(&mut self, val: bool)
Source§fn is_pass_opacity(&self) -> bool
fn is_pass_opacity(&self) -> bool
Source§fn set_pass_color3(&mut self, val: bool)
fn set_pass_color3(&mut self, val: bool)
Source§fn is_pass_color3(&self) -> bool
fn is_pass_color3(&self) -> bool
Source§fn set_transform_target(&mut self, val: &dyn INode)
fn set_transform_target(&mut self, val: &dyn INode)
Source§fn get_transform_target(&self) -> Option<Node>
fn get_transform_target(&self) -> Option<Node>
Source§fn set_scheduler(&mut self, val: &Scheduler)
fn set_scheduler(&mut self, val: &Scheduler)
Source§fn get_scheduler(&self) -> Scheduler
fn get_scheduler(&self) -> Scheduler
Source§fn get_children(&self) -> Option<Array>
fn get_children(&self) -> Option<Array>
Source§fn get_parent(&self) -> Option<Node>
fn get_parent(&self) -> Option<Node>
Source§fn is_running(&self) -> bool
fn is_running(&self) -> bool
Source§fn is_scheduled(&self) -> bool
fn is_scheduled(&self) -> bool
Source§fn get_action_count(&self) -> i32
fn get_action_count(&self) -> i32
Source§fn get_data(&self) -> Dictionary
fn get_data(&self) -> Dictionary
Source§fn set_touch_enabled(&mut self, val: bool)
fn set_touch_enabled(&mut self, val: bool)
Source§fn is_touch_enabled(&self) -> bool
fn is_touch_enabled(&self) -> bool
Source§fn set_swallow_touches(&mut self, val: bool)
fn set_swallow_touches(&mut self, val: bool)
Source§fn is_swallow_touches(&self) -> bool
fn is_swallow_touches(&self) -> bool
Source§fn set_swallow_mouse_wheel(&mut self, val: bool)
fn set_swallow_mouse_wheel(&mut self, val: bool)
Source§fn is_swallow_mouse_wheel(&self) -> bool
fn is_swallow_mouse_wheel(&self) -> bool
Source§fn set_keyboard_enabled(&mut self, val: bool)
fn set_keyboard_enabled(&mut self, val: bool)
Source§fn is_keyboard_enabled(&self) -> bool
fn is_keyboard_enabled(&self) -> bool
Source§fn set_controller_enabled(&mut self, val: bool)
fn set_controller_enabled(&mut self, val: bool)
Source§fn is_controller_enabled(&self) -> bool
fn is_controller_enabled(&self) -> bool
Source§fn set_render_group(&mut self, val: bool)
fn set_render_group(&mut self, val: bool)
Source§fn is_render_group(&self) -> bool
fn is_render_group(&self) -> bool
Source§fn set_show_debug(&mut self, val: bool)
fn set_show_debug(&mut self, val: bool)
Source§fn is_show_debug(&self) -> bool
fn is_show_debug(&self) -> bool
Source§fn set_render_order(&mut self, val: i32)
fn set_render_order(&mut self, val: i32)
Source§fn get_render_order(&self) -> i32
fn get_render_order(&self) -> i32
Source§fn add_child_with_order_tag(&mut self, child: &dyn INode, order: i32, tag: &str)
fn add_child_with_order_tag(&mut self, child: &dyn INode, order: i32, tag: &str)
Source§fn add_child_with_order(&mut self, child: &dyn INode, order: i32)
fn add_child_with_order(&mut self, child: &dyn INode, order: i32)
Source§fn add_to_with_order_tag(
&mut self,
parent: &dyn INode,
order: i32,
tag: &str,
) -> Node
fn add_to_with_order_tag( &mut self, parent: &dyn INode, order: i32, tag: &str, ) -> Node
Source§fn add_to_with_order(&mut self, parent: &dyn INode, order: i32) -> Node
fn add_to_with_order(&mut self, parent: &dyn INode, order: i32) -> Node
Source§fn add_to(&mut self, parent: &dyn INode) -> Node
fn add_to(&mut self, parent: &dyn INode) -> Node
Source§fn remove_child(&mut self, child: &dyn INode, cleanup: bool)
fn remove_child(&mut self, child: &dyn INode, cleanup: bool)
Source§fn remove_child_by_tag(&mut self, tag: &str, cleanup: bool)
fn remove_child_by_tag(&mut self, tag: &str, cleanup: bool)
Source§fn remove_all_children(&mut self, cleanup: bool)
fn remove_all_children(&mut self, cleanup: bool)
Source§fn remove_from_parent(&mut self, cleanup: bool)
fn remove_from_parent(&mut self, cleanup: bool)
Source§fn move_to_parent(&mut self, parent: &dyn INode)
fn move_to_parent(&mut self, parent: &dyn INode)
Source§fn schedule(&mut self, update_func: Box<dyn FnMut(f64) -> bool>)
fn schedule(&mut self, update_func: Box<dyn FnMut(f64) -> bool>)
Source§fn unschedule(&mut self)
fn unschedule(&mut self)
Source§fn convert_to_node_space(&mut self, world_point: &Vec2) -> Vec2
fn convert_to_node_space(&mut self, world_point: &Vec2) -> Vec2
Source§fn convert_to_world_space(&mut self, node_point: &Vec2) -> Vec2
fn convert_to_world_space(&mut self, node_point: &Vec2) -> Vec2
Source§fn convert_to_window_space(
&mut self,
node_point: &Vec2,
callback: Box<dyn FnMut(&Vec2)>,
)
fn convert_to_window_space( &mut self, node_point: &Vec2, callback: Box<dyn FnMut(&Vec2)>, )
Source§fn each_child(
&mut self,
visitor_func: Box<dyn FnMut(&dyn INode) -> bool>,
) -> bool
fn each_child( &mut self, visitor_func: Box<dyn FnMut(&dyn INode) -> bool>, ) -> bool
Source§fn traverse(&mut self, visitor_func: Box<dyn FnMut(&dyn INode) -> bool>) -> bool
fn traverse(&mut self, visitor_func: Box<dyn FnMut(&dyn INode) -> bool>) -> bool
TraverseEnabled flag are not visited. Read more