Skip to main content

MtObject

Struct MtObject 

Source
pub struct MtObject;
Expand description

The root class of MT Framework’s object system (MtObject).

Nearly every game class derives from MtObject; it provides the reflection machinery shared by all of them - a link to the class’s MtDti and the ability to enumerate its reflected properties as an MtPropertyList. The shared virtual-function behaviour (destructors, construction, property creation, DTI access) lives in the Object trait, which this type implements via #[derive(Object)].

Instances are owned by the game; you work with them through references, usually after obtaining one from the game or constructing a concrete subclass through its MtDti.

Implementations§

Source§

impl MtObject

Source

pub fn dti(&self) -> &'static MtDti

Returns the MtDti describing this object’s concrete class.

Source

pub fn get_properties(&self) -> MtPropertyList

Collects this object’s reflected properties into an MtPropertyList.

Invokes the object’s property-creation virtual function to populate a fresh list, which can then be iterated to inspect each property.

Source

pub fn to<T: Object>(&self) -> &T

Reinterprets this object as a shared reference to the subclass T.

This is an unchecked downcast; the caller must ensure the object is actually a T (e.g. via MtDti::is_a).

Source

pub fn to_mut<T: Object>(&mut self) -> &mut T

Reinterprets this object as a mutable reference to the subclass T.

This is an unchecked downcast; the caller must ensure the object is actually a T (e.g. via MtDti::is_a).

Trait Implementations§

Source§

impl HasVtable for MtObject

Source§

impl Object for MtObject

Source§

fn dtor(&mut self)

Runs the destructor on self Read more
Source§

fn destroy(&mut self)

Runs the destructor on self and deallocates the object Read more
Source§

fn create_ui(&self)

Invokes the object’s UI-creation virtual function. Read more
Source§

fn is_enable_instance(&self) -> bool

Returns whether the object is enabled
Source§

fn create_property(&self, props: &mut MtPropertyList)

Populates props with the object’s reflected properties. Read more
Source§

fn get_dti(&self) -> &'static MtDti

Returns a reference to the object’s MtDti. Read more
Source§

fn to_mt_object(&self) -> &MtObject

Converts this object to a reference to an MtObject.
Source§

fn to_mut_mt_object(&mut self) -> &mut MtObject

Converts this object to a mutable reference to an MtObject.
Source§

unsafe fn read<T>(&self, offset: usize) -> T

Reads a value of type T from self at the given byte offset. Read more
Source§

unsafe fn write<T: Copy>(&mut self, offset: usize, value: &T)

Writes a value of type T to self at the given byte offset. Read more
Source§

unsafe fn get_ref<T>(&self, offset: usize) -> &T

Returns a reference to a value of type T within self at the given byte offset. Read more
Source§

unsafe fn get_mut_ref<T>(&mut self, offset: usize) -> &mut T

Returns a mutable reference to a value of type T within self at the given byte offset. Read more

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> 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.