forked from altmp/coreclr-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AltAsync.BaseObject.cs
35 lines (31 loc) · 1.36 KB
/
AltAsync.BaseObject.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
using System;
using System.Threading.Tasks;
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<bool> ExistsAsync(this IBaseObject baseObject) =>
AltVAsync.Schedule(() => baseObject.Exists);
[Obsolete("Use async entities instead")]
public static Task<BaseObjectType> GetTypeAsync(this IBaseObject baseObject) =>
AltVAsync.Schedule(() => baseObject.Type);
[Obsolete("Use async entities instead")]
public static async Task SetMetaDataAsync(this IBaseObject baseObject, string key, object value)
{
Alt.CoreImpl.CreateMValue(out var mValue, value);
await AltVAsync.Schedule(() => baseObject.SetMetaData(key, in mValue));
mValue.Dispose();
}
[Obsolete("Use async entities instead")]
public static Task<T> GetMetaDataAsync<T>(this IBaseObject baseObject, string key) =>
AltVAsync.Schedule(() =>
{
baseObject.GetMetaData<T>(key, out var value);
return value;
});
}
}