pub struct LuaCommandable;Expand description
AI object which can be ordered commands. This can represent a UnitGroup (a set of multiple commandables) or can be a single Unit or SpiderUnit.
Implementations§
Source§impl LuaCommandable
impl LuaCommandable
Sourcepub fn commandable_members(&self) -> Vec<LuaCommandable>
pub fn commandable_members(&self) -> Vec<LuaCommandable>
Non recursively returns all members of this unit group.
Sourcepub fn distraction_command(&self) -> Command
pub fn distraction_command(&self) -> Command
The distraction command of this commandable, if any.
Sourcepub fn has_command(&self) -> bool
pub fn has_command(&self) -> bool
If this commandable has a command assigned.
Sourcepub fn is_script_driven(&self) -> bool
pub fn is_script_driven(&self) -> bool
Whether this unit group is controlled by a script or by the game engine. This can be changed using LuaCommandable::set_autonomous. Units created by LuaSurface::create_unit_group are considered script-driven.
Sourcepub fn is_unit_group(&self) -> bool
pub fn is_unit_group(&self) -> bool
If this commandable is UnitGroup.
Sourcepub fn members(&self) -> Vec<LuaEntity>
pub fn members(&self) -> Vec<LuaEntity>
All entity members of this unit group, recursive (if unit group is member of this unit group, its members will be returned here).
Sourcepub fn moving_state(&self) -> &str
pub fn moving_state(&self) -> &str
Current moving state of the commandable’s behavior
Sourcepub fn object_name(&self) -> &str
pub fn object_name(&self) -> &str
The class name of this object. Available even when valid is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct.
Sourcepub fn parent_group(&self) -> LuaCommandable
pub fn parent_group(&self) -> LuaCommandable
The unit group this commandable is a member of, if any.
Sourcepub fn position(&self) -> MapPosition
pub fn position(&self) -> MapPosition
Current position of this commandable.
If commandable is a UnitGroup, this can have different meanings depending on the group state. When the group is gathering, the position is the place of gathering. When the group is moving, the position is the expected position of its members along the path. When the group is attacking, it is the average position of its members.
Sourcepub fn surface(&self) -> LuaSurface
pub fn surface(&self) -> LuaSurface
Surface this commandable is on.
Sourcepub fn valid(&self) -> bool
pub fn valid(&self) -> bool
Is this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be false. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access.
Sourcepub fn add_member(&self, member: LuaAny)
pub fn add_member(&self, member: LuaAny)
Adds a member to this UnitGroup. Has the same effect as setting defines.command.group command on the member to join the group.
The member must have the same force be on the same surface as the group.
Sourcepub fn destroy(&self)
pub fn destroy(&self)
Destroys this commandable. If it is a unit group, members will not be destroyed, they will be merely unlinked from the group.
Sourcepub fn release_from_spawner(&self)
pub fn release_from_spawner(&self)
Release the commandable from the spawner. This allows the spawner to continue spawning additional units.
Sourcepub fn set_autonomous(&self)
pub fn set_autonomous(&self)
Make this group autonomous. Autonomous groups will automatically attack polluted areas. Autonomous groups aren’t considered to be script-driven.
Sourcepub fn set_command(&self, command: Command)
pub fn set_command(&self, command: Command)
Give this commandable a command.
Sourcepub fn set_distraction_command(&self, command: Command)
pub fn set_distraction_command(&self, command: Command)
Give this commandable a distraction command.
Sourcepub fn start_moving(&self)
pub fn start_moving(&self)
Make the group start moving even if some of its members haven’t yet arrived.
Trait Implementations§
Source§impl Clone for LuaCommandable
impl Clone for LuaCommandable
Source§fn clone(&self) -> LuaCommandable
fn clone(&self) -> LuaCommandable
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more