Don't use dictionary to store vehicle mods

This commit is contained in:
Sardelka9515
2023-03-20 17:14:52 +08:00
parent 7cd0fd22af
commit 5f1aadbdb5
4 changed files with 19 additions and 13 deletions

View File

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using GTA;
using GTA.Math;
@ -23,7 +24,7 @@ namespace RageCoop.Client
internal VehicleRoofState RoofState { get; set; }
internal VehicleDamageModel DamageModel { get; set; }
internal (byte, byte) Colors { get; set; }
internal Dictionary<int, int> Mods { get; set; }
internal (int, int)[] Mods { get; set; }
internal float EngineHealth { get; set; }
internal VehicleLockStatus LockStatus { get; set; }
internal byte RadioStation = 255;
@ -66,7 +67,7 @@ namespace RageCoop.Client
#region PRIVATE
private (byte, byte) _lastVehicleColors;
private Dictionary<int, int> _lastVehicleMods = new();
private (int, int)[] _lastVehicleMods = Array.Empty<(int, int)>();
private bool _lastHornActive;
private bool _lastTransformed;
internal int _lastLivery = -1;

View File

@ -1,4 +1,5 @@
using System;
using System.Linq;
using GTA;
using GTA.Math;
using GTA.Native;
@ -131,11 +132,11 @@ namespace RageCoop.Client
}
MainVehicle.EngineHealth = EngineHealth;
if (Mods != null && !Mods.Compare(_lastVehicleMods))
if (Mods != null && !Mods.SequenceEqual(_lastVehicleMods))
{
Call(SET_VEHICLE_MOD_KIT, MainVehicle, 0);
foreach (var mod in Mods) MainVehicle.Mods[(VehicleModType)mod.Key].Index = mod.Value;
foreach (var mod in Mods) MainVehicle.Mods[(VehicleModType)mod.Item1].Index = mod.Item2;
_lastVehicleMods = Mods;
}