Class GlobalObject
Represents a component which provides the data and functionality of an object.
public class GlobalObject : WorldEntity
- Inheritance
-
GlobalObject
- Inherited Members
Constructors
GlobalObject(IOmpEntityProvider, IObjectsComponent, IObject)
Initializes a new instance of the GlobalObject class.
protected GlobalObject(IOmpEntityProvider entityProvider, IObjectsComponent objects, IObject @object)
Parameters
entityProviderIOmpEntityProviderobjectsIObjectsComponentobjectIObject
Properties
AttachedObject
Gets the GlobalObject this object is attached to, or null if it is not attached to another object.
public virtual GlobalObject? AttachedObject { get; }
Property Value
AttachedPlayer
public virtual Player? AttachedPlayer { get; }
Property Value
AttachedVehicle
public virtual Vehicle? AttachedVehicle { get; }
Property Value
DrawDistance
Gets the draw distance of this object.
public virtual float DrawDistance { get; }
Property Value
HasCameraCollision
Gets or sets a value indicating whether this global object collides with players' cameras.
public virtual bool HasCameraCollision { get; set; }
Property Value
IsMoving
Gets a value indicating whether this object is moving.
public virtual bool IsMoving { get; }
Property Value
IsOmpEntityDestroyed
Gets a value indicating whether the open.mp entity counterpart has been destroyed.
protected bool IsOmpEntityDestroyed { get; }
Property Value
ModelId
Gets the model ID of this object.
public virtual int ModelId { get; }
Property Value
Methods
AttachTo(GlobalObject, Vector3, Vector3, bool)
Attaches this global object to the specified target GlobalObject.
public virtual void AttachTo(GlobalObject target, Vector3 offset, Vector3 rotation, bool syncRotation = false)
Parameters
targetGlobalObjectThe GlobalObject to attach this object to.
offsetVector3The offset position relative to the target object as a Vector3.
rotationVector3The rotation to apply to this object as a Vector3.
syncRotationboolA value indicating whether to synchronize the rotation with the target object.
AttachTo(Player, Vector3, Vector3)
Attaches this global object to the specified target Player.
public virtual void AttachTo(Player target, Vector3 offset, Vector3 rotation)
Parameters
targetPlayerThe Player to attach this object to.
offsetVector3The offset position relative to the player as a Vector3.
rotationVector3The rotation to apply to this object as a Vector3.
AttachTo(Vehicle, Vector3, Vector3)
Attaches this global object to the specified target Vehicle.
public virtual void AttachTo(Vehicle target, Vector3 offset, Vector3 rotation)
Parameters
targetVehicleThe Vehicle to attach this object to.
offsetVector3The offset position relative to the vehicle as a Vector3.
rotationVector3The rotation to apply to this object as a Vector3.
DisableCameraCollisions()
Disables collisions between players' cameras and this global object.
public virtual void DisableCameraCollisions()
GetMaterialData(int)
Gets the material data for the specified material slot, if any has been set.
public virtual ObjectMaterialData? GetMaterialData(int materialIndex)
Parameters
materialIndexintThe material slot index.
Returns
- ObjectMaterialData
The material data, or null if no material has been set in that slot.
GetMovingData()
Gets the current movement data of this global object.
public virtual ObjectMoveData GetMovingData()
Returns
- ObjectMoveData
The ObjectMoveData describing the current move target.
Move(Vector3, float)
Moves this global object to the specified position with the specified speed.
public virtual TimeSpan Move(Vector3 position, float speed)
Parameters
positionVector3The position to move this object to as a Vector3.
speedfloatThe speed at which to move this object.
Returns
- TimeSpan
The time for the object to complete the move.
Move(Vector3, float, Vector3)
Moves this global object to the specified position and rotation with the specified speed.
public virtual TimeSpan Move(Vector3 position, float speed, Vector3 rotation)
Parameters
positionVector3The position to move this object to as a Vector3.
speedfloatThe speed at which to move this object.
rotationVector3The rotation to move this object to as a Vector3.
Returns
- TimeSpan
The time for the object to complete the move.
OnDestroyComponent()
This method is invoked before this component is destroyed and removed from its entity.
protected override void OnDestroyComponent()
ResetAttachment()
Resets any current attachment of this global object (to a player, vehicle, or another object).
public virtual void ResetAttachment()
SetMaterial(int, int, string, string, Color)
Sets the material color of this global object.
public virtual void SetMaterial(int materialIndex, int modelId, string txdName, string textureName, Color materialColor)
Parameters
materialIndexintThe material index on the object to change.
modelIdintThe model ID on which the replacement texture is located. Use 0 for alpha. Use -1 to change the material color without altering the texture.
txdNamestringThe name of the TXD file containing the replacement texture (use "none" if not required).
textureNamestringThe name of the texture to use as the replacement (use "none" if not required).
materialColorColorThe Color of the material to set (use default(Color) to keep the existing material color).
SetMaterialText(int, string, ObjectMaterialSize, string, int, bool, Color, Color, ObjectMaterialTextAlign)
Sets the material text of this global object.
public virtual void SetMaterialText(int materialIndex, string text, ObjectMaterialSize materialSize, string fontface, int fontSize, bool bold, Color foreColor, Color backColor, ObjectMaterialTextAlign textAlignment)
Parameters
materialIndexintThe material index on the object to change.
textstringThe text to display on the object (maximum 2048 characters).
materialSizeObjectMaterialSizeThe object's material size.
fontfacestringThe font to use for the text.
fontSizeintThe size of the text (maximum 255).
boldboolA value indicating whether to write the text in bold.
foreColorColorThe Color of the text.
backColorColorThe background Color of the text.
textAlignmentObjectMaterialTextAlignThe alignment of the text.
Stop()
Stops this object from moving.
public virtual void Stop()
ToString()
public override string ToString()
Returns
Operators
implicit operator IObject(GlobalObject?)
Performs an implicit conversion from GlobalObject to IObject.
public static implicit operator IObject(GlobalObject? @object)
Parameters
objectGlobalObject