ped can not be damaged by explosion while he is in vehicle

This commit is contained in:
in0finite 2020-06-29 17:50:33 +02:00
parent e5c6144706
commit 99c1cf8ecc
3 changed files with 15 additions and 3 deletions

View file

@ -195,6 +195,17 @@ namespace SanAndreasUnity.Behaviours.Peds.States
return base.GetCameraFocusPos();
}
public override void OnDamaged(DamageInfo damageInfo)
{
if (damageInfo.damageType == DamageType.Explosion)
{
// ped should not be damaged by explosion while he is in vehicle
return;
}
base.OnDamaged(damageInfo);
}
}
}

View file

@ -187,7 +187,8 @@ namespace SanAndreasUnity.Behaviours.Vehicles
explosionCenter,
VehicleManager.Instance.explosionDamageRadius,
Mathf.Pow(this.HandlingData.Mass, VehicleManager.Instance.explosionMassToDamageExponent),
VehicleManager.Instance.explosionDamageOverDistanceCurve);
VehicleManager.Instance.explosionDamageOverDistanceCurve,
DamageType.Explosion);
// create explosion effect

View file

@ -53,7 +53,7 @@ namespace SanAndreasUnity.Utilities
}
public static void InflictDamageToObjectsInArea(
Vector3 center, float radius, float damageAmount, AnimationCurve damageOverDistanceCurve)
Vector3 center, float radius, float damageAmount, AnimationCurve damageOverDistanceCurve, string damageType)
{
Collider[] overlappingColliders = Physics.OverlapSphere(center, radius);
@ -102,7 +102,7 @@ namespace SanAndreasUnity.Utilities
float distanceFactor = damageOverDistanceCurve.Evaluate(Mathf.Clamp01(distance / radius));
float damageAmountBasedOnDistance = damageAmount * distanceFactor;
F.RunExceptionSafe(() => damageable.Damage(new DamageInfo() { amount = damageAmountBasedOnDistance }));
F.RunExceptionSafe(() => damageable.Damage(new DamageInfo() { amount = damageAmountBasedOnDistance, damageType = damageType }));
}
}