forked from altmp/coreclr-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAltAsync.Entity.cs
64 lines (55 loc) · 2.67 KB
/
AltAsync.Entity.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Threading.Tasks;
using AltV.Net.Data;
using AltV.Net.Elements.Args;
using AltV.Net.Elements.Entities;
namespace AltV.Net.Async
{
//TODO: allocate position, rotation, rgba structs in task thread an pass them to the main thread instead of creating them in the main thread
public partial class AltAsync
{
[Obsolete("Use async entities instead")]
public static Task<uint> GetModelAsync(this IEntity entity) =>
AltVAsync.Schedule(() => entity.Model);
[Obsolete("Use async entities instead")]
public static Task SetRotationAsync(this IEntity entity, Rotation rotation) =>
AltVAsync.Schedule(() => entity.Rotation = rotation);
[Obsolete("Use async entities instead")]
public static Task<Rotation> GetRotationAsync(this IEntity entity) =>
AltVAsync.Schedule(() => entity.Rotation);
[Obsolete("Use async entities instead")]
public static async Task SetSyncedMetaDataAsync(this IEntity entity, string key, object value)
{
Alt.CoreImpl.CreateMValue(out var mValue, value);
await AltVAsync.Schedule(() => entity.SetSyncedMetaData(key, mValue));
mValue.Dispose();
}
[Obsolete("Use async entities instead")]
public static Task<T> GetSyncedMetaDataAsync<T>(this IEntity entity, string key) =>
AltVAsync.Schedule(() =>
{
entity.GetSyncedMetaData<T>(key, out var value);
return value;
});
[Obsolete("Use async entities instead")]
public static async Task SetStreamSyncedMetaDataAsync(this IEntity entity, string key, object value)
{
Alt.CoreImpl.CreateMValue(out var mValue, value);
await AltVAsync.Schedule(() => entity.SetStreamSyncedMetaData(key, mValue));
mValue.Dispose();
}
[Obsolete("Use async entities instead")]
public static Task<T> GetStreamSyncedMetaDataAsync<T>(this IEntity entity, string key) =>
AltVAsync.Schedule(() =>
{
entity.GetStreamSyncedMetaData<T>(key, out var value);
return value;
});
[Obsolete("Use async entities instead")]
public static Task DeleteSyncedMetaDataAsync(this IEntity entity, string key) =>
AltVAsync.Schedule(() => entity.DeleteSyncedMetaData(key));
[Obsolete("Use async entities instead")]
public static Task DeleteStreamSyncedMetaDataAsync(this IEntity entity, string key) =>
AltVAsync.Schedule(() => entity.DeleteStreamSyncedMetaData(key));
}
}