Event

Struct Event 

Source
pub struct Event { /* private fields */ }
Expand description

An event on a specific map.

An event is any NPC or item that can interact with the player or can be interacted with. This struct contains detailed information about the position of the event and one or more pages containing extra details on how to render the event, plus the scripts related to this event.

Implementations§

Source§

impl Event

Source

pub fn parse(bytes: &[u8]) -> (usize, Self)

Parse raw bytes into a single Event struct.

Use of this method is highly discouraged unless you know exactly what you are doing. Prefer using Map::parse and then extract what you want from the structure tree.

§Panics

This function will panic if the given bytes do not represent a valid event structure.

This might be caused by unaligned bytes, corrupt files, incompatible format updates and library bugs. If you are confident you are doing everything right, feel free to report an issue on GitHub.

Source

pub fn parse_multiple(bytes: &[u8], count: u32) -> (usize, Vec<Self>)

Parse raw bytes into an Event collection.

Use of this method is highly discouraged unless you know exactly what you are doing. Prefer using Map::parse and then extract what you want from the structure tree.

§Panics

This function will panic if the given bytes do not represent a valid event list structure.

This might be caused by unaligned bytes, corrupt files, incompatible format updates and library bugs. If you are confident you are doing everything right, feel free to report an issue on GitHub.

Source

pub fn id(&self) -> u32

The unique identifier of this event.

Source

pub fn name(&self) -> &str

The name of this event.

This is only useful to recognize different events from a programming standpoint and is not shown in game whatsoever.

Source

pub fn name_mut(&mut self) -> &mut String

Mutable reference accessor for Event::name .

Source

pub fn position_x(&self) -> u32

The x coordinate of this event, in tiles.

Source

pub fn position_x_mut(&mut self) -> &mut u32

Mutable reference accessor for Event::position_x.

Source

pub fn position_y(&self) -> u32

The y coordinate of this event, in tiles.

Source

pub fn position_y_mut(&mut self) -> &mut u32

Mutable reference accessor for Event::position_y.

Source

pub fn pages(&self) -> &Vec<Page>

A collection of pages representing the different states this event can be in.

Each event can have up to ten pages describing its behaviour. The page that is actually run is the one with the highest index that meets the requirements of its Page::event_trigger and Page::conditions fields.

Source

pub fn pages_mut(&mut self) -> &mut Vec<Page>

Mutable reference accessor for Event::pages.

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Event

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl PartialEq for Event

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Event

Auto Trait Implementations§

§

impl Freeze for Event

§

impl RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnwindSafe for Event

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.