log error if frame is not child of vehicle

This commit is contained in:
in0finite 2020-07-04 19:11:39 +02:00
parent 96b0ac1f33
commit 9c63b25d38

View file

@ -213,9 +213,20 @@ namespace SanAndreasUnity.Behaviours.Vehicles
{
Frame frame = this.Frames.FirstOrDefault(f => f.gameObject.name == frameName);
if (null == frame)
{
Debug.LogError($"Failed to find frame by name: {frameName}");
}
else
DetachFrameDuringExplosion(frame, mass, parentGo);
{
if (this.transform.IsParentOf(frame.transform))
{
DetachFrameDuringExplosion(frame, mass, parentGo);
}
else
{
Debug.LogError($"Can not detach frame ({frameName}) from vehicle {this.DescriptionForLogging} because it seems that the frame is already detached");
}
}
}
void DetachFrameDuringExplosion(Frame frame, float mass, GameObject parentGo)