Skip to content

Commit 03ffb2b

Browse files
committed
streaming distance per entity
1 parent ea700be commit 03ffb2b

File tree

18 files changed

+105
-73
lines changed

18 files changed

+105
-73
lines changed

api/AltV.Net.Async/AltAsync.Ped.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ namespace AltV.Net.Async
77
{
88
public static partial class AltAsync
99
{
10-
public static Task<IPed> CreatePed(uint model, Position pos, Rotation rot) => AltVAsync.Schedule(() =>
11-
Alt.Core.CreatePed(model, pos, rot));
10+
public static Task<IPed> CreatePed(uint model, Position pos, Rotation rot, uint streamingDistance = 0) => AltVAsync.Schedule(() =>
11+
Alt.Core.CreatePed(model, pos, rot, streamingDistance));
1212

13-
public static Task<IPed> CreatePed(PedModel model, Position pos, Rotation rot) =>
14-
CreatePed((uint)model, pos, rot);
13+
public static Task<IPed> CreatePed(PedModel model, Position pos, Rotation rot, uint streamingDistance = 0) =>
14+
CreatePed((uint)model, pos, rot, streamingDistance);
1515

16-
public static Task<IPed> CreatePed(string model, Position pos, Rotation rot) =>
17-
CreatePed(Alt.Hash(model), pos, rot);
16+
public static Task<IPed> CreatePed(string model, Position pos, Rotation rot, uint streamingDistance = 0) =>
17+
CreatePed(Alt.Hash(model), pos, rot, streamingDistance);
1818

1919
}
2020
}

api/AltV.Net.Async/AltAsync.Vehicle.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ namespace AltV.Net.Async
1212
{
1313
public static partial class AltAsync
1414
{
15-
public static Task<IVehicle> CreateVehicle(uint model, Position pos, Rotation rot) => AltVAsync.Schedule(() =>
16-
Alt.Core.CreateVehicle(model, pos, rot));
15+
public static Task<IVehicle> CreateVehicle(uint model, Position pos, Rotation rot, uint streamingDistance = 0) => AltVAsync.Schedule(() =>
16+
Alt.Core.CreateVehicle(model, pos, rot, streamingDistance));
1717

18-
public static Task<IVehicle> CreateVehicle(VehicleModel model, Position pos, Rotation rot) =>
19-
CreateVehicle((uint) model, pos, rot);
18+
public static Task<IVehicle> CreateVehicle(VehicleModel model, Position pos, Rotation rot, uint streamingDistance = 0) =>
19+
CreateVehicle((uint) model, pos, rot, streamingDistance);
2020

21-
public static Task<IVehicle> CreateVehicle(string model, Position pos, Rotation rot) =>
22-
CreateVehicle(Alt.Hash(model), pos, rot);
21+
public static Task<IVehicle> CreateVehicle(string model, Position pos, Rotation rot, uint streamingDistance = 0) =>
22+
CreateVehicle(Alt.Hash(model), pos, rot, streamingDistance);
2323

2424
[Obsolete("Use AltAsync.CreateVehicle or Alt.CreateVehicle instead")]
2525
public static IVehicleBuilder CreateVehicleBuilder(uint model, Position pos, Rotation rot) =>

api/AltV.Net.Async/Elements/Entities/AsyncEntity.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,18 @@ public uint Timestamp
276276
return Entity.Timestamp;
277277
}
278278
}
279+
}
279280

281+
public uint StreamingDistance
282+
{
283+
get
284+
{
285+
lock (Entity)
286+
{
287+
if (!AsyncContext.CheckIfExistsOrCachedNullable(Entity)) return default;
288+
return Entity.StreamingDistance;
289+
}
290+
}
280291
}
281292

282293
public bool Frozen

api/AltV.Net.Async/Elements/Entities/AsyncVehicle.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,8 @@ public AsyncVehicle(ICore core, IntPtr nativePointer, uint id) : this(new Vehicl
586586
}
587587

588588
[Obsolete("Use AltAsync.CreateVehicle instead")]
589-
public AsyncVehicle(ICore core, uint model, Position position, Rotation rotation) : this(
590-
core, core.CreateVehicleEntity(out var id, model, position, rotation), id)
589+
public AsyncVehicle(ICore core, uint model, Position position, Rotation rotation, uint streamingDistance = 0) : this(
590+
core, core.CreateVehicleEntity(out var id, model, position, rotation, streamingDistance), id)
591591
{
592592
core.PoolManager.Vehicle.Add(this);
593593
}

api/AltV.Net.Async/Elements/Entities/VehicleBuilder.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,18 @@ public class VehicleBuilder : IVehicleBuilder
1919

2020
private readonly Rotation rotation;
2121

22+
private readonly uint streamingDistance;
23+
2224
private readonly Dictionary<string, Action<IntPtr>> functions = new Dictionary<string, Action<IntPtr>>();
2325

2426
private readonly List<IntPtr> memoryToFree = new List<IntPtr>();
2527

26-
public VehicleBuilder(uint model, Position position, Rotation rotation)
28+
public VehicleBuilder(uint model, Position position, Rotation rotation, uint streamingDistance = 0)
2729
{
2830
this.model = model;
2931
this.position = position;
3032
this.rotation = rotation;
33+
this.streamingDistance = streamingDistance;
3134
}
3235

3336
public IVehicleBuilder ModKit(byte value)
@@ -423,8 +426,7 @@ public async Task<IVehicle> Build()
423426
{
424427
uint id = default;
425428
var ptr = Alt.Core.Library.Server.Core_CreateVehicle(((Core) Alt.Core).NativePointer, model,
426-
position, rotation,
427-
&id);
429+
position, rotation, streamingDistance, &id);
428430

429431
while (enumerator.MoveNext())
430432
{

api/AltV.Net.CApi/Libraries/ClientLibrary.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ public unsafe interface IClientLibrary
886886

887887
public unsafe class ClientLibrary : IClientLibrary
888888
{
889-
public readonly uint Methods = 1725;
889+
public readonly uint Methods = 1726;
890890
public delegate* unmanaged[Cdecl]<nint, nint, void> Audio_AddOutput { get; }
891891
public delegate* unmanaged[Cdecl]<nint, nint> Audio_GetBaseObject { get; }
892892
public delegate* unmanaged[Cdecl]<nint, double> Audio_GetCurrentTime { get; }
@@ -3512,7 +3512,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
35123512
public ClientLibrary(Dictionary<ulong, IntPtr> funcTable)
35133513
{
35143514
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
3515-
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 3798753127100614877UL) Outdated = true;
3515+
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 5248804555507714941UL) Outdated = true;
35163516
Audio_AddOutput = (delegate* unmanaged[Cdecl]<nint, nint, void>) GetUnmanagedPtr<Audio_AddOutputDelegate>(funcTable, 9914412815391408844UL, Audio_AddOutputFallback);
35173517
Audio_GetBaseObject = (delegate* unmanaged[Cdecl]<nint, nint>) GetUnmanagedPtr<Audio_GetBaseObjectDelegate>(funcTable, 6330360502401226894UL, Audio_GetBaseObjectFallback);
35183518
Audio_GetCurrentTime = (delegate* unmanaged[Cdecl]<nint, double>) GetUnmanagedPtr<Audio_GetCurrentTimeDelegate>(funcTable, 2944324482134975819UL, Audio_GetCurrentTimeFallback);

0 commit comments

Comments
 (0)