Skip to content

Commit

Permalink
Obsolete ToAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
zziger committed Nov 21, 2022
1 parent c752de7 commit 201a8ea
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 2 deletions.
21 changes: 20 additions & 1 deletion api/AltV.Net.Async/AltAsync.ToAsync.cs
Original file line number Diff line number Diff line change
@@ -1,71 +1,90 @@
using AltV.Net.Async.Elements.Entities;
using System;
using AltV.Net.Async.Elements.Entities;
using AltV.Net.Elements.Entities;

namespace AltV.Net.Async
{
public static partial class AltAsync
{
[Obsolete("Use new async API instead")]
public static IPlayer ToAsync(this IPlayer player, IAsyncContext asyncContext) =>
asyncContext == null ? new AsyncPlayer(player, asyncContext) : null;

[Obsolete("Use new async API instead")]
public static IVehicle ToAsync(this IVehicle vehicle, IAsyncContext asyncContext) =>
asyncContext == null ? new AsyncVehicle(vehicle, asyncContext) : null;

[Obsolete("Use new async API instead")]
public static ICheckpoint ToAsync(this ICheckpoint checkpoint, IAsyncContext asyncContext) =>
asyncContext == null ? new AsyncCheckpoint(checkpoint, asyncContext) : null;

[Obsolete("Use new async API instead")]
public static IColShape ToAsync(this IColShape colShape, IAsyncContext asyncContext) =>
asyncContext == null ? new AsyncColShape(colShape, asyncContext) : null;

[Obsolete("Use new async API instead")]
public static IBlip ToAsync(this IBlip blip, IAsyncContext asyncContext) =>
asyncContext == null ? new AsyncBlip(blip, asyncContext) : null;

[Obsolete("Use new async API instead")]
public static IVoiceChannel ToAsync(this IVoiceChannel voiceChannel, IAsyncContext asyncContext) =>
asyncContext == null ? new AsyncVoiceChannel(voiceChannel, asyncContext) : null;

[Obsolete("Use new async API instead")]
public static IPlayer ToAsync(this IPlayer player) => new AsyncPlayer(player, null);

[Obsolete("Use new async API instead")]
public static IVehicle ToAsync(this IVehicle vehicle) => new AsyncVehicle(vehicle, null);

[Obsolete("Use new async API instead")]
public static ICheckpoint ToAsync(this ICheckpoint checkpoint) => new AsyncCheckpoint(checkpoint, null);

[Obsolete("Use new async API instead")]
public static IColShape ToAsync(this IColShape colShape) => new AsyncColShape(colShape, null);

[Obsolete("Use new async API instead")]
public static IBlip ToAsync(this IBlip blip) => new AsyncBlip(blip, null);

[Obsolete("Use new async API instead")]
public static IVoiceChannel ToAsync(this IVoiceChannel voiceChannel) => new AsyncVoiceChannel(voiceChannel, null);

[Obsolete("Use new async API instead")]
public static bool TryToAsync(this IPlayer thisValue, IAsyncContext asyncContext, out IPlayer player)
{
player = new AsyncPlayer(thisValue, asyncContext);
return true;
}

[Obsolete("Use new async API instead")]
public static bool TryToAsync(this IVehicle thisValue, IAsyncContext asyncContext, out IVehicle vehicle)
{
vehicle = new AsyncVehicle(thisValue, asyncContext);
return true;
}

[Obsolete("Use new async API instead")]
public static bool TryToAsync(this ICheckpoint thisValue, IAsyncContext asyncContext,
out ICheckpoint checkpoint)
{
checkpoint = new AsyncCheckpoint(thisValue, asyncContext);
return true;
}

[Obsolete("Use new async API instead")]
public static bool TryToAsync(this IColShape thisValue, IAsyncContext asyncContext, out IColShape colShape)
{
colShape = new AsyncColShape(thisValue, asyncContext);
return true;
}

[Obsolete("Use new async API instead")]
public static bool TryToAsync(this IBlip thisValue, IAsyncContext asyncContext, out IBlip blip)
{
blip = new AsyncBlip(thisValue, asyncContext);
return true;
}

[Obsolete("Use new async API instead")]
public static bool TryToAsync(this IVoiceChannel thisValue, IAsyncContext asyncContext,
out IVoiceChannel voiceChannel)
{
Expand Down
1 change: 1 addition & 0 deletions api/AltV.Net.Async/Elements/Entities/AsyncBlip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ public void Fade(uint opacity, uint duration)
}
}

[Obsolete("Use new async API instead")]
public IBlip ToAsync(IAsyncContext asyncContext)
{
return this;
Expand Down
1 change: 1 addition & 0 deletions api/AltV.Net.Async/Elements/Entities/AsyncCheckpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public AsyncCheckpoint(ICore core, IntPtr nativePointer) : this(new Checkpoint(c
{
}

[Obsolete("Use new async API instead")]
public ICheckpoint ToAsync(IAsyncContext asyncContext)
{
return this;
Expand Down
1 change: 1 addition & 0 deletions api/AltV.Net.Async/Elements/Entities/AsyncColShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public bool IsVehicleIn(IVehicle entity)
return ColShape.IsVehicleIn(entity);
}
}
[Obsolete("Use new async API instead")]
public IColShape ToAsync(IAsyncContext asyncContext)
{
return this;
Expand Down
1 change: 1 addition & 0 deletions api/AltV.Net.Async/Elements/Entities/AsyncPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,7 @@ public bool SendNames
}
}

[Obsolete("Use new async API instead")]
public IPlayer ToAsync(IAsyncContext asyncContext)
{
return this;
Expand Down
1 change: 1 addition & 0 deletions api/AltV.Net.Async/Elements/Entities/AsyncVehicle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1917,6 +1917,7 @@ public int GetWeaponCapacity(byte index)
}
}

[Obsolete("Use new async API instead")]
public IVehicle ToAsync(IAsyncContext asyncContext)
{
return this;
Expand Down
1 change: 1 addition & 0 deletions api/AltV.Net.Async/Elements/Entities/AsyncVoiceChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public bool IsPlayerMuted(IPlayer player)
}
}

[Obsolete("Use new async API instead")]
public IVoiceChannel ToAsync(IAsyncContext asyncContext)
{
return this;
Expand Down
6 changes: 5 additions & 1 deletion api/AltV.Net.Async/IAsyncConvertible.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
using AltV.Net.Elements.Entities;
using System;
using AltV.Net.Elements.Entities;

namespace AltV.Net.Async
{
public interface IAsyncConvertible<TBaseObject>: IBaseObject where TBaseObject: class, IBaseObject
{
[Obsolete("Use new async API instead")]
TBaseObject ToAsync(IAsyncContext asyncContext);

[Obsolete("Use new async API instead")]
bool TryToAsync(IAsyncContext asyncContext, out TBaseObject player)
{
player = ToAsync(asyncContext);
return true;
}

[Obsolete("Use new async API instead")]
TBaseObject ToAsync()
{
return ToAsync(null);
Expand Down

0 comments on commit 201a8ea

Please sign in to comment.