-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathAsyncResource.cs
153 lines (126 loc) · 5.58 KB
/
AsyncResource.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
using System;
using System.Runtime.Loader;
using AltV.Net.Async.Elements.Entities;
using AltV.Net.Async.Elements.Factories;
using AltV.Net.Async.Elements.Pools;
using AltV.Net.CApi;
using AltV.Net.Elements.Entities;
namespace AltV.Net.Async
{
public abstract class AsyncResource : Resource
{
private readonly AltVAsync altVAsync;
private readonly bool forceAsync;
public AsyncResource(bool forceAsyncBaseObjects = true) : this(new DefaultTickSchedulerFactory(), forceAsyncBaseObjects)
{
}
public AsyncResource(ITickSchedulerFactory tickSchedulerFactory, bool forceAsyncBaseObjects = true)
{
altVAsync = new AltVAsync(tickSchedulerFactory);
forceAsync = forceAsyncBaseObjects;
if (!forceAsyncBaseObjects)
{
Alt.LogFast("Legacy async API is deprecated");
}
}
public override void OnTick()
{
altVAsync.TickDelegate();
}
public override IEntityPool<IPlayer> GetPlayerPool(IEntityFactory<IPlayer> playerFactory)
{
return new AsyncPlayerPool(playerFactory, forceAsync);
}
public override IEntityPool<IVehicle> GetVehiclePool(IEntityFactory<IVehicle> vehicleFactory)
{
return new AsyncVehiclePool(vehicleFactory, forceAsync);
}
public override IEntityPool<IPed> GetPedPool(IEntityFactory<IPed> pedFactory)
{
return new AsyncPedPool(pedFactory, forceAsync);
}
public override IBaseObjectPool<IBlip> GetBlipPool(IBaseObjectFactory<IBlip> blipFactory)
{
return new AsyncBlipPool(blipFactory, forceAsync);
}
public override IBaseObjectPool<IVirtualEntity> GetVirtualEntityPool(IBaseObjectFactory<IVirtualEntity> virtualEntityFactory)
{
return new AsyncVirtualEntityPool(virtualEntityFactory, forceAsync);
}
public override IBaseObjectPool<IVirtualEntityGroup> GetVirtualEntityGroupPool(IBaseObjectFactory<IVirtualEntityGroup> virtualEntityGroupFactory)
{
return new AsyncVirtualEntityGroupPool(virtualEntityGroupFactory, forceAsync);
}
public override IBaseObjectPool<ICheckpoint> GetCheckpointPool(
IBaseObjectFactory<ICheckpoint> checkpointFactory)
{
return new AsyncCheckpointPool(checkpointFactory, forceAsync);
}
public override IBaseObjectPool<IVoiceChannel> GetVoiceChannelPool(
IBaseObjectFactory<IVoiceChannel> voiceChannelFactory)
{
return new AsyncVoiceChannelPool(voiceChannelFactory, forceAsync);
}
public override IBaseObjectPool<IColShape> GetColShapePool(IBaseObjectFactory<IColShape> colShapeFactory)
{
return new AsyncColShapePool(colShapeFactory, forceAsync);
}
public override IBaseObjectPool<IMarker> GetMarkerPool(IBaseObjectFactory<IMarker> factory)
{
return new AsyncMarkerPool(factory, forceAsync);
}
public override Core GetCore(IntPtr nativePointer, IntPtr resourcePointer, AssemblyLoadContext assemblyLoadContext, ILibrary library, IPoolManager poolManager,
INativeResourcePool nativeResourcePool)
{
return new AsyncCore(nativePointer, resourcePointer, assemblyLoadContext, library, poolManager, nativeResourcePool);
}
public override IBaseObjectFactory<IBlip> GetBlipFactory()
{
return forceAsync ? new AsyncBlipFactory() : base.GetBlipFactory();
}
public override IBaseObjectFactory<ICheckpoint> GetCheckpointFactory()
{
return forceAsync ? new AsyncCheckpointFactory() : base.GetCheckpointFactory();
}
public override IEntityFactory<IPlayer> GetPlayerFactory()
{
return forceAsync ? new AsyncPlayerFactory() : base.GetPlayerFactory();
}
public override IEntityFactory<IVehicle> GetVehicleFactory()
{
return forceAsync ? new AsyncVehicleFactory() : base.GetVehicleFactory();
}
public override IBaseObjectFactory<IColShape> GetColShapeFactory()
{
return forceAsync ? new AsyncColShapeFactory() : base.GetColShapeFactory();
}
public override IEntityFactory<IPed> GetPedFactory()
{
return forceAsync ? new AsyncPedFactory() : base.GetPedFactory();
}
public override IBaseObjectFactory<IVoiceChannel> GetVoiceChannelFactory()
{
return forceAsync ? new AsyncVoiceChannelFactory() : base.GetVoiceChannelFactory();
}
public override IBaseObjectFactory<IVirtualEntity> GetVirtualEntityFactory()
{
return forceAsync ? new AsyncVirtualEntityFactory() : base.GetVirtualEntityFactory();
}
public override IBaseObjectFactory<IVirtualEntityGroup> GetVirtualEntityGroupFactory()
{
return forceAsync ? new AsyncVirtualEntityGroupFactory() : base.GetVirtualEntityGroupFactory();
}
public override IBaseObjectFactory<IMarker> GetMarkerFactory()
{
return forceAsync ? new AsyncMarkerFactory() : base.GetMarkerFactory();
}
public override IEntityFactory<IObject> GetObjectFactory()
{
return forceAsync ? new AsyncObjectFactory() : base.GetObjectFactory();
}
public override IBaseObjectFactory<IConnectionInfo> GetConnectionInfoFactory()
{
return forceAsync ? new AsyncConnectionInfoFactory() : base.GetConnectionInfoFactory();
}
}
}