GameEntities.RTSBuilding.OnDamage C# (CSharp) Method

OnDamage() protected method

protected OnDamage ( MapObject prejudicial, Vec3 pos, Shape shape, float damage, bool allowMoveDamageToParent ) : void
prejudicial MapObject
pos Vec3
shape Shape
damage float
allowMoveDamageToParent bool
return void
        protected override void OnDamage( MapObject prejudicial, Vec3 pos, Shape shape, float damage,
			bool allowMoveDamageToParent )
        {
            float oldLife = Life;

            base.OnDamage( prejudicial, pos, shape, damage, allowMoveDamageToParent );

            if( damage < 0 && BuildedProgress != 1 )
            {
                BuildedProgress += ( -damage ) / Type.LifeMax;
                if( BuildedProgress > 1 )
                    BuildedProgress = 1;

                if( BuildedProgress != 1 && Life == Type.LifeMax )
                    Life = Type.LifeMax - .01f;
            }

            float halfLife = Type.LifeMax * .5f;
            if( Life > halfLife && oldLife <= halfLife )
                UpdateAttachedObjectsVisibility();
            else if( Life < halfLife && oldLife >= halfLife )
                UpdateAttachedObjectsVisibility();

            float quarterLife = Type.LifeMax * .25f;
            if( Life > quarterLife && oldLife <= quarterLife )
                UpdateAttachedObjectsVisibility();
            else if( Life < quarterLife && oldLife >= quarterLife )
                UpdateAttachedObjectsVisibility();
        }