rust-samp-sdk 3.6.0

Low-level FFI bindings for the SA-MP AMX virtual machine and open.mp native component ABI. Used internally by `rust-samp`; depend on it directly only if you need raw access without the higher-level macros and lifecycle.
Documentation
//! `INPCComponent` — generated by `cargo xtask gen-omp` from `Server/Components/NPCs/npcs.hpp`.
//! Implemented by `NPCComponent` in the server's `NPCs`.
//!
//! Do not edit: change `xtask/omp-wrappers.toml` or the generator and
//! regenerate. Slots are clang's layout of the header for each ABI, checked
//! against the official binaries by `cargo xtask check-abi --generated`.

#![allow(unused_imports)]

use crate::omp::containers::{FlatSet, HybridString, Pair, Span};
use crate::omp::types::{
    Colour, GTAQuat, Hours, Microseconds, Milliseconds, Minutes, Seconds, StringView, TimePoint,
    UID, Vector2, Vector3, Vector4, WorldTimePoint,
};
use crate::omp::vtable::{call_vtable_small_struct, opaque, slots, virtual_fns};
use crate::omp::*;

opaque! {
    /// Opaque handle for `INPCComponent*`.
    pub INPCComponent;
}

/// `NPCComponent_UID` in `Server/Components/NPCs/npcs.hpp`.
pub const NPCS_COMPONENT_UID: UID = 0x3d0e59e87f4e90bc;

impl ComponentInterface for INPCComponent {
    const UID: UID = NPCS_COMPONENT_UID;
    // `IComponent` is not this interface's first base.
    #[cfg(not(target_env = "msvc"))]
    const COMPONENT_OFFSET: isize = 4;
    #[cfg(target_env = "msvc")]
    const COMPONENT_OFFSET: isize = 8;
}

slots! {
    /// `IEventDispatcher<NPCEventHandler> & INPCComponent::getEventDispatcher()`
    SLOT_GET_EVENT_DISPATCHER: usize = 8, 7;
    /// `INPC * INPCComponent::create(StringView)`
    SLOT_CREATE: usize = 9, 8;
    /// `void INPCComponent::destroy(INPC &)`
    SLOT_DESTROY: usize = 10, 9;
    /// `int INPCComponent::createPath()`
    SLOT_CREATE_PATH: usize = 11, 10;
    /// `bool INPCComponent::destroyPath(int)`
    SLOT_DESTROY_PATH: usize = 12, 11;
    /// `void INPCComponent::destroyAllPaths()`
    SLOT_DESTROY_ALL_PATHS: usize = 13, 12;
    /// `size_t INPCComponent::getPathCount()`
    SLOT_GET_PATH_COUNT: usize = 14, 13;
    /// `bool INPCComponent::addPointToPath(int, const Vector3 &, float)`
    SLOT_ADD_POINT_TO_PATH: usize = 15, 14;
    /// `bool INPCComponent::removePointFromPath(int, size_t)`
    SLOT_REMOVE_POINT_FROM_PATH: usize = 16, 15;
    /// `bool INPCComponent::clearPath(int)`
    SLOT_CLEAR_PATH: usize = 17, 16;
    /// `size_t INPCComponent::getPathPointCount(int)`
    SLOT_GET_PATH_POINT_COUNT: usize = 18, 17;
    /// `bool INPCComponent::getPathPoint(int, size_t, Vector3 &, float &)`
    SLOT_GET_PATH_POINT: usize = 19, 18;
    /// `bool INPCComponent::hasPathPointInRange(int, const Vector3 &, float)`
    SLOT_HAS_PATH_POINT_IN_RANGE: usize = 20, 19;
    /// `bool INPCComponent::isValidPath(int)`
    SLOT_IS_VALID_PATH: usize = 21, 20;
    /// `int INPCComponent::loadRecord(StringView)`
    SLOT_LOAD_RECORD: usize = 22, 21;
    /// `bool INPCComponent::unloadRecord(int)`
    SLOT_UNLOAD_RECORD: usize = 23, 22;
    /// `bool INPCComponent::isValidRecord(int)`
    SLOT_IS_VALID_RECORD: usize = 24, 23;
    /// `size_t INPCComponent::getRecordCount()`
    SLOT_GET_RECORD_COUNT: usize = 25, 24;
    /// `void INPCComponent::unloadAllRecords()`
    SLOT_UNLOAD_ALL_RECORDS: usize = 26, 25;
    /// `bool INPCComponent::openNode(int)`
    SLOT_OPEN_NODE: usize = 27, 26;
    /// `void INPCComponent::closeNode(int)`
    SLOT_CLOSE_NODE: usize = 28, 27;
    /// `bool INPCComponent::isNodeOpen(int)`
    SLOT_IS_NODE_OPEN: usize = 29, 28;
    /// `uint8_t INPCComponent::getNodeType(int)`
    SLOT_GET_NODE_TYPE: usize = 30, 29;
    /// `bool INPCComponent::setNodePoint(int, uint16_t)`
    SLOT_SET_NODE_POINT: usize = 31, 30;
    /// `bool INPCComponent::getNodePointPosition(int, Vector3 &)`
    SLOT_GET_NODE_POINT_POSITION: usize = 32, 31;
    /// `int INPCComponent::getNodePointCount(int)`
    SLOT_GET_NODE_POINT_COUNT: usize = 33, 32;
    /// `bool INPCComponent::getNodeInfo(int, uint32_t &, uint32_t &, uint32_t &)`
    SLOT_GET_NODE_INFO: usize = 34, 33;
}

virtual_fns! {
    /// `IEventDispatcher<NPCEventHandler> & INPCComponent::getEventDispatcher()`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_event_dispatcher(
        component: INPCComponent,
    ) -> *mut EventDispatcher<NPCHandler> = [0, SLOT_GET_EVENT_DISPATCHER] or std::ptr::null_mut();

    /// `INPC * INPCComponent::create(StringView)`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_create(
        component: INPCComponent,
        name: StringView,
    ) -> *mut INPC = [0, SLOT_CREATE] or std::ptr::null_mut();

    /// `void INPCComponent::destroy(INPC &)`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    pub fn npcs_destroy(component: INPCComponent, npc: *mut INPC) = [0, SLOT_DESTROY];

    /// `int INPCComponent::createPath()`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_create_path(component: INPCComponent) -> i32 = [0, SLOT_CREATE_PATH] or 0;

    /// `bool INPCComponent::destroyPath(int)`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_destroy_path(
        component: INPCComponent,
        path_id: i32,
    ) -> bool = [0, SLOT_DESTROY_PATH] or false;

    /// `void INPCComponent::destroyAllPaths()`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    pub fn npcs_destroy_all_paths(component: INPCComponent) = [0, SLOT_DESTROY_ALL_PATHS];

    /// `size_t INPCComponent::getPathCount()`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_path_count(component: INPCComponent) -> usize = [0, SLOT_GET_PATH_COUNT] or 0;

    /// `bool INPCComponent::addPointToPath(int, const Vector3 &, float)`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_add_point_to_path(
        component: INPCComponent,
        path_id: i32,
        position: &Vector3,
        stop_range: f32,
    ) -> bool = [0, SLOT_ADD_POINT_TO_PATH] or false;

    /// `bool INPCComponent::removePointFromPath(int, size_t)`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_remove_point_from_path(
        component: INPCComponent,
        path_id: i32,
        point_index: usize,
    ) -> bool = [0, SLOT_REMOVE_POINT_FROM_PATH] or false;

    /// `bool INPCComponent::clearPath(int)`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_clear_path(
        component: INPCComponent,
        path_id: i32,
    ) -> bool = [0, SLOT_CLEAR_PATH] or false;

    /// `size_t INPCComponent::getPathPointCount(int)`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_path_point_count(
        component: INPCComponent,
        path_id: i32,
    ) -> usize = [0, SLOT_GET_PATH_POINT_COUNT] or 0;

    /// `bool INPCComponent::getPathPoint(int, size_t, Vector3 &, float &)`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_path_point(
        component: INPCComponent,
        path_id: i32,
        point_index: usize,
        position: &mut Vector3,
        stop_range: &mut f32,
    ) -> bool = [0, SLOT_GET_PATH_POINT] or false;

    /// `bool INPCComponent::hasPathPointInRange(int, const Vector3 &, float)`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_has_path_point_in_range(
        component: INPCComponent,
        path_id: i32,
        position: &Vector3,
        radius: f32,
    ) -> bool = [0, SLOT_HAS_PATH_POINT_IN_RANGE] or false;

    /// `bool INPCComponent::isValidPath(int)`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_is_valid_path(
        component: INPCComponent,
        path_id: i32,
    ) -> bool = [0, SLOT_IS_VALID_PATH] or false;

    /// `int INPCComponent::loadRecord(StringView)`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_load_record(
        component: INPCComponent,
        file_path: StringView,
    ) -> i32 = [0, SLOT_LOAD_RECORD] or 0;

    /// `bool INPCComponent::unloadRecord(int)`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_unload_record(
        component: INPCComponent,
        record_id: i32,
    ) -> bool = [0, SLOT_UNLOAD_RECORD] or false;

    /// `bool INPCComponent::isValidRecord(int)`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_is_valid_record(
        component: INPCComponent,
        record_id: i32,
    ) -> bool = [0, SLOT_IS_VALID_RECORD] or false;

    /// `size_t INPCComponent::getRecordCount()`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_record_count(component: INPCComponent) -> usize = [0, SLOT_GET_RECORD_COUNT] or 0;

    /// `void INPCComponent::unloadAllRecords()`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    pub fn npcs_unload_all_records(component: INPCComponent) = [0, SLOT_UNLOAD_ALL_RECORDS];

    /// `bool INPCComponent::openNode(int)`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_open_node(
        component: INPCComponent,
        node_id: i32,
    ) -> bool = [0, SLOT_OPEN_NODE] or false;

    /// `void INPCComponent::closeNode(int)`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    pub fn npcs_close_node(component: INPCComponent, node_id: i32) = [0, SLOT_CLOSE_NODE];

    /// `bool INPCComponent::isNodeOpen(int)`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_is_node_open(
        component: INPCComponent,
        node_id: i32,
    ) -> bool = [0, SLOT_IS_NODE_OPEN] or false;

    /// `uint8_t INPCComponent::getNodeType(int)`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_node_type(
        component: INPCComponent,
        node_id: i32,
    ) -> u8 = [0, SLOT_GET_NODE_TYPE] or 0;

    /// `bool INPCComponent::setNodePoint(int, uint16_t)`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_set_node_point(
        component: INPCComponent,
        node_id: i32,
        point_id: u16,
    ) -> bool = [0, SLOT_SET_NODE_POINT] or false;

    /// `bool INPCComponent::getNodePointPosition(int, Vector3 &)`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_node_point_position(
        component: INPCComponent,
        node_id: i32,
        position: &mut Vector3,
    ) -> bool = [0, SLOT_GET_NODE_POINT_POSITION] or false;

    /// `int INPCComponent::getNodePointCount(int)`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_node_point_count(
        component: INPCComponent,
        node_id: i32,
    ) -> i32 = [0, SLOT_GET_NODE_POINT_COUNT] or 0;

    /// `bool INPCComponent::getNodeInfo(int, uint32_t &, uint32_t &, uint32_t &)`.
    ///
    /// # Safety
    /// `component` must be a live `INPCComponent`.
    #[must_use]
    pub fn npcs_node_info(
        component: INPCComponent,
        node_id: i32,
        vehicle_nodes: &mut u32,
        ped_nodes: &mut u32,
        navi_nodes: &mut u32,
    ) -> bool = [0, SLOT_GET_NODE_INFO] or false;
}