protected virtual void OnDamage( MapObject prejudicial, Vec3 pos, Shape shape, float damage,
bool allowMoveDamageToParent)
{
float realDamage = damage * ReceiveDamageCoefficient;
if( Type.LifeMax != 0 )
{
float newLife = Life - realDamage;
MathFunctions.Clamp( ref newLife, Type.LifeMin, Type.LifeMax );
Life = newLife;
if( Life == 0 )
Die( prejudicial );
}
else
{
if( allowMoveDamageToParent )
{
//damage to parent
Dynamic dynamic = AttachedMapObjectParent as Dynamic;
if( dynamic != null )
dynamic.OnDamage( prejudicial, pos, shape, realDamage, true );
}
}
if( Damage != null )
Damage( this, prejudicial, pos, realDamage );
}