Skip to content

Commit 6c9b324

Browse files
authored
added marker pool & factory (#778)
1 parent 069c996 commit 6c9b324

File tree

6 files changed

+54
-3
lines changed

6 files changed

+54
-3
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using AltV.Net.Client.Elements.Entities;
2+
using AltV.Net.Client.Elements.Interfaces;
3+
4+
namespace AltV.Net.Client.Elements.Factories
5+
{
6+
public class MarkerFactory : IBaseObjectFactory<IMarker>
7+
{
8+
public IMarker Create(ICore core, IntPtr markerPointer, uint id)
9+
{
10+
return new Marker(core, markerPointer, id);
11+
}
12+
}
13+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using AltV.Net.Client.Elements.Interfaces;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace AltV.Net.Client.Elements.Pools
9+
{
10+
public class MarkerPool : BaseObjectPool<IMarker>
11+
{
12+
public MarkerPool(IBaseObjectFactory<IMarker> markerFactory) : base(markerFactory)
13+
{
14+
}
15+
16+
public override uint GetId(IntPtr entityPointer)
17+
{
18+
unsafe
19+
{
20+
return Alt.Core.Library.Shared.Marker_GetID(entityPointer);
21+
}
22+
}
23+
}
24+
}

api/AltV.Net.Client/Elements/Pools/PoolManager.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public class PoolManager : IPoolManager
1919
public IBaseObjectPool<ICheckpoint> Checkpoint { get; }
2020
public IBaseObjectPool<IVirtualEntity> VirtualEntity { get; }
2121
public IBaseObjectPool<IVirtualEntityGroup> VirtualEntityGroup { get; }
22-
public IBaseObjectPool<IMarker> Marker { get; }
2322
public IBaseObjectPool<IRmlDocument> RmlDocument { get; }
2423
public IBaseObjectPool<IRmlElement> RmlElement { get; }
2524
public IBaseObjectPool<IAudio> Audio { get; }
@@ -35,6 +34,7 @@ public class PoolManager : IPoolManager
3534
public IBaseObjectPool<ILocalVehicle> LocalVehicle { get; }
3635
public IBaseObjectPool<ILocalPed> LocalPed { get; }
3736
public IBaseObjectPool<IFont> Font { get; }
37+
public IBaseObjectPool<IMarker> Marker { get; }
3838
public IBaseObjectPool<IColShape> ColShape { get; }
3939

4040
public IPlayerPool Player { get; }
@@ -76,7 +76,8 @@ public PoolManager(
7676
IBaseObjectPool<IAudioFrontendOutput> audioFrontendOutputPool,
7777
IBaseObjectPool<IAudioAttachedOutput> audioAttachedOutputPool,
7878
IBaseObjectPool<IAudioWorldOutput> audioWorldOutputPool,
79-
IBaseObjectPool<IFont> fontPool)
79+
IBaseObjectPool<IFont> fontPool,
80+
IBaseObjectPool<IMarker> markerPool)
8081
{
8182
this.Player = playerPool;
8283
this.Vehicle = vehiclePool;
@@ -102,6 +103,7 @@ public PoolManager(
102103
AudioAttachedOutput = audioAttachedOutputPool;
103104
AudioWorldOutput = audioWorldOutputPool;
104105
Font = fontPool;
106+
Marker = markerPool;
105107
}
106108

107109
ISharedBaseObject ISharedPoolManager.GetOrCreate(ISharedCore core, IntPtr entityPointer, BaseObjectType baseObjectType,
@@ -139,6 +141,7 @@ public IBaseObject GetOrCreate(ICore core, IntPtr entityPointer, BaseObjectType
139141
BaseObjectType.AudioOutputFrontend => AudioFrontendOutput.GetOrCreate(core, entityPointer, entityId),
140142
BaseObjectType.AudioOutputWorld => AudioWorldOutput.GetOrCreate(core, entityPointer, entityId),
141143
BaseObjectType.Font => Font.GetOrCreate(core, entityPointer, entityId),
144+
BaseObjectType.Marker => Marker.GetOrCreate(core, entityPointer, entityId),
142145
_ => default
143146
};
144147
}
@@ -171,6 +174,7 @@ public IBaseObject GetOrCreate(ICore core, IntPtr entityPointer, BaseObjectType
171174
BaseObjectType.AudioOutputFrontend => AudioFrontendOutput.GetOrCreate(core, entityPointer),
172175
BaseObjectType.AudioOutputWorld => AudioWorldOutput.GetOrCreate(core, entityPointer),
173176
BaseObjectType.Font => Font.GetOrCreate(core, entityPointer),
177+
BaseObjectType.Marker => Marker.GetOrCreate(core, entityPointer),
174178
_ => default
175179
};
176180
}
@@ -204,6 +208,7 @@ public IBaseObject Get(IntPtr entityPointer, BaseObjectType baseObjectType)
204208
BaseObjectType.AudioOutputFrontend => AudioFrontendOutput.Get(entityPointer),
205209
BaseObjectType.AudioOutputWorld => AudioWorldOutput.Get(entityPointer),
206210
BaseObjectType.Font => Font.Get(entityPointer),
211+
BaseObjectType.Marker => Marker.Get(entityPointer),
207212
_ => default
208213
};
209214
}
@@ -242,6 +247,7 @@ public bool Remove(IntPtr entityPointer, BaseObjectType baseObjectType)
242247
BaseObjectType.AudioOutputFrontend => AudioFrontendOutput.Remove(entityPointer),
243248
BaseObjectType.AudioOutputWorld => AudioWorldOutput.Remove(entityPointer),
244249
BaseObjectType.Font => Font.Remove(entityPointer),
250+
BaseObjectType.Marker => Marker.Remove(entityPointer),
245251
_ => default
246252
};
247253
}
@@ -272,6 +278,7 @@ public void Dispose()
272278
AudioFrontendOutput.Dispose();
273279
AudioWorldOutput.Dispose();
274280
Font.Dispose();
281+
Marker.Dispose();
275282
}
276283
}
277284
}

api/AltV.Net.Client/IResource.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public interface IResource
3232
public IBaseObjectFactory<IAudioOutput> GetAudioOutputFactory();
3333
public IBaseObjectFactory<IAudioWorldOutput> GetAudioWorldOutputFactory();
3434
public IBaseObjectFactory<IFont> GetFontFactory();
35+
public IBaseObjectFactory<IMarker> GetMarkerFactory();
3536
public IBaseObjectFactory<IAudioAttachedOutput> GetAudioAttachedOutputFactory();
3637
public IBaseObjectFactory<IAudioFrontendOutput> GetAudioFrontendOutputFactory();
3738
public INativeResourceFactory GetResourceFactory();

api/AltV.Net.Client/ModuleWrapper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,14 @@ public static void MainWithAssembly(Assembly resourceAssembly, IntPtr resourcePo
8585
var audioFrontendOutputPool = new AudioFrontendOutputPool(_resource.GetAudioFrontendOutputFactory());
8686
var audioWorldOutputPool = new AudioWorldOutputPool(_resource.GetAudioWorldOutputFactory());
8787
var fontPool = new FontPool(_resource.GetFontFactory());
88+
var markerPool = new MarkerPool(_resource.GetMarkerFactory());
8889
var baseBaseObjectPool = new PoolManager(playerPool, vehiclePool, pedPool,
8990
blipPool, checkpointPool, audioPool,
9091
httpClientPool, webSocketClientPool, webViewPool,
9192
rmlElementPool, rmlDocumentPool, objectPool,
9293
virtualEntityPool, virtualEntityGroupPool,
9394
textLabelPool, colShapePool, localVehiclePool,
94-
localPedPool, audioFilterPool, audioOutputPool, audioFrontendOutputPool, audioAttachedOutputPool, audioWorldOutputPool, fontPool);
95+
localPedPool, audioFilterPool, audioOutputPool, audioFrontendOutputPool, audioAttachedOutputPool, audioWorldOutputPool, fontPool, markerPool);
9596
var timerPool = new TimerPool();
9697

9798
var natives = _resource.GetNatives(library);

api/AltV.Net.Client/Resource.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ public virtual IBaseObjectFactory<IFont> GetFontFactory()
111111
return new FontFactory();
112112
}
113113

114+
public virtual IBaseObjectFactory<IMarker> GetMarkerFactory()
115+
{
116+
return new MarkerFactory();
117+
}
118+
114119
public virtual IBaseObjectFactory<IAudioAttachedOutput> GetAudioAttachedOutputFactory()
115120
{
116121
return new AudioAttachedOutputFactory();

0 commit comments

Comments
 (0)