Skip to content

Commit

Permalink
make inheritance work with Alt.Core hack
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDutchDev committed Nov 27, 2023
1 parent 8533596 commit 6511756
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
15 changes: 11 additions & 4 deletions src/AltV.Atlas.Vehicles.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@

<ItemGroup>
<None Include="../README.md" Pack="true" PackagePath="\"/>
<PackageReference Include="AltV.Net.Async" Version="15.0.5"/>
<PackageReference Include="AutoMapper" Version="12.0.1"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0"/>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1"/>
<PackageReference Include="AltV.Net.Async" Version="15.0.6"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0"/>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0"/>
</ItemGroup>


<ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
<PackageReference Include="AltV.Atlas.Shared" Version="2.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<ProjectReference Include="..\..\AltV.Atlas.Shared\AltV.Atlas.Shared.csproj" />
</ItemGroup>
</Project>
13 changes: 4 additions & 9 deletions src/Factories/AtlasVehicleFactory.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using AltV.Atlas.Vehicles.AltV.Entities;
using AltV.Atlas.Vehicles.AltV.Interfaces;
using AltV.Atlas.Vehicles.Entities;
using AltV.Atlas.Vehicles.AltV.Interfaces;
using AltV.Atlas.Vehicles.Interfaces;
using AltV.Net;
using AltV.Net.Async;
using AltV.Net.Data;
using AltV.Net.Enums;
using AutoMapper;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

Expand Down Expand Up @@ -41,12 +38,10 @@ public AtlasVehicleFactory( ILogger<AtlasVehicleFactory> logger, IServiceProvide
/// <returns>A new vehicle of type T</returns>
public async Task<T> CreateVehicleAsync<T>( uint model, Position position, Rotation rotation ) where T : class, IAtlasVehicle
{
var config = new MapperConfiguration(cfg => cfg.CreateMap<AtlasVehicleBase, T>());
var mapper = config.CreateMapper();

var altVeh = await AltAsync.CreateVehicle( model, position, rotation );
_logger.LogInformation( "ALtVeh: {Type}", altVeh.GetType( ) );
return mapper.Map<T>( altVeh );
var actualVeh = ActivatorUtilities.CreateInstance<T>( _serviceProvider, altVeh.Core, altVeh.NativePointer, altVeh.Id );
Alt.Core.PoolManager.Vehicle.Add( actualVeh );
return actualVeh;
}

public Task<T> CreateVehicleAsync<T>( string model, Position position, Rotation rotation ) where T : class, IAtlasVehicle
Expand Down

0 comments on commit 6511756

Please sign in to comment.