add onColorsChanged event to Vehicle

This commit is contained in:
in0finite 2021-11-17 19:05:34 +01:00
parent a5d3c657fc
commit 6adfbcd69c

View file

@ -125,6 +125,8 @@ namespace SanAndreasUnity.Behaviours.Vehicles
private static readonly int CarEmissionPropertyId = Shader.PropertyToID("_CarEmission");
private bool _colorsChanged, _isNightToggled;
public event System.Action onColorsChanged = delegate {};
private const float constRearNightIntensity = .7f;
public bool IsNightToggled
@ -441,9 +443,14 @@ namespace SanAndreasUnity.Behaviours.Vehicles
private void UpdateMaterials()
{
if (!_colorsChanged)
return;
_colorsChanged = false;
UpdateMaterials(_frames, _colors, _lights, _props);
F.InvokeEventExceptionSafe(this.onColorsChanged);
}
public static void UpdateMaterials(
@ -530,10 +537,7 @@ namespace SanAndreasUnity.Behaviours.Vehicles
}
}
if (_colorsChanged)
{
UpdateMaterials();
}
this.UpdateMaterials();
this.Update_Damage();