namespace SAMP.API
{
public class Text3D
{
#region Class Variables
private int _nId;
private bool _bDeleted;
private string _strText;
private Color _qColor;
#endregion
#region Constructor
///
/// Creates a 3D Text Label. NOTE: This merely initializes the 3D Text Label. Use SAMP.API.Text3D.Create to create/spawn it!
///
/// The initial text string.
/// The text color.
public Text3D(string text, Color color)
{
_strText = text;
_qColor = color;
}
#endregion
#region Accessors & Mutators
///
/// Gets or sets the color of this 3D text label.
///
public Color Color
{
get { return _qColor; }
set
{
if(_bDeleted) return;
Core.Natives.Update3DTextLabelText(this.ID, value.ToArgb(), _strText);
}
}
///
/// Gets the ID of the 3D text label.
///
internal int ID
{
get { return _nId; }
}
///
/// Gets or sets the text of this 3D text label.
///
public string Text
{
get { return _strText; }
set
{
if(_bDeleted) return;
if(!_strText.Equals(string.Empty))
Core.Natives.Update3DTextLabelText(this.ID, _qColor.ToArgb(), value);
}
}
#endregion
#region Public Methods
///
/// Creates the 3D Text Label at a specific location in the world.
///
/// The position.
/// The distance from where you are able to see the 3D Text Label.
/// The virtual world in which you are able to see the 3D Text.
/// Test the line-of-sight so this text can't be seen through objects.
public void Create(Vector3 position, float drawDistance, int virtualWorld, bool testLOS = false)
{
_nId = Core.Natives.Create3DTextLabel(this.Text, this.Color.ToArgb(), position.X, position.Y, position.Z, drawDistance, virtualWorld, testLOS ? 1 : 0);
}
///
/// Attaches the 3D text label to a player.
///
/// The player to attach the 3D text label to.
/// The offset from the player.
public void AttachToPlayer(Player player, Vector3 offset)
{
if(_bDeleted) return;
Core.Natives.Attach3DTextLabelToPlayer(this.ID, player.ID, offset.X, offset.Y, offset.Z);
}
///
/// Attaches the 3D text label to a vehicle.
///
/// The vehicle to attach the 3D text label to.
/// The offset from the player.
public void AttachToVehicle(Vehicle vehicle, Vector3 offset)
{
if(_bDeleted) return;
Core.Natives.Attach3DTextLabelToVehicle(this.ID, vehicle.ID, offset.X, offset.Y, offset.Z);
}
///
/// Deletes the 3D text label.
///
/// Returns a System.Boolean representing whether or not the 3D text label was deleted.
public bool Delete()
{
_bDeleted = true;
return Core.Natives.Delete3DTextLabel(this.ID) == 1;
}
#endregion
};
};