ReSharper suggests using null propagation for the "damageable" if block, but for the "forceVelocityCalculator" one there is no suggestion.
void Damage(Collider hitCollider)
{
var damageable = hitCollider.GetComponent<IDamageable>();
if (damageable != null)
{
damageable.TakeDamage(_damage);
}
}
void Push(Collider hitCollider)
{
var forceVelocityCalculator = hitCollider.GetComponent<ForceVelocityCalculator>();
if (forceVelocityCalculator != null)
{
forceVelocityCalculator.Push(_pushForce, GameAPI.playerTransform.transform.forward);
}
}
Am I missing something? I would use null propagation for both blocks.