Struct INPCComponent
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
handlenintA pointer to the unmanaged interface.
Properties
Handle
Gets the handle to the unmanaged interface instance.
public nint Handle { get; }
Property Value
HasValue
Gets a value indicating whether the pointer has a value.
public bool HasValue { get; }
Property Value
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
Returns
Bounds()
Gets the bounds of the pool.
public (Size, Size) Bounds()
Returns
ClearPath(int)
Removes all waypoints from a path container.
public bool ClearPath(int pathId)
Parameters
pathIdint
Returns
CloseNode(int)
Closes a previously opened node file.
public void CloseNode(int nodeId)
Parameters
nodeIdint
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
namestringThe NPC name (must follow the same rules as normal player names).
Returns
CreatePath()
Creates a new (empty) path container.
public int CreatePath()
Returns
Destroy(INPC)
Destroys the given NPC. Required because NPC removal is more than a pool release.
public void Destroy(INPC npc)
Parameters
npcINPC
DestroyAllPaths()
Destroys all path containers.
public void DestroyAllPaths()
DestroyPath(int)
Destroys a previously created path container.
public bool DestroyPath(int pathId)
Parameters
pathIdint
Returns
Equals(INPCComponent)
public bool Equals(INPCComponent other)
Parameters
otherINPCComponent
Returns
Equals(object?)
public override bool Equals(object? other)
Parameters
otherobject
Returns
Get(int)
Gets the element at the specified index.
public INPC Get(int index)
Parameters
indexintThe 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
GetHashCode()
public override int GetHashCode()
Returns
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
Returns
GetNodePointCount(int)
Gets the total number of points in a node.
public int GetNodePointCount(int nodeId)
Parameters
nodeIdint
Returns
GetNodePointPosition(int, out Vector3)
Gets the position of the current point in a node.
public bool GetNodePointPosition(int nodeId, out Vector3 position)
Parameters
Returns
GetNodeType(int)
Gets the type of a node.
public byte GetNodeType(int nodeId)
Parameters
nodeIdint
Returns
GetPathCount()
Gets the total number of active path containers.
public Size GetPathCount()
Returns
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
Returns
GetPathPointCount(int)
Gets the number of waypoints in a path container.
public Size GetPathPointCount(int pathId)
Parameters
pathIdint
Returns
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
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
Returns
IsNodeOpen(int)
Checks whether the specified node file is currently open.
public bool IsNodeOpen(int nodeId)
Parameters
nodeIdint
Returns
IsValidPath(int)
Checks if a path id is valid.
public bool IsValidPath(int pathId)
Parameters
pathIdint
Returns
IsValidRecord(int)
Checks if a record ID is valid.
public bool IsValidRecord(int recordId)
Parameters
recordIdint
Returns
LoadRecord(string)
Loads a record file for playback. Returns the record id (or -1 on failure).
public int LoadRecord(string filePath)
Parameters
filePathstring
Returns
Lock(int)
Locks the element at the specified index.
public void Lock(int index)
Parameters
indexintThe index of the element to lock.
OpenNode(int)
Opens a node file for NPC path navigation.
public bool OpenNode(int nodeId)
Parameters
nodeIdint
Returns
Release(int)
Releases the element at the specified index.
public void Release(int index)
Parameters
indexintThe 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
Returns
SetNodePoint(int, ushort)
Sets the current point within a node.
public bool SetNodePoint(int nodeId, ushort pointId)
Parameters
Returns
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
recordIdint
Returns
Unlock(int)
Unlocks the element at the specified index.
public bool Unlock(int index)
Parameters
indexintThe index of the element to unlock.
Returns
Operators
operator ==(INPCComponent, object?)
Determines whether the specified values are equal.
public static bool operator ==(INPCComponent lhs, object? rhs)
Parameters
lhsINPCComponentThe value on the left side of the operator.
rhsobjectThe value on the right side of the operator.
Returns
- bool
trueif the values are equal; otherwise,false.
explicit operator INPCComponent(IComponent)
Casts the IComponent to a INPCComponent.
public static explicit operator INPCComponent(IComponent value)
Parameters
valueIComponentThe 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
valueINPCComponentThe INPCComponent to cast.
Returns
- IComponent
The converted IComponent.
explicit operator INetworkComponent(INPCComponent)
Casts the INPCComponent to a INetworkComponent.
public static explicit operator INetworkComponent(INPCComponent value)
Parameters
valueINPCComponentThe 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
valueINPCComponentThe INPCComponent to cast.
Returns
explicit operator INPCComponent(INetworkComponent)
Casts the INetworkComponent to a INPCComponent.
public static explicit operator INPCComponent(INetworkComponent value)
Parameters
valueINetworkComponentThe 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
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
lhsINPCComponentThe value on the left side of the operator.
rhsobjectThe value on the right side of the operator.
Returns
- bool
trueif the values are not equal; otherwise,false.
Explicit Interface Implementations
ComponentId
Gets the identifier of the component type.
static UID ComponentId { get; }
Returns
FromComponentHandle(nint)
Casts a handle from a IComponent handle to a handle of this type.
static nint FromComponentHandle(nint handle)
Parameters
handlenintThe IComponent handle.
Returns
- nint
The handle of this type.