[][src]Struct sulis_state::script::ScriptEntitySet

pub struct ScriptEntitySet {
    pub parent: usize,
    pub selected_point: Option<(i32, i32)>,
    pub affected_points: Vec<(i32, i32)>,
    pub indices: Vec<Option<usize>>,
    pub surface: Option<ScriptActiveSurface>,
}

Represents a set of ScriptEntities, which can be created from a variety of sources. This is passed to many script functions as a targets variable. It includes a parent ScriptEntity, a list of target ScriptEntities, optionally a selected point (for a targeter that has been activated), and optionally a list of affected points (again for a targeter).

num_targets() -> Int

Returns the number of targets in this set.

to_table() -> Table

Creates a table of this set. Iterating over the table will allow you to access each entity in this set.

Examples

  table = targets:to_table()
  for i = 1, #table do
   game:log("target: " .. table[i]:name())
  end

random_affected_points(frac: Float) -> Table

Returns a table of a randomly selected subset of the affected points in this set. The probability of any individual point ending up in the returned set is set by frac.

surface() -> ScriptActiveSurface

Returns the surface associated with this target set, if it is defined. Otherwise throws an error.

affected_points() -> Table

Returns a table containing all the affected points in this set.

Examples

  points = targets:affected_points()
  for i = 1, #points do
    point = points[i]
    game:log("point " .. point.x .. ", " .. point.y)
  end

selected_point() -> Table

Returns a table representing the selected point for this set, if one is defined. The table will have x and y elements defined. If there is no selected point, throws an error.

is_empty() -> Bool

Returns whether or not there are any targets in this ScriptEntitySet. Does not take affected points or selected_point into consideration.

first() -> ScriptEntity

Returns the first ScriptEntity as a target in this set, or throws an error if the set is empty.

parent() -> ScriptEntity

Returns the parent ScriptEntity of this set. When this is passed to a function as targets, usually, but not always, the parent argument is the same as this.

without_self() -> ScriptEntitySet

Creates a new ScriptEntitySet which contains all the data in this set, except it does not include the parent entity as a target.

visible_within(dist: Float) -> ScriptEntitySet

Creates a new ScriptEntitySet containing all the data in this set, except all targets that are not visible or are outside the specified dist from the parent are removed.

visible() -> ScriptEntitySet

Creates a new ScriptEntitySet with all the data from this set, except only targets that are visible to the parent are present.

hostile() -> ScriptEntitySet

Creates a new ScriptEntitySet with all the data from this set, except only targets that are hostile to the parent are present.

friendly() -> ScriptEntitySet

Creates a new ScriptEntitySet with all the data from this set, except only targets that are friendly to the parent are present.

hostile_to(faction: String) -> ScriptEntitySet

Creates a new ScriptEntitySet filtered to only those targets that are hostile to the specified Faction

friendly_to(faction: String) -> ScriptEntitySet

Creates a new ScriptEntitySet filtered to only those targets that are friendly to the specified Faction

touchable() -> ScriptEntitySet

Creates a new ScriptEntitySet with all the data from this set, except only targets which the parent can touch (without any weapon) are parents.

attackable() -> ScriptEntitySet

Creates a new ScriptEntitySet with all the data from this set, except only targets which the parent can attack with their current weapon are present. If the parent does not have enough AP or otherwise cannot attack, the set will be empty.

threatening() -> ScriptEntitySet

Creates a new ScriptEntitySet with all the data from this set, except only targets which can hit the parent with a melee weapon currently or in the future without moving are present.

Fields

parent: usizeselected_point: Option<(i32, i32)>affected_points: Vec<(i32, i32)>indices: Vec<Option<usize>>surface: Option<ScriptActiveSurface>

Implementations

impl ScriptEntitySet[src]

pub fn update_entity_refs_on_load(
    &mut self,
    entities: &HashMap<usize, Rc<RefCell<EntityState>>>
) -> Result<(), Error>
[src]

pub fn append(&mut self, other: &ScriptEntitySet)[src]

pub fn with_parent(parent: usize) -> ScriptEntitySet[src]

pub fn from_pair(
    parent: &Rc<RefCell<EntityState>>,
    target: &Rc<RefCell<EntityState>>
) -> ScriptEntitySet
[src]

pub fn new(
    parent: &Rc<RefCell<EntityState>>,
    entities: &[Option<Rc<RefCell<EntityState>>>]
) -> ScriptEntitySet
[src]

Trait Implementations

impl Clone for ScriptEntitySet[src]

impl Debug for ScriptEntitySet[src]

impl<'de> Deserialize<'de> for ScriptEntitySet[src]

impl Serialize for ScriptEntitySet[src]

impl UserData for ScriptEntitySet[src]

Auto Trait Implementations

impl RefUnwindSafe for ScriptEntitySet

impl Send for ScriptEntitySet

impl Sync for ScriptEntitySet

impl Unpin for ScriptEntitySet

impl UnwindSafe for ScriptEntitySet

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> From<T> for T[src]

impl<'lua, T> FromLua<'lua> for T where
    T: 'static + UserData + Clone
[src]

impl<'lua, T> FromLuaMulti<'lua> for T where
    T: FromLua<'lua>, 
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<'lua, T> ToLua<'lua> for T where
    T: 'static + UserData + Send
[src]

impl<'lua, T> ToLuaMulti<'lua> for T where
    T: ToLua<'lua>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]