Skip to content

Commit

Permalink
-added enums , changed module, changed factories to activator utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaiwoknats committed Nov 10, 2023
1 parent 3391927 commit a0108d9
Show file tree
Hide file tree
Showing 11 changed files with 285 additions and 24 deletions.
5 changes: 0 additions & 5 deletions src/AltV.Atlas.Vehicles.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,4 @@
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
</ItemGroup>

<ItemGroup>
<Folder Include="Enums\" />
<Folder Include="Interfaces\" />
</ItemGroup>

</Project>
12 changes: 12 additions & 0 deletions src/Enums/EColorMaterial.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace AltV.Atlas.Vehicles.Enums;

public enum EColorMaterial
{
Metallic,
Matte,
Util,
Worn,
Chrome,
Brushed,
DefaultAlloy
}
165 changes: 165 additions & 0 deletions src/Enums/EGtaColor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
namespace AltV.Atlas.Vehicles.Enums;

public enum EGtaColor
{
MetallicBlack,
MetallicGraphiteBlack,
MetallicBlackSteal,
MetallicDarkSilver,
MetallicSilver,
MetallicBlueSilver,
MetallicSteelGray,
MetallicShadowSilver,
MetallicStoneSilver,
MetallicMidnightSilver,
MetallicGunMetal,
MetallicAnthraciteGrey,
MatteBlack,
MatteGray,
MatteLightGrey,
UtilBlack,
UtilBlackPoly,
UtilDarkSilver,
UtilSilver,
UtilGunMetal,
UtilShadowSilver,
WornBlack,
WornGraphite,
WornSilverGrey,
WornSilver,
WornBlueSilver,
WornShadowSilver,
MetallicRed,
MetallicTorinoRed,
MetallicFormulaRed,
MetallicBlazeRed,
MetallicGracefulRed,
MetallicGarnetRed,
MetallicDesertRed,
MetallicCabernetRed,
MetallicCandyRed,
MetallicSunriseOrange,
MetallicClassicGold,
MetallicOrange,
MatteRed,
MatteDarkRed,
MatteOrange,
MatteYellow,
UtilRed,
UtilBrightRed,
UtilGarnetRed,
WornRed,
WornGoldenRed,
WornDarkRed,
MetallicDarkGreen,
MetallicRacingGreen,
MetallicSeaGreen,
MetallicOliveGreen,
MetallicGreen,
MetallicGasolineBlueGreen,
MatteLimeGreen,
UtilDarkGreen,
UtilGreen,
WornDarkGreen,
WornGreen,
WornSeaWash,
MetallicMidnightBlue,
MetallicDarkBlue,
MetallicSaxonyBlue,
MetallicBlue,
MetallicMarinerBlue,
MetallicHarborBlue,
MetallicDiamondBlue,
MetallicSurfBlue,
MetallicNauticalBlue,
MetallicBrightBlue,
MetallicPurpleBlue,
MetallicSpinnakerBlue,
MetallicUltraBlue,
MetallicBrightBlue2,
UtilDarkBlue,
UtilMidnightBlue,
UtilBlue,
UtilSeaFoamBlue,
UtilLightningBlue,
UtilMauiBluePoly,
UtilBrightBlue3,
MatteDarkBlue,
MatteBlue,
MatteMidnightBlue,
WornDarkBlue,
WornBlue,
WornLightBlue,
MetallicTaxiYellow,
MetallicRaceYellow,
MetallicBronze,
MetallicYellowBird,
MetallicLime,
MetallicChampagne,
MetallicPuebloBeige,
MetallicDarkIvory,
MetallicChocoBrown,
MetallicGoldenBrown,
MetallicLightBrown,
MetallicStrawBeige,
MetallicMossBrown,
MetallicBistonBrown,
MetallicBeechwood,
MetallicDarkBeechwood,
MetallicChocoOrange,
MetallicBeachSand,
MetallicSunBleechedSand,
MetallicCream,
UtilBrown,
UtilMediumBrown,
UtilLightBrown,
MetallicWhite,
MetallicFrostWhite,
WornHoneyBeige,
WornBrown,
WornDarkBrown,
WornStrawBeige,
BrushedSteel,
BrushedBlackSteel,
BrushedAluminium,
Chrome,
WornOffWhite,
UtilOffWhite,
WornOrange,
WornLightOrange,
MetallicSecuricorGreen,
WornTaxiYellow,
PoliceCarBlue,
MatteGreen,
MatteBrown,
WornOrange2,
MatteWhite,
WornWhite,
WornOliveArmyGreen,
PureWhite,
HotPink,
SalmonPink,
MetallicVermillionPink,
Orange,
Green,
Blue,
MettalicBlackBlue,
MetallicBlackPurple,
MetallicBlackRed,
HunterGreen,
MetallicPurple,
MetaillicVDarkBlue,
ModshopBlack,
MattePurple,
MatteDarkPurple,
MetallicLavaRed,
MatteForestGreen,
MatteOliveDrab,
MatteDesertBrown,
MatteDesertTan,
MatteFoilageGreen,
DefaultAlloy,
EpsilonBlue,
PureGold,
BrushedGold
}
18 changes: 18 additions & 0 deletions src/Enums/EHeadlightColor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace AltV.Atlas.Vehicles.Enums;

public enum EHeadlightColor
{
White,
Darkblue,
Lightblue,
Turquoise,
Green,
Yellow,
Gold,
Orange,
Red,
Pink,
Violet,
Purple,
Ultraviolet
}
13 changes: 13 additions & 0 deletions src/Enums/EWheelType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace AltV.Atlas.Vehicles.Enums;

public enum EWheelType
{
Sport,
Muscle,
Lowrider,
SUV,
Offroad,
Tuner,
BikeWheels,
HighEnd
}
9 changes: 5 additions & 4 deletions src/Factories/Entities/AtlasTuningVehicle.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using AltV.Net;
using AltV.Atlas.Vehicles.Interfaces;
using AltV.Net;
using Microsoft.Extensions.Logging;
namespace AltV.Atlas.Vehicles.Factories.Entities;

public class AtlasTuningVehicle : AtlasVehicle
{

public AtlasTuningVehicle( ICore core, IntPtr nativePointer, uint id ) : base( core, nativePointer, id )
public AtlasTuningVehicle( ILogger<IAtlasVehicle> logger, ICore core, IntPtr nativePointer, uint id ) : base( logger, core, nativePointer, id )
{
}
public AtlasTuningVehicle( uint vehicleId, ICore core, IntPtr nativePointer, uint id ) : base( vehicleId, core, nativePointer, id )
public AtlasTuningVehicle( ILogger<IAtlasVehicle> logger, uint vehicleId, ICore core, IntPtr nativePointer, uint id ) : base( logger, vehicleId, core, nativePointer, id )
{
}
}
15 changes: 10 additions & 5 deletions src/Factories/Entities/AtlasVehicle.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
using AltV.Net;
using AltV.Atlas.Vehicles.Interfaces;
using AltV.Net;
using AltV.Net.Async.Elements.Entities;
using AltV.Net.Data;
using AltV.Net.Elements.Entities;
using Microsoft.Extensions.Logging;
namespace AltV.Atlas.Vehicles.Factories.Entities;

public class AtlasVehicle : AsyncVehicle
public class AtlasVehicle : AsyncVehicle, IAtlasVehicle
{
protected readonly ILogger<IAtlasVehicle> _logger;
public uint Fuel => CalculateFuel( );
public uint VehicleId { get; private set; }

public AtlasVehicle( ICore core, IntPtr nativePointer, uint id ) : base( core, nativePointer, id )
public AtlasVehicle( ILogger<IAtlasVehicle> logger, ICore core, IntPtr nativePointer, uint id ) : base( core, nativePointer, id )
{
_logger = logger;
}

public AtlasVehicle( uint vehicleId, ICore core, IntPtr nativePointer, uint id ) : base( core, nativePointer, id )
public AtlasVehicle( ILogger<IAtlasVehicle> logger, uint vehicleId, ICore core, IntPtr nativePointer, uint id ) : base( core, nativePointer, id )
{
_logger = logger;
VehicleId = vehicleId;
}

Expand All @@ -41,7 +46,7 @@ public bool LockVehicle( IPlayer player )
{
return false;
}

private uint CalculateFuel( )
{
return 1;
Expand Down
21 changes: 21 additions & 0 deletions src/Factories/EntityFactories/AltVehicleFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using AltV.Atlas.Vehicles.Factories.Entities;
using AltV.Net;
using AltV.Net.Elements.Entities;
using Microsoft.Extensions.DependencyInjection;

namespace AltV.Atlas.Vehicles.Factories.EntityFactories;

public class AltVehicleFactory : IEntityFactory<IVehicle>
{
private readonly IServiceProvider _serviceProvider;

public AltVehicleFactory( IServiceProvider serviceProvider )
{
_serviceProvider = serviceProvider;
}

public IVehicle Create( ICore core, IntPtr entityPointer, uint id )
{
return ActivatorUtilities.CreateInstance<AtlasVehicle>( _serviceProvider, core, entityPointer, id );
}
}
27 changes: 21 additions & 6 deletions src/Factories/EntityFactories/AtlasVehicleFactory.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
using AltV.Atlas.Vehicles.Factories.Entities;
using AltV.Net;
using AltV.Net.Elements.Entities;
using AltV.Atlas.Vehicles.Interfaces;
using AltV.Net.Async;
using AltV.Net.Data;
using Microsoft.Extensions.Logging;

namespace AltV.Atlas.Vehicles.Factories.EntityFactories;

public class AtlasVehicleFactory : IEntityFactory<IVehicle>
public class AtlasVehicleFactory
{
public IVehicle Create( ICore core, IntPtr entityPointer, uint id )
private readonly ILogger<AtlasVehicleFactory> _logger;

public AtlasVehicleFactory( ILogger<AtlasVehicleFactory> logger )
{
_logger = logger;
}

public async Task<T> CreateVehicleAsync<T>( uint model, Position position, Rotation rotation ) where T : IAtlasVehicle
{
return new AtlasVehicle( core, entityPointer, id );
return ( T ) await AltAsync.CreateVehicle( model, position, rotation );
}

public async Task<IAtlasVehicle> CreateVehicleAsync( uint model, Position position, Rotation rotation )
{
return ( IAtlasVehicle ) await AltAsync.CreateVehicle( model, position, rotation );
}

}
13 changes: 13 additions & 0 deletions src/Interfaces/IAtlasVehicle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using AltV.Net.Data;
using AltV.Net.Elements.Entities;
namespace AltV.Atlas.Vehicles.Interfaces;

public interface IAtlasVehicle
{
uint VehicleId { get; }
uint Fuel { get; }
void SpawnVehicle( Position pos, Rotation rot, uint model );
void WarpOutOfVehicle( IPlayer player );
bool LockVehicle( object item );
bool LockVehicle( IPlayer player );
}
11 changes: 7 additions & 4 deletions src/VehicleModule.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
using AltV.Atlas.Vehicles.Factories.Entities;
using AltV.Atlas.Vehicles.Factories.EntityFactories;
using AltV.Atlas.Vehicles.Interfaces;
using AltV.Net;
using AltV.Net.Async.Elements.Entities;
using AltV.Net.Elements.Entities;
using Microsoft.Extensions.DependencyInjection;

namespace AltV.Atlas.Vehicles;

public static class VehicleModule
{
public static IServiceCollection RegisterPedModule( this IServiceCollection serviceCollection )
public static IServiceCollection RegisterVehicleModule( this IServiceCollection serviceCollection )
{
serviceCollection.AddTransient<AtlasVehicle>( );
serviceCollection.AddTransient<IAtlasVehicle, AtlasVehicle>( );
serviceCollection.AddTransient<AtlasVehicleFactory>( );
serviceCollection.AddTransient<IVehicle, AsyncVehicle>( );

//serviceCollection.AddTransient<IEntityFactory<IPed>, AtlasVehicleFactory>( );
serviceCollection.AddTransient<IEntityFactory<IVehicle>, AltVehicleFactory>( );

return serviceCollection;
}
}

0 comments on commit a0108d9

Please sign in to comment.