[−][src]Struct sulis_state::script::ScriptEntitySet
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: usize
selected_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]
&mut self,
entities: &HashMap<usize, Rc<RefCell<EntityState>>>
) -> Result<(), Error>
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]
parent: &Rc<RefCell<EntityState>>,
target: &Rc<RefCell<EntityState>>
) -> ScriptEntitySet
pub fn new(
parent: &Rc<RefCell<EntityState>>,
entities: &[Option<Rc<RefCell<EntityState>>>]
) -> ScriptEntitySet
[src]
parent: &Rc<RefCell<EntityState>>,
entities: &[Option<Rc<RefCell<EntityState>>>]
) -> ScriptEntitySet
Trait Implementations
impl Clone for ScriptEntitySet
[src]
fn clone(&self) -> ScriptEntitySet
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for ScriptEntitySet
[src]
impl<'de> Deserialize<'de> for ScriptEntitySet
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Serialize for ScriptEntitySet
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl UserData for ScriptEntitySet
[src]
fn add_methods<'lua, M: UserDataMethods<'lua, Self>>(methods: &mut M)
[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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<'lua, T> FromLua<'lua> for T where
T: 'static + UserData + Clone,
[src]
T: 'static + UserData + Clone,
impl<'lua, T> FromLuaMulti<'lua> for T where
T: FromLua<'lua>,
[src]
T: FromLua<'lua>,
pub fn from_lua_multi(
values: MultiValue<'lua>,
lua: Context<'lua>
) -> Result<T, Error>
[src]
values: MultiValue<'lua>,
lua: Context<'lua>
) -> Result<T, Error>
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<'lua, T> ToLua<'lua> for T where
T: 'static + UserData + Send,
[src]
T: 'static + UserData + Send,
impl<'lua, T> ToLuaMulti<'lua> for T where
T: ToLua<'lua>,
[src]
T: ToLua<'lua>,
pub fn to_lua_multi(self, lua: Context<'lua>) -> Result<MultiValue<'lua>, Error>
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,