Skip to content

Commit

Permalink
remove Alt.Core access for everyone
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh committed Aug 23, 2024
1 parent f743610 commit 7274aba
Show file tree
Hide file tree
Showing 123 changed files with 894 additions and 3,595 deletions.
2 changes: 1 addition & 1 deletion api/AltV.Net.Async/AltAsync.BaseObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static Task<BaseObjectType> GetTypeAsync(this IBaseObject baseObject) =>
[Obsolete("Use async entities instead")]
public static async Task SetMetaDataAsync(this IBaseObject baseObject, string key, object value)
{
Alt.Core.CreateMValue(out var mValue, value);
Alt.CoreImpl.CreateMValue(out var mValue, value);
await AltVAsync.Schedule(() => baseObject.SetMetaData(key, in mValue));
mValue.Dispose();
}
Expand Down
6 changes: 3 additions & 3 deletions api/AltV.Net.Async/AltAsync.Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static Task<Rotation> GetRotationAsync(this IEntity entity) =>
[Obsolete("Use async entities instead")]
public static async Task SetSyncedMetaDataAsync(this IEntity entity, string key, object value)
{
Alt.Core.CreateMValue(out var mValue, value);
Alt.CoreImpl.CreateMValue(out var mValue, value);
await AltVAsync.Schedule(() => entity.SetSyncedMetaData(key, mValue));
mValue.Dispose();
}
Expand All @@ -40,7 +40,7 @@ public static Task<T> GetSyncedMetaDataAsync<T>(this IEntity entity, string key)
[Obsolete("Use async entities instead")]
public static async Task SetStreamSyncedMetaDataAsync(this IEntity entity, string key, object value)
{
Alt.Core.CreateMValue(out var mValue, value);
Alt.CoreImpl.CreateMValue(out var mValue, value);
await AltVAsync.Schedule(() => entity.SetStreamSyncedMetaData(key, mValue));
mValue.Dispose();
}
Expand All @@ -56,7 +56,7 @@ public static Task<T> GetStreamSyncedMetaDataAsync<T>(this IEntity entity, strin
[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));
Expand Down
2 changes: 1 addition & 1 deletion api/AltV.Net.Async/AltAsync.Ped.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace AltV.Net.Async
public static partial class AltAsync
{
public static Task<IPed> CreatePed(uint model, Position pos, Rotation rot, uint streamingDistance = 0) => AltVAsync.Schedule(() =>
Alt.Core.CreatePed(model, pos, rot, streamingDistance));
Alt.CoreImpl.CreatePed(model, pos, rot, streamingDistance));

public static Task<IPed> CreatePed(PedModel model, Position pos, Rotation rot, uint streamingDistance = 0) =>
CreatePed((uint)model, pos, rot, streamingDistance);
Expand Down
10 changes: 5 additions & 5 deletions api/AltV.Net.Async/AltAsync.Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ public static async Task<IVehicle> GetVehicleAsync(this IPlayer player)
unsafe
{
player.CheckIfEntityExists();
var vehiclePtr = Alt.Core.Library.Shared.Player_GetVehicle(player.PlayerNativePointer);
return Alt.Core.PoolManager.Vehicle.Get(vehiclePtr);
var vehiclePtr = Alt.CoreImpl.Library.Shared.Player_GetVehicle(player.PlayerNativePointer);
return Alt.CoreImpl.PoolManager.Vehicle.Get(vehiclePtr);
}
});
}
Expand Down Expand Up @@ -156,7 +156,7 @@ await AltVAsync.Schedule(() =>
unsafe
{
player.CheckIfEntityExists();
Alt.Core.Library.Server.Player_Kick(player.PlayerNativePointer, reasonPtr);
Alt.CoreImpl.Library.Server.Player_Kick(player.PlayerNativePointer, reasonPtr);
}
});
Marshal.FreeHGlobal(reasonPtr);
Expand All @@ -167,12 +167,12 @@ public static async Task EmitAsync(this IPlayer player, string eventName, params
{
var size = args.Length;
var mValues = new MValueConst[size];
Alt.Core.CreateMValues(mValues, args);
Alt.CoreImpl.CreateMValues(mValues, args);
var eventNamePtr = MemoryUtils.StringToHGlobalUtf8(eventName);
await AltVAsync.Schedule(() =>
{
player.CheckIfEntityExists();
Alt.Core.TriggerClientEvent(player, eventNamePtr, mValues);
Alt.CoreImpl.TriggerClientEvent(player, eventNamePtr, mValues);
});
Marshal.FreeHGlobal(eventNamePtr);
for (var i = 0; i < size; i++)
Expand Down
4 changes: 2 additions & 2 deletions api/AltV.Net.Async/AltAsync.Vehicle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace AltV.Net.Async
public static partial class AltAsync
{
public static Task<IVehicle> CreateVehicle(uint model, Position pos, Rotation rot, uint streamingDistance = 0) => AltVAsync.Schedule(() =>
Alt.Core.CreateVehicle(model, pos, rot, streamingDistance));
Alt.CreateVehicle(model, pos, rot, streamingDistance));

public static Task<IVehicle> CreateVehicle(VehicleModel model, Position pos, Rotation rot, uint streamingDistance = 0) =>
CreateVehicle((uint) model, pos, rot, streamingDistance);
Expand Down Expand Up @@ -163,7 +163,7 @@ await AltVAsync.Schedule(() =>
unsafe
{
vehicle.CheckIfEntityExists();
Alt.Core.Library.Server.Vehicle_SetNumberplateText(vehicle.VehicleNativePointer, numberPlateTextPtr);
Alt.CoreImpl.Library.Server.Vehicle_SetNumberplateText(vehicle.VehicleNativePointer, numberPlateTextPtr);
}
});
Marshal.FreeHGlobal(numberPlateTextPtr);
Expand Down
2 changes: 1 addition & 1 deletion api/AltV.Net.Async/AltAsync.VirtualEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace AltV.Net.Async;
public partial class AltAsync
{
public static Task<IVirtualEntityGroup> CreateVirtualEntityGroup(uint streamingDistance) =>AltVAsync.Schedule(() =>
Alt.Core.CreateVirtualEntityGroup(streamingDistance));
Alt.CreateVirtualEntityGroup(streamingDistance));

public static Task<IVirtualEntity> CreateVirtualEntity(IVirtualEntityGroup group, Position position,
uint streamingDistance, Dictionary<string, object> dataDict) =>
Expand Down
14 changes: 7 additions & 7 deletions api/AltV.Net.Async/AltAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -368,17 +368,17 @@ public static event ResourceEventAsyncDelegate OnResourceError
public static async void Log(string message)
{
var messagePtr = MemoryUtils.StringToHGlobalUtf8(message);
await Do(() => Alt.Core.LogInfo(messagePtr));
await Do(() => Alt.CoreImpl.LogInfo(messagePtr));
Marshal.FreeHGlobal(messagePtr);
}

public static async void Emit(string eventName, params object[] args)
{
var size = args.Length;
var mValues = new MValueConst[size];
Alt.Core.CreateMValues(mValues, args);
Alt.CoreImpl.CreateMValues(mValues, args);
var eventNamePtr = MemoryUtils.StringToHGlobalUtf8(eventName);
await Do(() => Alt.Core.TriggerLocalEvent(eventNamePtr, mValues));
await Do(() => Alt.CoreImpl.TriggerLocalEvent(eventNamePtr, mValues));
Marshal.FreeHGlobal(eventNamePtr);
for (var i = 0; i < size; i++)
{
Expand All @@ -390,9 +390,9 @@ public static async void EmitAllClients(string eventName, params object[] args)
{
var size = args.Length;
var mValues = new MValueConst[size];
Alt.Core.CreateMValues(mValues, args);
Alt.CoreImpl.CreateMValues(mValues, args);
var eventNamePtr = MemoryUtils.StringToHGlobalUtf8(eventName);
await Do(() => Alt.Core.TriggerClientEventForAll(eventNamePtr, mValues));
await Do(() => Alt.CoreImpl.TriggerClientEventForAll(eventNamePtr, mValues));
Marshal.FreeHGlobal(eventNamePtr);
for (var i = 0; i < size; i++)
{
Expand All @@ -404,9 +404,9 @@ public static async void EmitUnreliableAllClients(string eventName, params objec
{
var size = args.Length;
var mValues = new MValueConst[size];
Alt.Core.CreateMValues(mValues, args);
Alt.CoreImpl.CreateMValues(mValues, args);
var eventNamePtr = MemoryUtils.StringToHGlobalUtf8(eventName);
await Do(() => Alt.Core.TriggerClientEventUnreliableForAll(eventNamePtr, mValues));
await Do(() => Alt.CoreImpl.TriggerClientEventUnreliableForAll(eventNamePtr, mValues));
Marshal.FreeHGlobal(eventNamePtr);
for (var i = 0; i < size; i++)
{
Expand Down
23 changes: 9 additions & 14 deletions api/AltV.Net.Async/AltThreadSafe.Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,13 @@ public static bool GetPositionLocked(this IPlayer player, ref Position position)
{
lock (player)
{
unsafe
if (!player.Exists)
{
if (!player.Exists)
{
return false;
}

var pos = Vector3.Zero;
Alt.Core.Library.Shared.WorldObject_GetPosition(player.WorldObjectNativePointer, &pos);
position = pos;
return true;
return false;
}

position = player.Position;
return true;
}
}

Expand All @@ -114,7 +109,7 @@ public static bool EmitLockedWithContext(this IPlayer player, string eventName,
{
if (player.Exists)
{
Alt.Core.TriggerClientEvent(player, eventNamePtr, mValues);
Alt.CoreImpl.TriggerClientEvent(player, eventNamePtr, mValues);
}
else
{
Expand Down Expand Up @@ -143,7 +138,7 @@ public static bool EmitUnreliableLockedWithContext(this IPlayer player, string e
{
if (player.Exists)
{
Alt.Core.TriggerClientEventUnreliable(player, eventNamePtr, mValues);
Alt.CoreImpl.TriggerClientEventUnreliable(player, eventNamePtr, mValues);
}
else
{
Expand Down Expand Up @@ -172,7 +167,7 @@ public static bool EmitLocked(this IPlayer player, string eventName, params obje
{
if (player.Exists)
{
Alt.Core.TriggerClientEvent(player, eventNamePtr, mValues);
Alt.CoreImpl.TriggerClientEvent(player, eventNamePtr, mValues);
}
else
{
Expand Down Expand Up @@ -201,7 +196,7 @@ public static bool EmitUnreliableLocked(this IPlayer player, string eventName, p
{
if (player.Exists)
{
Alt.Core.TriggerClientEventUnreliable(player, eventNamePtr, mValues);
Alt.CoreImpl.TriggerClientEventUnreliable(player, eventNamePtr, mValues);
}
else
{
Expand Down
12 changes: 6 additions & 6 deletions api/AltV.Net.Async/Elements/Entities/AsyncPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ public void Spawn(Position position, uint delayMs = 0)
Player.Spawn(position, delayMs);
}
}

public void Spawn(uint model, Position position, uint delayMs = 0)
{
lock (Player)
Expand All @@ -589,7 +589,7 @@ public void Spawn(uint model, Position position, uint delayMs = 0)
Player.Spawn(model, position, delayMs);
}
}

public void Spawn(PedModel model, Position position, uint delayMs = 0)
{
lock (Player)
Expand Down Expand Up @@ -726,7 +726,7 @@ public void Emit(string eventName, params object[] args)
{
if (Player.Exists)
{
Alt.Core.TriggerClientEvent(Player, eventNamePtr, mValues);
Alt.CoreImpl.TriggerClientEvent(Player, eventNamePtr, mValues);
}
}

Expand All @@ -749,7 +749,7 @@ public ushort EmitRPC(string name, params object[] args)
{
if (Player.Exists)
{
result = Alt.Core.TriggerClientRPC(Player, eventNamePtr, mValues);
result = Alt.CoreImpl.TriggerClientRPC(Player, eventNamePtr, mValues);
}
}

Expand All @@ -771,7 +771,7 @@ public void EmitRPCAnswer(ushort answerId, object answer, string error)
{
if (Player.Exists)
{
Alt.Core.TriggerClientRPCAnswer(Player, answerId, mValue, errorPtr);
Alt.CoreImpl.TriggerClientRPCAnswer(Player, answerId, mValue, errorPtr);
}
}

Expand All @@ -795,7 +795,7 @@ public void EmitUnreliable(string eventName, params object[] args)
{
if (Player.Exists)
{
Alt.Core.TriggerClientEventUnreliable(Player, eventNamePtr, mValues);
Alt.CoreImpl.TriggerClientEventUnreliable(Player, eventNamePtr, mValues);
}
}

Expand Down
Loading

0 comments on commit 7274aba

Please sign in to comment.