-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVehicleModule.cs
56 lines (49 loc) · 2.09 KB
/
VehicleModule.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using AltV.Atlas.Vehicles.Server.AltV.Entities;
using AltV.Atlas.Vehicles.Server.AltV.Factories;
using AltV.Atlas.Vehicles.Server.AltV.Interfaces;
using AltV.Atlas.Vehicles.Server.Events;
using AltV.Atlas.Vehicles.Server.Factories;
using AltV.Atlas.Vehicles.Server.Interfaces;
using AltV.Net;
using Microsoft.Extensions.DependencyInjection;
namespace AltV.Atlas.Vehicles.Server;
/// <summary>
/// Entrypoint for atlas vehicle module
/// </summary>
public static class VehicleModule
{
/// <summary>
/// Registers the vehicle module and it's classes/interfaces
/// </summary>
/// <param name="serviceCollection">A service collection</param>
/// <returns>The service collection</returns>
public static IServiceCollection RegisterVehicleModule<TFactory>( this IServiceCollection serviceCollection ) where TFactory : class, IAtlasVehicleFactory
{
serviceCollection.AddTransient<IAtlasVehicle, AtlasVehicleBase>( );
serviceCollection.AddTransient<IAtlasVehicleFactory, TFactory>( );
// Events
serviceCollection.AddSingleton<AtlasVehicleEvents>( );
serviceCollection.AddSingleton<PlayerEnterVehicleEvent>( );
serviceCollection.AddTransient<IEntityFactory<IAtlasVehicle>, AltVehicleFactory>( );
return serviceCollection;
}
/// <summary>
/// Registers the vehicle module and it's classes/interfaces
/// </summary>
/// <param name="serviceCollection">A service collection</param>
/// <returns>The service collection</returns>
public static IServiceCollection RegisterVehicleModule( this IServiceCollection serviceCollection )
{
return RegisterVehicleModule<AtlasVehicleFactory>( serviceCollection );
}
/// <summary>
/// Initializes the vehicle module
/// </summary>
/// <param name="serviceProvider">a service provider</param>
/// <returns></returns>
public static IServiceProvider InitializeVehicleModule( this IServiceProvider serviceProvider )
{
_ = serviceProvider.GetService<PlayerEnterVehicleEvent>( );
return serviceProvider;
}
}