Struct IBaseObject
This type represents a pointer to an unmanaged open.mp IBaseObject interface.
[OpenMpApi(new Type[] { typeof(IExtensible), typeof(IEntity) })]
public readonly struct IBaseObject : IEquatable<IBaseObject>, IBaseObject.IManagedInterface, IExtensible.IManagedInterface, IEntity.IManagedInterface, IIDProvider.IManagedInterface, IUnmanagedInterface
- Implements
- Inherited Members
Constructors
IBaseObject(nint)
Initializes a new instance of the IBaseObject struct.
public IBaseObject(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
AddExtension<T>(T)
Adds the specified managed extension to this extensible.
public void AddExtension<T>(T extension) where T : Extension
Parameters
extensionTAn instance of the extension to add. The extension will be disposed if the extension could not be added to this extensible.
Type Parameters
TThe 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.
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
vehicleIVehicleThe vehicle to attach the object to.
offsetVector3The offset from the vehicle's center.
rotationVector3The rotation of the object relative to the vehicle.
Equals(IBaseObject)
public bool Equals(IBaseObject other)
Parameters
otherIBaseObject
Returns
Equals(object?)
public override bool Equals(object? other)
Parameters
otherobject
Returns
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
trueif 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
idUIDThe 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
TThe type of the managed extension.
Exceptions
- ArgumentException
Thrown if the extension could not be found.
GetHashCode()
public override int GetHashCode()
Returns
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
materialIndexuintThe index of the material to retrieve.
outputObjectMaterialDataWhen the method returns, contains the material data if successful; otherwise,
null.
Returns
- bool
trueif 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
trueif 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
dataObjectMoveDataThe 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
TThe type of the unmanaged extension.
RemoveExtension(IExtension)
Removes the specified extension from this extensible.
public void RemoveExtension(IExtension extension)
Parameters
extensionIExtensionThe 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
idUIDThe 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
extensionTThe managed extension to remove.
Type Parameters
TThe 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
collisionbooltrueto enable camera collision; otherwise,false.
SetDrawDistance(float)
Sets the draw distance for the object.
public void SetDrawDistance(float drawDistance)
Parameters
drawDistancefloatThe 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
materialIndexuintThe index of the material to set.
modelintThe model ID to use for the texture library.
textureLibrarystringThe texture library (TXD) name.
textureNamestringThe texture name from the library.
colourColourThe 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
materialIndexuintThe index of the material to set text on.
textstringThe text to display on the material.
materialSizeObjectMaterialSizeThe size of the material.
fontFacestringThe font face to use for the text.
fontSizeintThe font size for the text.
boldbooltrueto make the text bold; otherwise,false.fontColourColourThe colour of the text.
backgroundColourColourThe background colour of the material.
alignObjectMaterialTextAlignThe text alignment on the material.
SetModel(int)
Sets the model ID of the object.
public void SetModel(int model)
Parameters
modelintThe model ID of the object.
SetPosition(Vector3)
Sets the position of this entity.
public void SetPosition(Vector3 position)
Parameters
positionVector3The position to set.
SetRotation(GTAQuat)
Sets the rotation of this entity.
public void SetRotation(GTAQuat rotation)
Parameters
rotationGTAQuatThe rotation to set.
SetVirtualWorld(int)
Sets the virtual world of this entity.
public void SetVirtualWorld(int vw)
Parameters
vwintThe 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
Tor null if no extension with the specified type could be found.
Type Parameters
TThe 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
extensionTThe extension if found, otherwise null.
Returns
Type Parameters
TThe type of the unmanaged extension.
Operators
operator ==(IBaseObject, object?)
Determines whether the specified values are equal.
public static bool operator ==(IBaseObject lhs, object? rhs)
Parameters
lhsIBaseObjectThe 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 IEntity(IBaseObject)
Casts the IBaseObject to a IEntity.
public static explicit operator IEntity(IBaseObject value)
Parameters
valueIBaseObjectThe IBaseObject to cast.
Returns
explicit operator IExtensible(IBaseObject)
Casts the IBaseObject to a IExtensible.
public static explicit operator IExtensible(IBaseObject value)
Parameters
valueIBaseObjectThe IBaseObject to cast.
Returns
- IExtensible
The converted IExtensible.
explicit operator IIDProvider(IBaseObject)
Casts the IBaseObject to a IIDProvider.
public static explicit operator IIDProvider(IBaseObject value)
Parameters
valueIBaseObjectThe IBaseObject to cast.
Returns
- IIDProvider
The converted IIDProvider.
explicit operator IBaseObject(IEntity)
Casts the IEntity to a IBaseObject.
public static explicit operator IBaseObject(IEntity value)
Parameters
Returns
- IBaseObject
The converted IBaseObject.
explicit operator IBaseObject(IExtensible)
Casts the IExtensible to a IBaseObject.
public static explicit operator IBaseObject(IExtensible value)
Parameters
valueIExtensibleThe IExtensible to cast.
Returns
- IBaseObject
The converted IBaseObject.
explicit operator IBaseObject(IIDProvider)
Casts the IIDProvider to a IBaseObject.
public static explicit operator IBaseObject(IIDProvider value)
Parameters
valueIIDProviderThe IIDProvider to cast.
Returns
- IBaseObject
The converted IBaseObject.
operator !=(IBaseObject, object?)
Determines whether the specified values are not equal.
public static bool operator !=(IBaseObject lhs, object? rhs)
Parameters
lhsIBaseObjectThe 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.