diff --git a/src/AltV/Entities/AtlasVehicleBase.cs b/src/AltV/Entities/AtlasVehicleBase.cs
index c548912..953843e 100644
--- a/src/AltV/Entities/AtlasVehicleBase.cs
+++ b/src/AltV/Entities/AtlasVehicleBase.cs
@@ -1,20 +1,18 @@
using AltV.Atlas.Vehicles.AltV.Interfaces;
using AltV.Net;
using AltV.Net.Async.Elements.Entities;
-using AltV.Net.Data;
using AltV.Net.Elements.Entities;
namespace AltV.Atlas.Vehicles.AltV.Entities;
-public class AtlasVehicleBase : AsyncVehicle, IAtlasVehicle
+public class AtlasVehicleBase( ICore core, IntPtr nativePointer, uint id ) : AsyncVehicle( core, nativePointer, id ), IAtlasVehicle
{
- public uint Fuel => CalculateFuel( );
public uint VehicleId { get; set; }
- public AtlasVehicleBase( ICore core, IntPtr nativePointer, uint id ) : base( core, nativePointer, id )
- {
- }
-
+ ///
+ /// Forces the player out of the vehicle
+ ///
+ /// The player to force out
public void WarpOutOfVehicle( IPlayer player )
{
var isInVehicle = Passengers.Any( s => s.Player == player );
@@ -33,9 +31,4 @@ public bool LockVehicle( IPlayer player )
{
return false;
}
-
- private uint CalculateFuel( )
- {
- return 1;
- }
}
\ No newline at end of file
diff --git a/src/AltV/Interfaces/IAtlasVehicle.cs b/src/AltV/Interfaces/IAtlasVehicle.cs
index 9043a14..4562ac0 100644
--- a/src/AltV/Interfaces/IAtlasVehicle.cs
+++ b/src/AltV/Interfaces/IAtlasVehicle.cs
@@ -5,7 +5,6 @@ namespace AltV.Atlas.Vehicles.AltV.Interfaces;
public interface IAtlasVehicle : IVehicle
{
- uint Fuel { get; }
uint VehicleId { get; set; }
void WarpOutOfVehicle( IPlayer player );
bool LockVehicle( object item );
diff --git a/src/Entities/AtlasTuningVehicle.cs b/src/Entities/AtlasTuningVehicle.cs
index e5ef94a..be531c4 100644
--- a/src/Entities/AtlasTuningVehicle.cs
+++ b/src/Entities/AtlasTuningVehicle.cs
@@ -1,71 +1,160 @@
using AltV.Atlas.Vehicles.AltV.Entities;
+using AltV.Atlas.Vehicles.Enums;
+using AltV.Atlas.Vehicles.Models;
+using AltV.Atlas.Vehicles.Utils;
using AltV.Net;
+using AltV.Net.Data;
+using AltV.Net.Enums;
namespace AltV.Atlas.Vehicles.Entities;
public class AtlasTuningVehicle : AtlasVehicleBase
{
+ ///
+ /// Creates an AtlasTuningVehicle
+ ///
+ /// AltV core
+ /// AltV nativePointer
+ /// Id of the ped
public AtlasTuningVehicle( ICore core, IntPtr nativePointer, uint id ) : base( core, nativePointer, id )
{
+ ModKit = 1;
+ NumberplateText = "ATLAS";
+ SetPrimaryRgb( "#1a222e" );
+ SetSecondaryRgb( "#15dbfc" );
+ SetPearlColor( EGtaColor.MatteBlack );
}
+ ///
+ /// All installed vehicle mods
+ ///
+ public List InstalledMods { get; } = new( );
+ ///
+ /// The primary color material
+ ///
+ public EColorMaterial PrimaryColorMaterial { get; private set; } = EColorMaterial.DefaultAlloy;
+ ///
+ /// The secondary color material
+ ///
+ public EColorMaterial SecondaryColorMaterial { get; private set; } = EColorMaterial.DefaultAlloy;
- // public List InstalledMods { get; } = new( );
- // public EColorMaterial PrimaryColorMaterial { get; private set; } = EColorMaterial.DefaultAlloy;
- // public EColorMaterial SecondaryColorMaterial { get; private set; } = EColorMaterial.DefaultAlloy;
-
- // public void SetPrimaryMaterial( EColorMaterial material )
- // {
- // var oldColor = PrimaryColorRgb;
- // PrimaryColor = ( byte ) material;
- // PrimaryColorRgb = oldColor;
- // }
- //
- // public void SetSecondaryMaterial( EColorMaterial material )
- // {
- // var oldColor = PrimaryColorRgb;
- // PrimaryColor = ( byte ) material;
- // PrimaryColorRgb = oldColor;
- // }
- //
- // public void SetPrimaryRgb( string rgb )
- // {
- // if( !rgb.TryParseRgb( out var color ) )
- // return;
- //
- // PrimaryColorRgb = new Rgba( color.R, color.G, color.B, color.A );
- // }
- //
- // public void SetSecondaryRgb( string rgb )
- // {
- // if( !rgb.TryParseRgb( out var color ) )
- // return;
- //
- // SecondaryColorRgb = new Rgba( color.R, color.G, color.B, color.A );
- // }
- //
- // public bool InstallMod( VehicleMod vehicleMod, bool force = false )
- // {
- // var maxIndex = GetModsCount( ( byte ) vehicleMod.ModType );
- //
- // if( vehicleMod.Index > maxIndex && !force )
- // {
- // return false;
- // }
- //
- // var result = SetMod( ( byte ) vehicleMod.ModType, ( byte ) vehicleMod.Index );
- // InstalledMods.Add( vehicleMod );
- // return result;
- // }
- //
- // public IEnumerable<( VehicleMod mod, bool result )> InstallMods( IEnumerable vehicleMods )
- // {
- // return ( from vehicleMod in vehicleMods let result = InstallMod( vehicleMod ) select ( vehicleMod, result ) ).ToList( );
- // }
- //
- // public bool RemoveMod( VehicleModType vehicleModType )
- // {
- // var result = SetMod( ( byte ) vehicleModType, 0 );
- // InstalledMods.RemoveAll( x => x.ModType == vehicleModType );
- // return result;
- // }
+ ///
+ /// Sets the PrimaryMaterial of the vehicle
+ /// A list of all available Materials can be found in the EColorMaterial Enum
+ ///
+ /// The material to apply
+ public void SetPrimaryMaterial( EColorMaterial material )
+ {
+ var oldColor = PrimaryColorRgb;
+ PrimaryColor = ( byte ) material;
+ PrimaryColorRgb = oldColor;
+ }
+
+ ///
+ /// Sets the SecondaryMaterial of the vehicle
+ /// A list of all available Materials can be found in the EColorMaterial Enum
+ ///
+ /// The material to apply
+ public void SetSecondaryMaterial( EColorMaterial material )
+ {
+ var oldColor = PrimaryColorRgb;
+ PrimaryColor = ( byte ) material;
+ PrimaryColorRgb = oldColor;
+ }
+
+ ///
+ /// Sets the vehicle PrimaryColorRgb from a string
+ ///
+ ///
+ public void SetPrimaryRgb( string rgb )
+ {
+ if( !rgb.TryParseRgb( out var color ) )
+ return;
+
+ PrimaryColorRgb = new Rgba( color.R, color.G, color.B, color.A );
+ }
+
+ ///
+ /// Sets the vehicle SecondaryColorRgb from a string
+ ///
+ ///
+ public void SetSecondaryRgb( string rgb )
+ {
+ if( !rgb.TryParseRgb( out var color ) )
+ return;
+
+ SecondaryColorRgb = new Rgba( color.R, color.G, color.B, color.A );
+ }
+
+ ///
+ /// Sets the vehicle PearlColor from a EGtaColor
+ ///
+ ///
+ public void SetPearlColor( EGtaColor color ) => PearlColor = ( byte ) color;
+
+ ///
+ /// Installs a given VehicleMod
+ ///
+ /// The mod to install
+ /// Force the mod index even if it should not exist
+ /// Returns if the SetMod was successful
+ public bool InstallMod( VehicleMod vehicleMod, bool force = false )
+ {
+ var maxIndex = GetModsCount( ( byte ) vehicleMod.ModType );
+
+ if( vehicleMod.Index > maxIndex && !force )
+ {
+ return false;
+ }
+
+ var result = SetMod( ( byte ) vehicleMod.ModType, ( byte ) vehicleMod.Index );
+
+ if( result )
+ InstalledMods.Add( vehicleMod );
+
+ return result;
+ }
+
+ ///
+ /// Installs a list of mods
+ ///
+ /// The list of mods to install
+ /// Returns a list of tuples with the given mod and the SetMod result
+ public IEnumerable<( VehicleMod mod, bool result )> InstallMods( IEnumerable vehicleMods )
+ {
+ return ( from vehicleMod in vehicleMods let result = InstallMod( vehicleMod ) select ( vehicleMod, result ) ).ToList( );
+ }
+
+ ///
+ /// Removes the given VehicleModType
+ ///
+ /// The type to remove
+ /// Returns the SetMod result or false if the mod wasn't installed
+ public bool RemoveMod( VehicleModType vehicleModType )
+ {
+ if( InstalledMods.All( mod => mod.ModType != vehicleModType ) )
+ return false;
+
+ var result = SetMod( ( byte ) vehicleModType, 0 );
+ InstalledMods.RemoveAll( x => x.ModType == vehicleModType );
+ return result;
+ }
+
+ ///
+ /// Removes all installed vehicleMods
+ ///
+ /// Returns a list of tuples with the given mod and the SetMod result
+ public IEnumerable<( VehicleMod mod, bool result )> RemoveMods( )
+ {
+ return ( from vehicleMod in InstalledMods.ToList( ) let result = RemoveMod( vehicleMod.ModType ) select ( vehicleMod, result ) ).ToList( );
+ }
+
+ ///
+ /// Removes all given vehicleMods
+ ///
+ ///
+ /// Returns a list of tuples with the given mod and the SetMod result
+ public IEnumerable<( VehicleMod mod, bool result )> RemoveMods( IEnumerable vehicleMods )
+ {
+ return ( from vehicleMod in vehicleMods.ToList( ) let result = RemoveMod( vehicleMod.ModType ) select ( vehicleMod, result ) ).ToList( );
+ }
}
\ No newline at end of file
diff --git a/src/Factories/AtlasVehicleFactory.cs b/src/Factories/AtlasVehicleFactory.cs
index 89bacef..f8f267d 100644
--- a/src/Factories/AtlasVehicleFactory.cs
+++ b/src/Factories/AtlasVehicleFactory.cs
@@ -34,7 +34,6 @@ public AtlasVehicleFactory( ILogger logger, IServiceProvide
///
/// Create a new vehicle of type T
///
- ///
/// The model of the vehicle
/// The position to spawn the vehicle at
/// The rotation to spawn the vehicle at
diff --git a/src/Models/VehicleMod.cs b/src/Models/VehicleMod.cs
index bf3b22b..23cffd4 100644
--- a/src/Models/VehicleMod.cs
+++ b/src/Models/VehicleMod.cs
@@ -3,23 +3,14 @@ namespace AltV.Atlas.Vehicles.Models;
public class VehicleMod
{
- ///
- /// Constructor to create a VehicleMod
- ///
- /// The type of the mod
- /// The index of the mod
- public VehicleMod( VehicleModType vehicleModType, uint index )
- {
- ModType = vehicleModType;
- Index = index;
- }
///
/// Type of the vehicle mod
///
- public VehicleModType ModType { get; set; }
+ public VehicleModType ModType { get; init; }
///
/// Index of the vehicle mod
///
- public uint Index { get; set; }
+ public uint Index { get; init; }
+
}
\ No newline at end of file