Table of Contents

Struct INPCComponent

Namespace
SampSharp.OpenMp.Core.Api
Assembly
SampSharp.OpenMp.Core.dll

This type represents a pointer to an unmanaged open.mp INPCComponent interface.

[OpenMpApi(new Type[] { typeof(IPool<INPC>), typeof(INetworkComponent) })]
public readonly struct INPCComponent : IEquatable<INPCComponent>, INPCComponent.IManagedInterface, IPool<INPC>.IManagedInterface, INetworkComponent.IManagedInterface, IComponent.IManagedInterface, IUnmanagedInterface
Implements
Inherited Members

Constructors

INPCComponent(nint)

Initializes a new instance of the INPCComponent struct.

public INPCComponent(nint handle)

Parameters

handle nint

A pointer to the unmanaged interface.

Properties

Handle

Gets the handle to the unmanaged interface instance.

public nint Handle { get; }

Property Value

nint

HasValue

Gets a value indicating whether the pointer has a value.

public bool HasValue { get; }

Property Value

bool

Methods

AddPointToPath(int, Vector3, float)

Adds a point with stop range to a path container.

public bool AddPointToPath(int pathId, Vector3 position, float stopRange)

Parameters

pathId int
position Vector3
stopRange float

Returns

bool

Bounds()

Gets the bounds of the pool.

public (Size, Size) Bounds()

Returns

(Size, Size)

A tuple containing the lower and upper bounds of the pool.

ClearPath(int)

Removes all waypoints from a path container.

public bool ClearPath(int pathId)

Parameters

pathId int

Returns

bool

CloseNode(int)

Closes a previously opened node file.

public void CloseNode(int nodeId)

Parameters

nodeId int

ComponentName()

Gets the name of the component.

public string ComponentName()

Returns

string

The component name.

ComponentVersion()

Gets the version of the component.

public SemanticVersion ComponentVersion()

Returns

SemanticVersion

The component version.

Count()

Gets the number of elements in the pool.

public Size Count()

Returns

Size

The number of elements in the pool.

Create(string)

Creates a controllable NPC with the given name. The NPC must be spawned via Spawn() separately before it appears in the world.

public INPC Create(string name)

Parameters

name string

The NPC name (must follow the same rules as normal player names).

Returns

INPC

CreatePath()

Creates a new (empty) path container.

public int CreatePath()

Returns

int

Destroy(INPC)

Destroys the given NPC. Required because NPC removal is more than a pool release.

public void Destroy(INPC npc)

Parameters

npc INPC

DestroyAllPaths()

Destroys all path containers.

public void DestroyAllPaths()

DestroyPath(int)

Destroys a previously created path container.

public bool DestroyPath(int pathId)

Parameters

pathId int

Returns

bool

Equals(INPCComponent)

public bool Equals(INPCComponent other)

Parameters

other INPCComponent

Returns

bool

Equals(object?)

public override bool Equals(object? other)

Parameters

other object

Returns

bool

Get(int)

Gets the element at the specified index.

public INPC Get(int index)

Parameters

index int

The index of the element to retrieve.

Returns

INPC

The element at the specified index.

GetComponentType()

Gets the type of the component.

public ComponentType GetComponentType()

Returns

ComponentType

The component type.

GetEnumerator()

Gets an enumerator that iterates through the pool.

public IPool<INPC>.Enumerator GetEnumerator()

Returns

IPool<INPC>.Enumerator

An enumerator for the pool.

GetEventDispatcher()

Gets the event dispatcher for NPC-related events.

public IEventDispatcher<INPCEventHandler> GetEventDispatcher()

Returns

IEventDispatcher<INPCEventHandler>

GetHashCode()

public override int GetHashCode()

Returns

int

GetNetwork()

Gets the network provided by this component.

public INetwork GetNetwork()

Returns

INetwork

The network.

GetNodeInfo(int, out uint, out uint, out uint)

Gets information about vehicle nodes, pedestrian nodes, and navigation nodes in a node file.

public bool GetNodeInfo(int nodeId, out uint vehicleNodes, out uint pedNodes, out uint naviNodes)

Parameters

nodeId int
vehicleNodes uint
pedNodes uint
naviNodes uint

Returns

bool

GetNodePointCount(int)

Gets the total number of points in a node.

public int GetNodePointCount(int nodeId)

Parameters

nodeId int

Returns

int

GetNodePointPosition(int, out Vector3)

Gets the position of the current point in a node.

public bool GetNodePointPosition(int nodeId, out Vector3 position)

Parameters

nodeId int
position Vector3

Returns

bool

GetNodeType(int)

Gets the type of a node.

public byte GetNodeType(int nodeId)

Parameters

nodeId int

Returns

byte

GetPathCount()

Gets the total number of active path containers.

public Size GetPathCount()

Returns

Size

GetPathPoint(int, Size, out Vector3, out float)

Gets the position and stop range of a waypoint at the specified index in a path.

public bool GetPathPoint(int pathId, Size pointIndex, out Vector3 position, out float stopRange)

Parameters

pathId int
pointIndex Size
position Vector3
stopRange float

Returns

bool

GetPathPointCount(int)

Gets the number of waypoints in a path container.

public Size GetPathPointCount(int pathId)

Parameters

pathId int

Returns

Size

GetPoolEventDispatcher()

Gets the event dispatcher for the pool.

public IEventDispatcher<IPoolEventHandler<INPC>> GetPoolEventDispatcher()

Returns

IEventDispatcher<IPoolEventHandler<INPC>>

An IEventDispatcher<T> for handling pool events.

GetRecordCount()

Gets the total number of loaded records.

public Size GetRecordCount()

Returns

Size

HasPathPointInRange(int, Vector3, float)

Checks whether any waypoint in the path is within the given radius of the position.

public bool HasPathPointInRange(int pathId, Vector3 position, float radius)

Parameters

pathId int
position Vector3
radius float

Returns

bool

IsNodeOpen(int)

Checks whether the specified node file is currently open.

public bool IsNodeOpen(int nodeId)

Parameters

nodeId int

Returns

bool

IsValidPath(int)

Checks if a path id is valid.

public bool IsValidPath(int pathId)

Parameters

pathId int

Returns

bool

IsValidRecord(int)

Checks if a record ID is valid.

public bool IsValidRecord(int recordId)

Parameters

recordId int

Returns

bool

LoadRecord(string)

Loads a record file for playback. Returns the record id (or -1 on failure).

public int LoadRecord(string filePath)

Parameters

filePath string

Returns

int

Lock(int)

Locks the element at the specified index.

public void Lock(int index)

Parameters

index int

The index of the element to lock.

OpenNode(int)

Opens a node file for NPC path navigation.

public bool OpenNode(int nodeId)

Parameters

nodeId int

Returns

bool

Release(int)

Releases the element at the specified index.

public void Release(int index)

Parameters

index int

The index of the element to release.

RemovePointFromPath(int, Size)

Removes a waypoint at the specified index from a path container.

public bool RemovePointFromPath(int pathId, Size pointIndex)

Parameters

pathId int
pointIndex Size

Returns

bool

SetNodePoint(int, ushort)

Sets the current point within a node.

public bool SetNodePoint(int nodeId, ushort pointId)

Parameters

nodeId int
pointId ushort

Returns

bool

SupportedVersion()

Gets the supported version of the component.

public int SupportedVersion()

Returns

int

The supported version of the component.

Remarks

The idea is for the SDK to be totally forward compatible, so code built at any time will always work, thanks to ABI compatibility. This method is an emergency trap door, just in case that's ever not the problem. Check which major version this component was built for, if it isn't the current major version, fail to load it. Always just returns a constant, recompiling will often be enough to upgrade. virtual and final to be the vtable, but it can't be overridden because it is a constant.

UnloadAllRecords()

Unloads all loaded records.

public void UnloadAllRecords()

UnloadRecord(int)

Unloads a previously loaded record.

public bool UnloadRecord(int recordId)

Parameters

recordId int

Returns

bool

Unlock(int)

Unlocks the element at the specified index.

public bool Unlock(int index)

Parameters

index int

The index of the element to unlock.

Returns

bool

true if the element was successfully unlocked; otherwise, false.

Operators

operator ==(INPCComponent, object?)

Determines whether the specified values are equal.

public static bool operator ==(INPCComponent lhs, object? rhs)

Parameters

lhs INPCComponent

The value on the left side of the operator.

rhs object

The value on the right side of the operator.

Returns

bool

true if the values are equal; otherwise, false.

explicit operator INPCComponent(IComponent)

Casts the IComponent to a INPCComponent.

public static explicit operator INPCComponent(IComponent value)

Parameters

value IComponent

The IComponent to cast.

Returns

INPCComponent

The converted INPCComponent.

explicit operator IComponent(INPCComponent)

Casts the INPCComponent to a IComponent.

public static explicit operator IComponent(INPCComponent value)

Parameters

value INPCComponent

The INPCComponent to cast.

Returns

IComponent

The converted IComponent.

explicit operator INetworkComponent(INPCComponent)

public static explicit operator INetworkComponent(INPCComponent value)

Parameters

value INPCComponent

The INPCComponent to cast.

Returns

INetworkComponent

The converted INetworkComponent.

explicit operator IPool<INPC>(INPCComponent)

Casts the INPCComponent to a IPool<T>.

public static explicit operator IPool<INPC>(INPCComponent value)

Parameters

value INPCComponent

The INPCComponent to cast.

Returns

IPool<INPC>

The converted IPool<T>.

explicit operator INPCComponent(INetworkComponent)

public static explicit operator INPCComponent(INetworkComponent value)

Parameters

value INetworkComponent

The INetworkComponent to cast.

Returns

INPCComponent

The converted INPCComponent.

explicit operator INPCComponent(IPool<INPC>)

Casts the IPool<T> to a INPCComponent.

public static explicit operator INPCComponent(IPool<INPC> value)

Parameters

value IPool<INPC>

The IPool<T> to cast.

Returns

INPCComponent

The converted INPCComponent.

operator !=(INPCComponent, object?)

Determines whether the specified values are not equal.

public static bool operator !=(INPCComponent lhs, object? rhs)

Parameters

lhs INPCComponent

The value on the left side of the operator.

rhs object

The value on the right side of the operator.

Returns

bool

true if the values are not equal; otherwise, false.

Explicit Interface Implementations

ComponentId

Gets the identifier of the component type.

static UID ComponentId { get; }

Returns

UID

FromComponentHandle(nint)

Casts a handle from a IComponent handle to a handle of this type.

static nint FromComponentHandle(nint handle)

Parameters

handle nint

The IComponent handle.

Returns

nint

The handle of this type.