Table of Contents

Struct IObject

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

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

[OpenMpApi(new Type[] { typeof(IBaseObject) })]
public readonly struct IObject : IEquatable<IObject>, IObject.IManagedInterface, IBaseObject.IManagedInterface, IExtensible.IManagedInterface, IEntity.IManagedInterface, IIDProvider.IManagedInterface, IUnmanagedInterface
Implements
Inherited Members

Constructors

IObject(nint)

Initializes a new instance of the IObject struct.

public IObject(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

AddExtension<T>(T)

Adds the specified managed extension to this extensible.

public void AddExtension<T>(T extension) where T : Extension

Parameters

extension T

An instance of the extension to add. The extension will be disposed if the extension could not be added to this extensible.

Type Parameters

T

The type of the managed extension.

Remarks

A managed extension can only be added to one extensible.

Exceptions

ArgumentException

Throw when an instance of the extension type was already added to this extensible.

AttachToObject(IObject, Vector3, Vector3, bool)

Attaches this object to another object with the specified offset, rotation, and synchronization option.

public void AttachToObject(IObject objekt, Vector3 offset, Vector3 rotation, bool syncRotation)

Parameters

objekt IObject

The object to attach to.

offset Vector3

The offset of this object relative to the target object.

rotation Vector3

The rotation of this object relative to the target object.

syncRotation bool

A value indicating whether the rotation should be synchronized with the target object.

AttachToPlayer(IPlayer, Vector3, Vector3)

Attaches this object to a player with the specified offset and rotation.

public void AttachToPlayer(IPlayer player, Vector3 offset, Vector3 rotation)

Parameters

player IPlayer

The player to attach to.

offset Vector3

The offset of this object relative to the player.

rotation Vector3

The rotation of this object relative to the player.

AttachToVehicle(IVehicle, Vector3, Vector3)

Attaches the object to a vehicle at the specified offset and rotation.

public void AttachToVehicle(IVehicle vehicle, Vector3 offset, Vector3 rotation)

Parameters

vehicle IVehicle

The vehicle to attach the object to.

offset Vector3

The offset from the vehicle's center.

rotation Vector3

The rotation of the object relative to the vehicle.

Equals(IObject)

public bool Equals(IObject other)

Parameters

other IObject

Returns

bool

Equals(object?)

public override bool Equals(object? other)

Parameters

other object

Returns

bool

GetAttachmentData()

Gets the attachment data of the object.

public ref ObjectAttachmentData GetAttachmentData()

Returns

ObjectAttachmentData

A reference to the ObjectAttachmentData structure containing the attachment information.

GetCameraCollision()

Gets whether the object has camera collision enabled.

public bool GetCameraCollision()

Returns

bool

true if the object has camera collision enabled; otherwise, false.

GetDrawDistance()

Gets the draw distance of the object.

public float GetDrawDistance()

Returns

float

The draw distance in units.

GetExtension(UID)

Gets the extension with the specified id.

public IExtension GetExtension(UID id)

Parameters

id UID

The identifier of the extension type.

Returns

IExtension

The extension or null if the extension could not be found.

GetExtension<T>()

Gets the specified managed extension from this extensible.

public T GetExtension<T>() where T : Extension

Returns

T

An instance of the extension with type T.

Type Parameters

T

The type of the managed extension.

Exceptions

ArgumentException

Thrown if the extension could not be found.

GetHashCode()

public override int GetHashCode()

Returns

int

GetID()

Gets the identifier of this unit.

public int GetID()

Returns

int

The identifier of the unit.

GetMaterialData(uint, out ObjectMaterialData?)

Gets the material data for a specific material index on the object.

public bool GetMaterialData(uint materialIndex, out ObjectMaterialData? output)

Parameters

materialIndex uint

The index of the material to retrieve.

output ObjectMaterialData

When the method returns, contains the material data if successful; otherwise, null.

Returns

bool

true if the material data was retrieved successfully; otherwise, false.

GetModel()

Gets the model ID of the object.

public int GetModel()

Returns

int

The model ID of the object.

GetMovingData()

Gets the current movement data of the object.

public ref ObjectMoveData GetMovingData()

Returns

ObjectMoveData

A reference to the ObjectMoveData structure containing the movement information.

GetPosition()

Gets the position of this entity.

public Vector3 GetPosition()

Returns

Vector3

The position of this entity.

GetRotation()

Gets the rotation of this entity.

public GTAQuat GetRotation()

Returns

GTAQuat

The rotation of this entity.

GetVirtualWorld()

Gets the virtual world of this entity.

public int GetVirtualWorld()

Returns

int

The virtual world of this entity.

IsMoving()

Checks if the object is currently moving.

public bool IsMoving()

Returns

bool

true if the object is moving; otherwise, false.

Move(ref ObjectMoveData)

Moves the object to a new position and rotation over a specified time.

public void Move(ref ObjectMoveData data)

Parameters

data ObjectMoveData

The movement data containing the target position, rotation, and time.

QueryExtension<T>()

Gets the specified unmanaged extension from this extensible.

public T QueryExtension<T>() where T : unmanaged, IExtension.IManagedInterface

Returns

T

The unmanaged extension or null if the extension could not be found.

Type Parameters

T

The type of the unmanaged extension.

RemoveExtension(IExtension)

Removes the specified extension from this extensible.

public void RemoveExtension(IExtension extension)

Parameters

extension IExtension

The extension to remove.

Exceptions

ArgumentException

Thrown if the extension could not be found.

RemoveExtension(UID)

Removes the extension with the specified id from this extensible.

public void RemoveExtension(UID id)

Parameters

id UID

The identifier of the extension.

Exceptions

ArgumentException

Thrown if the extension could not be found.

RemoveExtension<T>(T)

Removes the specified managed extension from this extensible.

public void RemoveExtension<T>(T extension) where T : Extension

Parameters

extension T

The managed extension to remove.

Type Parameters

T

The type of the managed extension.

Exceptions

ArgumentException

Thrown if the extension could not be found.

ResetAttachment()

Resets the object's attachment, removing it from any vehicle or object it was attached to.

public void ResetAttachment()

SetCameraCollision(bool)

Sets whether the object has camera collision enabled.

public void SetCameraCollision(bool collision)

Parameters

collision bool

true to enable camera collision; otherwise, false.

SetDrawDistance(float)

Sets the draw distance for the object.

public void SetDrawDistance(float drawDistance)

Parameters

drawDistance float

The draw distance in units.

SetMaterial(uint, int, string, string, Colour)

Sets the material for a specific material index on the object.

public void SetMaterial(uint materialIndex, int model, string textureLibrary, string textureName, Colour colour)

Parameters

materialIndex uint

The index of the material to set.

model int

The model ID to use for the texture library.

textureLibrary string

The texture library (TXD) name.

textureName string

The texture name from the library.

colour Colour

The colour to apply to the material.

SetMaterialText(uint, string, ObjectMaterialSize, string, int, bool, Colour, Colour, ObjectMaterialTextAlign)

Sets text material on a specific material index of the object.

public void SetMaterialText(uint materialIndex, string text, ObjectMaterialSize materialSize, string fontFace, int fontSize, bool bold, Colour fontColour, Colour backgroundColour, ObjectMaterialTextAlign align)

Parameters

materialIndex uint

The index of the material to set text on.

text string

The text to display on the material.

materialSize ObjectMaterialSize

The size of the material.

fontFace string

The font face to use for the text.

fontSize int

The font size for the text.

bold bool

true to make the text bold; otherwise, false.

fontColour Colour

The colour of the text.

backgroundColour Colour

The background colour of the material.

align ObjectMaterialTextAlign

The text alignment on the material.

SetModel(int)

Sets the model ID of the object.

public void SetModel(int model)

Parameters

model int

The model ID of the object.

SetPosition(Vector3)

Sets the position of this entity.

public void SetPosition(Vector3 position)

Parameters

position Vector3

The position to set.

SetRotation(GTAQuat)

Sets the rotation of this entity.

public void SetRotation(GTAQuat rotation)

Parameters

rotation GTAQuat

The rotation to set.

SetVirtualWorld(int)

Sets the virtual world of this entity.

public void SetVirtualWorld(int vw)

Parameters

vw int

The virtual world to set.

Stop()

Stops the object's current movement.

public void Stop()

TryGetExtension<T>()

Tries to get the specified managed extension from this extensible.

public T? TryGetExtension<T>() where T : Extension

Returns

T

An instance of the extension with type T or null if no extension with the specified type could be found.

Type Parameters

T

The type of the managed extension.

TryQueryExtension<T>(out T)

Tries to get the specified unmanaged extension from this extensible.

public bool TryQueryExtension<T>(out T extension) where T : unmanaged, IExtension.IManagedInterface

Parameters

extension T

The extension if found, otherwise null.

Returns

bool

true if the extension was found; false otherwise.

Type Parameters

T

The type of the unmanaged extension.

Operators

operator ==(IObject, object?)

Determines whether the specified values are equal.

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

Parameters

lhs IObject

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 IObject(IBaseObject)

Casts the IBaseObject to a IObject.

public static explicit operator IObject(IBaseObject value)

Parameters

value IBaseObject

The IBaseObject to cast.

Returns

IObject

The converted IObject.

explicit operator IObject(IEntity)

Casts the IEntity to a IObject.

public static explicit operator IObject(IEntity value)

Parameters

value IEntity

The IEntity to cast.

Returns

IObject

The converted IObject.

explicit operator IObject(IExtensible)

Casts the IExtensible to a IObject.

public static explicit operator IObject(IExtensible value)

Parameters

value IExtensible

The IExtensible to cast.

Returns

IObject

The converted IObject.

explicit operator IObject(IIDProvider)

Casts the IIDProvider to a IObject.

public static explicit operator IObject(IIDProvider value)

Parameters

value IIDProvider

The IIDProvider to cast.

Returns

IObject

The converted IObject.

explicit operator IBaseObject(IObject)

Casts the IObject to a IBaseObject.

public static explicit operator IBaseObject(IObject value)

Parameters

value IObject

The IObject to cast.

Returns

IBaseObject

The converted IBaseObject.

explicit operator IEntity(IObject)

Casts the IObject to a IEntity.

public static explicit operator IEntity(IObject value)

Parameters

value IObject

The IObject to cast.

Returns

IEntity

The converted IEntity.

explicit operator IExtensible(IObject)

Casts the IObject to a IExtensible.

public static explicit operator IExtensible(IObject value)

Parameters

value IObject

The IObject to cast.

Returns

IExtensible

The converted IExtensible.

explicit operator IIDProvider(IObject)

Casts the IObject to a IIDProvider.

public static explicit operator IIDProvider(IObject value)

Parameters

value IObject

The IObject to cast.

Returns

IIDProvider

The converted IIDProvider.

operator !=(IObject, object?)

Determines whether the specified values are not equal.

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

Parameters

lhs IObject

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.