Skip to main content

Trigger

Struct Trigger 

Source
pub struct Trigger {
    pub id: String,
    pub map_id: String,
    pub trigger_type: TriggerType,
    pub x: u32,
    pub y: u32,
    pub width: u32,
    pub height: u32,
    pub script_name: String,
    pub one_shot: bool,
    pub fired: bool,
}
Expand description

A trigger bound to a specific tile or rectangular area on a map.

When the player satisfies the trigger_type condition (stepping on, entering, or interacting with the tile), the associated script_name is returned so the game loop can call the corresponding JS function on the script engine.

Fields§

§id: String

Unique identifier for this trigger (e.g. "start_town_prof").

§map_id: String

The map this trigger lives on (e.g. "StartTown").

§trigger_type: TriggerType

When the trigger fires — every frame (OnStep), once on entry (OnEnter), or on A-press (OnInteract).

§x: u32

Top-left X coordinate of the trigger area (in tile units).

§y: u32

Top-left Y coordinate of the trigger area (in tile units).

§width: u32

Width of the trigger area in tiles. 1 for a single-tile trigger; larger values for rectangular area triggers.

§height: u32

Height of the trigger area in tiles.

§script_name: String

Name of the exported JS async function to call when this trigger fires.

§one_shot: bool

If true, the trigger fires only once and then is permanently disabled.

§fired: bool

Whether this trigger has already been activated (relevant for one-shot triggers). Call TriggerManager::reset_fired_for_map to re-enable triggers after re-entering a map.

Implementations§

Source§

impl Trigger

Source

pub fn single_tile( id: impl Into<String>, map_id: impl Into<String>, trigger_type: TriggerType, x: u32, y: u32, script_name: impl Into<String>, one_shot: bool, ) -> Self

Creates a single-tile trigger.

Source

pub fn contains(&self, tile_x: u32, tile_y: u32) -> bool

Returns true when tile (tile_x, tile_y) falls inside this trigger’s axis-aligned bounding box.

Trait Implementations§

Source§

impl Clone for Trigger

Source§

fn clone(&self) -> Trigger

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Trigger

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Trigger

Source§

impl PartialEq for Trigger

Source§

fn eq(&self, other: &Trigger) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Trigger

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.