csharp/Alan-FGR/aelum/Farseer/Farseer%20Physics%20Engine%203.5/Common/PhysicsLogic/SimpleExplosion.cs

SimpleExplosion.cs
using System;
using System.Collections.Generic;
using FarseerPhysics.Collision;
using FarseerPhysics.Dynamics;
using Microsoft.Xna.Framework;

namespace FarseerPhysics.Common.PhysicsLogic
{
    /// 
    /// Creates a simple explosion that ignores other bodies hiding behind static bodies.
    /// 
    public sealed clast SimpleExplosion : PhysicsLogic
    {
        public SimpleExplosion(World world)
            : base(world, PhysicsLogicType.Explosion)
        {
            Power = 1; //linear
        }

        /// 
        /// This is the power used in the power function. A value of 1 means the force
        /// applied to bodies in the explosion is linear. A value of 2 means it is exponential.
        /// 
        public float Power { get; set; }

        /// 
        /// Activate the explosion at the specified position.
        /// 
        /// The position (center) of the explosion.
        /// The radius of the explosion.
        /// The force applied
        /// A maximum amount of force. When force gets over this value, it will be equal to maxForce
        /// A list of bodies and the amount of force that was applied to them.
        public Dictionary Activate(Vector2 pos, float radius, float force, float maxForce = float.MaxValue)
        {
            HashSet affectedBodies = new HashSet();

            AABB aabb;
            aabb.LowerBound = pos - new Vector2(radius);
            aabb.UpperBound = pos + new Vector2(radius);

            // Query the world for bodies within the radius.
            World.QueryAABB(fixture =>
            {
                if (Vector2.Distance(fixture.Body.Position, pos)