Bug fixes. Compare() added to compare two Dictionary<>

This commit is contained in:
EntenKoeniq 2021-12-16 22:26:45 +01:00
parent 6c09c10bd9
commit 6742fb9050
4 changed files with 29 additions and 3 deletions

View File

@ -177,7 +177,7 @@ namespace CoopClient.Entities
return;
}
}
else if (Clothes != LastClothes)
else if (!Clothes.Compare(LastClothes))
{
foreach (KeyValuePair<byte, short> cloth in Clothes)
{

View File

@ -102,7 +102,7 @@ namespace CoopClient.Entities
}
}
if (Character.Weapons.Current.Hash != (WeaponHash)CurrentWeaponHash || WeaponComponents != LastWeaponComponents)
if (Character.Weapons.Current.Hash != (WeaponHash)CurrentWeaponHash || !WeaponComponents.Compare(LastWeaponComponents))
{
Character.Weapons.RemoveAll();

View File

@ -194,7 +194,7 @@ namespace CoopClient.Entities
}
else
{
if (VehicleMods != null && VehicleMods != LastVehicleMods)
if (VehicleMods != null && !VehicleMods.Compare(LastVehicleMods))
{
Function.Call(Hash.SET_VEHICLE_MOD_KIT, MainVehicle, 0);

View File

@ -75,6 +75,32 @@ namespace CoopClient
return Comparer<T>.Default.Compare(item, start) >= 0 && Comparer<T>.Default.Compare(item, end) <= 0;
}
public static bool Compare<T, Y>(this Dictionary<T, Y> item, Dictionary<T, Y> item2)
{
if (item == null || item2 == null || item.Count != item2.Count)
{
return false;
}
foreach (KeyValuePair<T, Y> pair in item)
{
if (item2.TryGetValue(pair.Key, out Y value))
{
if (!Equals(value, pair.Value))
{
return false;
}
continue;
}
break;
}
return true;
}
public static Vector3 LinearVectorLerp(Vector3 start, Vector3 end, ulong currentTime, int duration)
{
return new Vector3()