Data

Struct Data 

Source
pub struct Data {}
Expand description

An interface that provides a centralized location for storing and accessing game-related data.

Implementations§

Source§

impl Data

Source

pub fn get_group_first_player() -> i32

Gets the group key representing the first index for a player group.

Source

pub fn get_group_last_player() -> i32

Gets the group key representing the last index for a player group.

Source

pub fn get_group_hide() -> i32

Gets the group key that won’t have any contact with other groups by default.

Source

pub fn get_group_detect_player() -> i32

Gets the group key that will have contacts with player groups by default.

Source

pub fn get_group_terrain() -> i32

Gets the group key representing terrain that will have contacts with other groups by default.

Source

pub fn get_group_detection() -> i32

Gets the group key that will have contacts with other groups by default.

Source

pub fn get_store() -> Dictionary

Gets the dictionary that can be used to store arbitrary data associated with string keys and various values globally.

Source

pub fn set_should_contact(group_a: i32, group_b: i32, contact: bool)

Sets a boolean value indicating whether two groups should be in contact or not.

§Arguments
  • group_a - An integer representing the first group.
  • group_b - An integer representing the second group.
  • contact - A boolean indicating whether the two groups should be in contact.
Source

pub fn get_should_contact(group_a: i32, group_b: i32) -> bool

Gets a boolean value indicating whether two groups should be in contact or not.

§Arguments
  • group_a - An integer representing the first group.
  • group_b - An integer representing the second group.
§Returns
  • A boolean indicating whether the two groups should be in contact.
Source

pub fn set_relation(group_a: i32, group_b: i32, relation: Relation)

Sets the relation between two groups.

§Arguments
  • group_a - An integer representing the first group.
  • group_b - An integer representing the second group.
  • relation - The relation between the two groups.
Source

pub fn get_relation_by_group(group_a: i32, group_b: i32) -> Relation

Gets the relation between two groups.

§Arguments
  • group_a - An integer representing the first group.
  • group_b - An integer representing the second group.
§Returns
  • The relation between the two groups.
Source

pub fn get_relation(body_a: &dyn IBody, body_b: &dyn IBody) -> Relation

A function that can be used to get the relation between two bodies.

§Arguments
  • body_a - The first body.
  • body_b - The second body.
§Returns
  • The relation between the two bodies.
Source

pub fn is_enemy_group(group_a: i32, group_b: i32) -> bool

A function that returns whether two groups have an “Enemy” relation.

§Arguments
  • group_a - An integer representing the first group.
  • group_b - An integer representing the second group.
§Returns
  • A boolean indicating whether the two groups have an “Enemy” relation.
Source

pub fn is_enemy(body_a: &dyn IBody, body_b: &dyn IBody) -> bool

A function that returns whether two bodies have an “Enemy” relation.

§Arguments
  • body_a - The first body.
  • body_b - The second body.
§Returns
  • A boolean indicating whether the two bodies have an “Enemy” relation.
Source

pub fn is_friend_group(group_a: i32, group_b: i32) -> bool

A function that returns whether two groups have a “Friend” relation.

§Arguments
  • group_a - An integer representing the first group.
  • group_b - An integer representing the second group.
§Returns
  • A boolean indicating whether the two groups have a “Friend” relation.
Source

pub fn is_friend(body_a: &dyn IBody, body_b: &dyn IBody) -> bool

A function that returns whether two bodies have a “Friend” relation.

§Arguments
  • body_a - The first body.
  • body_b - The second body.
§Returns
  • A boolean indicating whether the two bodies have a “Friend” relation.
Source

pub fn is_neutral_group(group_a: i32, group_b: i32) -> bool

A function that returns whether two groups have a “Neutral” relation.

§Arguments
  • group_a - An integer representing the first group.
  • group_b - An integer representing the second group.
§Returns
  • A boolean indicating whether the two groups have a “Neutral” relation.
Source

pub fn is_neutral(body_a: &dyn IBody, body_b: &dyn IBody) -> bool

A function that returns whether two bodies have a “Neutral” relation.

§Arguments
  • body_a - The first body.
  • body_b - The second body.
§Returns
  • A boolean indicating whether the two bodies have a “Neutral” relation.
Source

pub fn set_damage_factor(damage_type: i32, defence_type: i32, bounus: f32)

Sets the bonus factor for a particular type of damage against a particular type of defence.

The builtin “MeleeAttack” and “RangeAttack” actions use a simple formula of finalDamage = damage * bonus.

§Arguments
  • damage_type - An integer representing the type of damage.
  • defence_type - An integer representing the type of defence.
  • bonus - A number representing the bonus.
Source

pub fn get_damage_factor(damage_type: i32, defence_type: i32) -> f32

Gets the bonus factor for a particular type of damage against a particular type of defence.

§Arguments
  • damage_type - An integer representing the type of damage.
  • defence_type - An integer representing the type of defence.
§Returns
  • A number representing the bonus factor.
Source

pub fn is_player(body: &dyn IBody) -> bool

A function that returns whether a body is a player or not.

This works the same as Data::get_group_first_player() <= body.group and body.group <= Data::get_group_last_player().

§Arguments
  • body - The body to check.
§Returns
  • A boolean indicating whether the body is a player.
Source

pub fn is_terrain(body: &dyn IBody) -> bool

A function that returns whether a body is terrain or not.

This works the same as body.group == Data::get_group_terrain().

§Arguments
  • body - The body to check.
§Returns
  • A boolean indicating whether the body is terrain.
Source

pub fn clear()

Clears all data stored in the “Data” object, including user data in Data.store field. And reset some data to default values.

Auto Trait Implementations§

§

impl Freeze for Data

§

impl RefUnwindSafe for Data

§

impl Send for Data

§

impl Sync for Data

§

impl Unpin for Data

§

impl UnwindSafe for Data

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.