1
- using System ;
2
1
using System . Collections . Generic ;
3
2
using System . Linq ;
4
3
using System . Runtime . InteropServices ;
@@ -11,111 +10,171 @@ namespace AlternateLife.RageMP.Net.Elements.Entities
11
10
{
12
11
internal partial class Player
13
12
{
14
- public async Task SetCurrentWeaponAsync ( uint value )
13
+ public void SetCurrentWeapon ( uint value )
15
14
{
16
15
CheckExistence ( ) ;
17
16
18
- await _plugin
19
- . Schedule ( ( ) => Rage . Player . Player_SetCurrentWeapon ( NativePointer , value ) )
20
- . ConfigureAwait ( false ) ;
17
+ Rage . Player . Player_SetCurrentWeapon ( NativePointer , value ) ;
21
18
}
22
19
23
- public async Task < uint > GetCurrentWeaponAsync ( )
20
+ public Task SetCurrentWeaponAsync ( uint value )
21
+ {
22
+ return _plugin . Schedule ( ( ) => SetCurrentWeapon ( value ) ) ;
23
+ }
24
+
25
+ public uint GetCurrentWeapon ( )
24
26
{
25
27
CheckExistence ( ) ;
26
28
27
- return await _plugin
28
- . Schedule ( ( ) => Rage . Player . Player_GetCurrentWeapon ( NativePointer ) )
29
- . ConfigureAwait ( false ) ;
29
+ return Rage . Player . Player_GetCurrentWeapon ( NativePointer ) ;
30
+ }
31
+
32
+ public Task < uint > GetCurrentWeaponAsync ( )
33
+ {
34
+ return _plugin . Schedule ( GetCurrentWeapon ) ;
30
35
}
31
36
32
- public async Task SetCurrentWeaponAmmoAsync ( uint value )
37
+ public void SetCurrentWeaponAmmo ( uint value )
33
38
{
34
39
CheckExistence ( ) ;
35
40
36
- await _plugin
37
- . Schedule ( ( ) => Rage . Player . Player_SetCurrentWeaponAmmo ( NativePointer , value ) )
38
- . ConfigureAwait ( false ) ;
41
+ Rage . Player . Player_SetCurrentWeaponAmmo ( NativePointer , value ) ;
39
42
}
40
43
41
- public async Task < uint > GetCurrentWeaponAmmoAsync ( )
44
+ public Task SetCurrentWeaponAmmoAsync ( uint value )
45
+ {
46
+ return _plugin . Schedule ( ( ) => SetCurrentWeaponAmmo ( value ) ) ;
47
+ }
48
+
49
+ public uint GetCurrentWeaponAmmo ( )
42
50
{
43
51
CheckExistence ( ) ;
44
52
45
- return await _plugin
46
- . Schedule ( ( ) => Rage . Player . Player_GetCurrentWeaponAmmo ( NativePointer ) )
47
- . ConfigureAwait ( false ) ;
53
+ return Rage . Player . Player_GetCurrentWeaponAmmo ( NativePointer ) ;
54
+ }
55
+
56
+ public Task < uint > GetCurrentWeaponAmmoAsync ( )
57
+ {
58
+ return _plugin . Schedule ( GetCurrentWeaponAmmo ) ;
48
59
}
49
60
50
- public async Task < uint > GetWeaponAmmoAsync ( WeaponHash weaponHash )
61
+ public uint GetWeaponAmmo ( WeaponHash weaponHash )
51
62
{
52
63
CheckExistence ( ) ;
53
64
54
- return await _plugin
55
- . Schedule ( ( ) => Rage . Player . Player_GetWeaponAmmo ( NativePointer , ( uint ) weaponHash ) )
56
- . ConfigureAwait ( false ) ;
65
+ return Rage . Player . Player_GetWeaponAmmo ( NativePointer , ( uint ) weaponHash ) ;
66
+ }
67
+
68
+ public Task < uint > GetWeaponAmmoAsync ( WeaponHash weaponHash )
69
+ {
70
+ return _plugin . Schedule ( ( ) => GetWeaponAmmo ( weaponHash ) ) ;
71
+ }
72
+
73
+ public uint GetWeaponAmmo ( uint weapon )
74
+ {
75
+ return GetWeaponAmmo ( ( WeaponHash ) weapon ) ;
57
76
}
58
77
59
78
public Task < uint > GetWeaponAmmoAsync ( uint weapon )
60
79
{
61
80
return GetWeaponAmmoAsync ( ( WeaponHash ) weapon ) ;
62
81
}
63
82
64
- public async Task < int > GetWeaponAmmoAsync ( int weapon )
83
+ public int GetWeaponAmmo ( int weapon )
65
84
{
66
- return ( int ) await GetWeaponAmmoAsync ( ( WeaponHash ) weapon )
67
- . ConfigureAwait ( false ) ;
85
+ return ( int ) GetWeaponAmmo ( ( WeaponHash ) weapon ) ;
68
86
}
69
87
70
- public async Task SetWeaponAmmoAsync ( WeaponHash weaponHash , uint ammo )
88
+ public Task < int > GetWeaponAmmoAsync ( int weapon )
89
+ {
90
+ return _plugin . Schedule ( ( ) => GetWeaponAmmo ( weapon ) ) ;
91
+ }
92
+
93
+ public void SetWeaponAmmo ( WeaponHash weaponHash , uint ammo )
71
94
{
72
95
CheckExistence ( ) ;
73
96
74
- await _plugin
75
- . Schedule ( ( ) => Rage . Player . Player_SetWeaponAmmo ( NativePointer , ( uint ) weaponHash , ammo ) )
76
- . ConfigureAwait ( false ) ;
97
+ Rage . Player . Player_SetWeaponAmmo ( NativePointer , ( uint ) weaponHash , ammo ) ;
98
+ }
99
+
100
+ public Task SetWeaponAmmoAsync ( WeaponHash weaponHash , uint ammo )
101
+ {
102
+ return _plugin . Schedule ( ( ) => SetWeaponAmmo ( weaponHash , ammo ) ) ;
103
+ }
104
+
105
+ public void SetWeaponAmmo ( WeaponHash weapon , int ammo )
106
+ {
107
+ SetWeaponAmmo ( weapon , ( uint ) ammo ) ;
77
108
}
78
109
79
110
public Task SetWeaponAmmoAsync ( WeaponHash weapon , int ammo )
80
111
{
81
112
return SetWeaponAmmoAsync ( weapon , ( uint ) ammo ) ;
82
113
}
83
114
115
+ public void SetWeaponAmmo ( uint weapon , uint ammo )
116
+ {
117
+ SetWeaponAmmo ( ( WeaponHash ) weapon , ammo ) ;
118
+ }
119
+
84
120
public Task SetWeaponAmmoAsync ( uint weapon , uint ammo )
85
121
{
86
122
return SetWeaponAmmoAsync ( ( WeaponHash ) weapon , ammo ) ;
87
123
}
88
124
125
+ public void SetWeaponAmmo ( int weapon , int ammo )
126
+ {
127
+ SetWeaponAmmo ( ( WeaponHash ) weapon , ( uint ) ammo ) ;
128
+ }
129
+
89
130
public Task SetWeaponAmmoAsync ( int weapon , int ammo )
90
131
{
91
132
return SetWeaponAmmoAsync ( ( WeaponHash ) weapon , ( uint ) ammo ) ;
92
133
}
93
134
94
- public async Task GiveWeaponAsync ( WeaponHash weaponHash , uint ammo )
135
+ public void GiveWeapon ( WeaponHash weaponHash , uint ammo )
95
136
{
96
137
CheckExistence ( ) ;
97
138
98
- await _plugin
99
- . Schedule ( ( ) => Rage . Player . Player_GiveWeapon ( NativePointer , ( uint ) weaponHash , ammo ) )
100
- . ConfigureAwait ( false ) ;
139
+ Rage . Player . Player_GiveWeapon ( NativePointer , ( uint ) weaponHash , ammo ) ;
140
+ }
141
+
142
+ public Task GiveWeaponAsync ( WeaponHash weaponHash , uint ammo )
143
+ {
144
+ return _plugin . Schedule ( ( ) => GiveWeapon ( weaponHash , ammo ) ) ;
145
+ }
146
+
147
+ public void GiveWeapon ( WeaponHash weapon , int ammo )
148
+ {
149
+ GiveWeapon ( weapon , ( uint ) ammo ) ;
101
150
}
102
151
103
152
public Task GiveWeaponAsync ( WeaponHash weapon , int ammo )
104
153
{
105
154
return GiveWeaponAsync ( weapon , ( uint ) ammo ) ;
106
155
}
107
156
157
+ public void GiveWeapon ( uint weapon , uint ammo )
158
+ {
159
+ GiveWeapon ( ( WeaponHash ) weapon , ammo ) ;
160
+ }
161
+
108
162
public Task GiveWeaponAsync ( uint weapon , uint ammo )
109
163
{
110
164
return GiveWeaponAsync ( ( WeaponHash ) weapon , ammo ) ;
111
165
}
112
166
167
+ public void GiveWeapon ( int weapon , int ammo )
168
+ {
169
+ GiveWeapon ( ( WeaponHash ) weapon , ( uint ) ammo ) ;
170
+ }
171
+
113
172
public Task GiveWeaponAsync ( int weapon , int ammo )
114
173
{
115
174
return GiveWeaponAsync ( ( WeaponHash ) weapon , ( uint ) ammo ) ;
116
175
}
117
176
118
- public async Task GiveWeaponsAsync ( IDictionary < WeaponHash , uint > weapons )
177
+ public void GiveWeapons ( IDictionary < WeaponHash , uint > weapons )
119
178
{
120
179
Contract . NotNull ( weapons , nameof ( weapons ) ) ;
121
180
CheckExistence ( ) ;
@@ -125,87 +184,128 @@ public async Task GiveWeaponsAsync(IDictionary<WeaponHash, uint> weapons)
125
184
var hashes = weapons . Keys . Select ( x => ( uint ) x ) . ToArray ( ) ;
126
185
var ammo = weapons . Values . ToArray ( ) ;
127
186
128
- await _plugin
129
- . Schedule ( ( ) => Rage . Player . Player_GiveWeapons ( NativePointer , hashes , ammo , ( ulong ) count ) )
130
- . ConfigureAwait ( false ) ;
187
+ Rage . Player . Player_GiveWeapons ( NativePointer , hashes , ammo , ( ulong ) count ) ;
188
+ }
189
+
190
+ public Task GiveWeaponsAsync ( IDictionary < WeaponHash , uint > weapons )
191
+ {
192
+ return _plugin . Schedule ( ( ) => GiveWeapons ( weapons ) ) ;
193
+ }
194
+
195
+ public void GiveWeapons ( IDictionary < WeaponHash , int > weapons )
196
+ {
197
+ GiveWeapons ( weapons . ToDictionary ( x => x . Key , x => ( uint ) x . Value ) ) ;
131
198
}
132
199
133
200
public Task GiveWeaponsAsync ( IDictionary < WeaponHash , int > weapons )
134
201
{
135
202
return GiveWeaponsAsync ( weapons . ToDictionary ( x => x . Key , x => ( uint ) x . Value ) ) ;
136
203
}
137
204
205
+ public void GiveWeapons ( IDictionary < uint , uint > weapons )
206
+ {
207
+ GiveWeapons ( weapons . ToDictionary ( x => ( WeaponHash ) x . Key , x => x . Value ) ) ;
208
+ }
209
+
138
210
public Task GiveWeaponsAsync ( IDictionary < uint , uint > weapons )
139
211
{
140
212
return GiveWeaponsAsync ( weapons . ToDictionary ( x => ( WeaponHash ) x . Key , x => x . Value ) ) ;
141
213
}
142
214
215
+ public void GiveWeapons ( IDictionary < int , int > weapons )
216
+ {
217
+ GiveWeapons ( weapons . ToDictionary ( x => ( WeaponHash ) x . Key , x => ( uint ) x . Value ) ) ;
218
+ }
219
+
143
220
public Task GiveWeaponsAsync ( IDictionary < int , int > weapons )
144
221
{
145
222
return GiveWeaponsAsync ( weapons . ToDictionary ( x => ( WeaponHash ) x . Key , x => ( uint ) x . Value ) ) ;
146
223
}
147
224
148
- public async Task RemoveWeaponAsync ( WeaponHash weaponHash )
225
+ public void RemoveWeapon ( WeaponHash weaponHash )
149
226
{
150
227
CheckExistence ( ) ;
151
228
152
- await _plugin
153
- . Schedule ( ( ) => Rage . Player . Player_RemoveWeapon ( NativePointer , ( uint ) weaponHash ) )
154
- . ConfigureAwait ( false ) ;
229
+ Rage . Player . Player_RemoveWeapon ( NativePointer , ( uint ) weaponHash ) ;
230
+ }
231
+
232
+ public Task RemoveWeaponAsync ( WeaponHash weaponHash )
233
+ {
234
+ return _plugin . Schedule ( ( ) => RemoveWeapon ( weaponHash ) ) ;
235
+ }
236
+
237
+ public void RemoveWeapon ( uint weapon )
238
+ {
239
+ RemoveWeapon ( ( WeaponHash ) weapon ) ;
155
240
}
156
241
157
242
public Task RemoveWeaponAsync ( uint weapon )
158
243
{
159
244
return RemoveWeaponAsync ( ( WeaponHash ) weapon ) ;
160
245
}
161
246
247
+ public void RemoveWeapon ( int weapon )
248
+ {
249
+ RemoveWeapon ( ( WeaponHash ) weapon ) ;
250
+ }
251
+
162
252
public Task RemoveWeaponAsync ( int weapon )
163
253
{
164
254
return RemoveWeaponAsync ( ( WeaponHash ) weapon ) ;
165
255
}
166
256
167
- public async Task RemoveWeaponsAsync ( IEnumerable < uint > weaponHashes )
257
+ public void RemoveWeapons ( IEnumerable < uint > weaponHashes )
168
258
{
169
259
Contract . NotNull ( weaponHashes , nameof ( weaponHashes ) ) ;
170
260
CheckExistence ( ) ;
171
261
172
262
var weapons = weaponHashes . ToArray ( ) ;
173
263
174
- await _plugin
175
- . Schedule ( ( ) => Rage . Player . Player_RemoveWeapons ( NativePointer , weapons , ( ulong ) weapons . LongLength ) )
176
- . ConfigureAwait ( false ) ;
264
+ Rage . Player . Player_RemoveWeapons ( NativePointer , weapons , ( ulong ) weapons . LongLength ) ;
265
+ }
266
+
267
+ public Task RemoveWeaponsAsync ( IEnumerable < uint > weaponHashes )
268
+ {
269
+ return _plugin . Schedule ( ( ) => RemoveWeapons ( weaponHashes ) ) ;
177
270
}
178
271
272
+ public void RemoveWeapons ( IEnumerable < WeaponHash > weaponHashes )
273
+ {
274
+ RemoveWeapons ( weaponHashes . Select ( x => ( uint ) x ) ) ;
275
+ }
276
+
179
277
public Task RemoveWeaponsAsync ( IEnumerable < WeaponHash > weaponHashes )
180
278
{
181
279
return RemoveWeaponsAsync ( weaponHashes . Select ( x => ( uint ) x ) ) ;
182
280
}
183
281
282
+ public void RemoveWeapons ( IEnumerable < int > weaponHashes )
283
+ {
284
+ RemoveWeapons ( weaponHashes . Select ( x => ( uint ) x ) ) ;
285
+ }
286
+
184
287
public Task RemoveWeaponsAsync ( IEnumerable < int > weaponHashes )
185
288
{
186
289
return RemoveWeaponsAsync ( weaponHashes . Select ( x => ( uint ) x ) ) ;
187
290
}
188
291
189
- public async Task RemoveAllWeaponsAsync ( )
292
+ public void RemoveAllWeapons ( )
190
293
{
191
294
CheckExistence ( ) ;
192
295
193
- await _plugin
194
- . Schedule ( ( ) => Rage . Player . Player_RemoveAllWeapons ( NativePointer ) )
195
- . ConfigureAwait ( false ) ;
296
+ Rage . Player . Player_RemoveAllWeapons ( NativePointer ) ;
297
+ }
298
+
299
+ public Task RemoveAllWeaponsAsync ( )
300
+ {
301
+ return _plugin . Schedule ( RemoveAllWeapons ) ;
196
302
}
197
303
198
- public async Task < IReadOnlyDictionary < WeaponHash , uint > > GetWeaponsAsync ( )
304
+ public IReadOnlyDictionary < WeaponHash , uint > GetWeapons ( )
199
305
{
200
306
CheckExistence ( ) ;
201
307
202
- IntPtr weapons = IntPtr . Zero ;
203
- IntPtr ammo = IntPtr . Zero ;
204
- ulong count = 0 ;
205
-
206
- await _plugin
207
- . Schedule ( ( ) => Rage . Player . Player_GetWeapons ( NativePointer , out weapons , out ammo , out count ) )
208
- . ConfigureAwait ( false ) ;
308
+ Rage . Player . Player_GetWeapons ( NativePointer , out var weapons , out var ammo , out var count ) ;
209
309
210
310
var allWeapons = new Dictionary < WeaponHash , uint > ( ) ;
211
311
@@ -219,5 +319,10 @@ await _plugin
219
319
220
320
return allWeapons ;
221
321
}
322
+
323
+ public Task < IReadOnlyDictionary < WeaponHash , uint > > GetWeaponsAsync ( )
324
+ {
325
+ return _plugin . Schedule ( GetWeapons ) ;
326
+ }
222
327
}
223
328
}
0 commit comments