1
1
using System ;
2
2
using System . Drawing ;
3
+ using System . Threading . Tasks ;
3
4
using AlternateLife . RageMP . Net . Data ;
4
5
using AlternateLife . RageMP . Net . Enums ;
5
6
using AlternateLife . RageMP . Net . Extensions ;
@@ -11,91 +12,85 @@ namespace AlternateLife.RageMP.Net.Elements.Entities
11
12
{
12
13
internal class TextLabel : Entity , ITextLabel
13
14
{
14
- public Color Color
15
+
16
+ internal TextLabel ( IntPtr nativePointer , Plugin plugin ) : base ( nativePointer , plugin , EntityType . TextLabel )
15
17
{
16
- get
17
- {
18
- CheckExistence ( ) ;
18
+ }
19
19
20
- return StructConverter . PointerToStruct < ColorRgba > ( Rage . TextLabel . TextLabel_GetColor ( NativePointer ) ) . FromModColor ( ) ;
21
- }
22
- set
23
- {
24
- CheckExistence ( ) ;
20
+ public async Task SetColorAsync ( Color value )
21
+ {
22
+ CheckExistence ( ) ;
25
23
26
- Rage . TextLabel . TextLabel_SetColor ( NativePointer , value . ToModColor ( ) ) ;
27
- }
24
+ await _plugin . Schedule ( ( ) => Rage . TextLabel . TextLabel_SetColor ( NativePointer , value . ToModColor ( ) ) ) . ConfigureAwait ( false ) ;
28
25
}
29
26
30
- public string Text
27
+ public async Task < Color > GetColorAsync ( )
31
28
{
32
- get
33
- {
34
- CheckExistence ( ) ;
29
+ CheckExistence ( ) ;
35
30
36
- return StringConverter . PointerToString ( Rage . TextLabel . TextLabel_GetText ( NativePointer ) ) ;
37
- }
38
- set
31
+ return await _plugin . Schedule ( ( ) => StructConverter . PointerToStruct < ColorRgba > ( Rage . TextLabel . TextLabel_GetColor ( NativePointer ) ) . FromModColor ( ) ) . ConfigureAwait ( false ) ;
32
+ }
33
+
34
+ public async Task SetTextAsync ( string value )
35
+ {
36
+ Contract . NotNull ( value , nameof ( value ) ) ;
37
+
38
+ using ( var converter = new StringConverter ( ) )
39
39
{
40
- Contract . NotNull ( value , nameof ( value ) ) ;
40
+ var text = converter . StringToPointer ( value ) ;
41
41
42
- using ( var converter = new StringConverter ( ) )
43
- {
44
- Rage . TextLabel . TextLabel_SetText ( NativePointer , converter . StringToPointer ( value ) ) ;
45
- }
42
+ await _plugin . Schedule ( ( ) => Rage . TextLabel . TextLabel_SetText ( NativePointer , text ) ) . ConfigureAwait ( false ) ;
46
43
}
47
44
}
48
45
49
- public bool LOS
46
+ public async Task < string > GetTextAsync ( )
50
47
{
51
- get
52
- {
53
- CheckExistence ( ) ;
48
+ CheckExistence ( ) ;
54
49
55
- return Rage . TextLabel . TextLabel_GetLOS ( NativePointer ) ;
56
- }
57
- set
58
- {
59
- CheckExistence ( ) ;
50
+ return await _plugin . Schedule ( ( ) => StringConverter . PointerToString ( Rage . TextLabel . TextLabel_GetText ( NativePointer ) ) ) . ConfigureAwait ( false ) ;
51
+ }
60
52
61
- Rage . TextLabel . TextLabel_SetLOS ( NativePointer , value ) ;
62
- }
53
+ public async Task SetLOSAsync ( bool value )
54
+ {
55
+ CheckExistence ( ) ;
56
+
57
+ await _plugin . Schedule ( ( ) => Rage . TextLabel . TextLabel_SetLOS ( NativePointer , value ) ) . ConfigureAwait ( false ) ;
63
58
}
64
59
65
- public float DrawDistance
60
+ public async Task < bool > GetLOSAsync ( )
66
61
{
67
- get
68
- {
69
- CheckExistence ( ) ;
62
+ CheckExistence ( ) ;
70
63
71
- return Rage . TextLabel . TextLabel_GetDrawDistance ( NativePointer ) ;
72
- }
73
- set
74
- {
75
- CheckExistence ( ) ;
64
+ return await _plugin . Schedule ( ( ) => Rage . TextLabel . TextLabel_GetLOS ( NativePointer ) ) . ConfigureAwait ( false ) ;
65
+ }
76
66
77
- Rage . TextLabel . TextLabel_SetDrawDistance ( NativePointer , value ) ;
78
- }
67
+ public async Task SetDrawDistanceAsync ( float value )
68
+ {
69
+ CheckExistence ( ) ;
70
+
71
+ await _plugin . Schedule ( ( ) => Rage . TextLabel . TextLabel_SetDrawDistance ( NativePointer , value ) ) . ConfigureAwait ( false ) ;
79
72
}
80
73
81
- public uint Font
74
+ public async Task < float > GetDrawDistanceAsync ( )
82
75
{
83
- get
84
- {
85
- CheckExistence ( ) ;
76
+ CheckExistence ( ) ;
86
77
87
- return Rage . TextLabel . TextLabel_GetFont ( NativePointer ) ;
88
- }
89
- set
90
- {
91
- CheckExistence ( ) ;
78
+ return await _plugin . Schedule ( ( ) => Rage . TextLabel . TextLabel_GetDrawDistance ( NativePointer ) ) . ConfigureAwait ( false ) ;
79
+ }
92
80
93
- Rage . TextLabel . TextLabel_SetFont ( NativePointer , value ) ;
94
- }
81
+ public async Task SetFontAsync ( uint value )
82
+ {
83
+ CheckExistence ( ) ;
84
+
85
+ await _plugin . Schedule ( ( ) => Rage . TextLabel . TextLabel_SetFont ( NativePointer , value ) ) . ConfigureAwait ( false ) ;
95
86
}
96
87
97
- internal TextLabel ( IntPtr nativePointer , Plugin plugin ) : base ( nativePointer , plugin , EntityType . TextLabel )
88
+ public async Task < uint > GetFontAsync ( )
98
89
{
90
+ CheckExistence ( ) ;
91
+
92
+ return await _plugin . Schedule ( ( ) => Rage . TextLabel . TextLabel_GetFont ( NativePointer ) ) . ConfigureAwait ( false ) ;
99
93
}
94
+
100
95
}
101
96
}
0 commit comments