public virtual void UpdateForce(T2DPhysicsComponent physics, float strength, Vector2 offset, Vector2 direction, float dt)
 {
     strength = strength * (MaxStrength - MinStrength) + MinStrength;
     // will be modified by inverse mass (and inverse rot inertia)
     physics.ApplyImpulse(-direction * strength * dt, offset);
 }
 public override void UpdateForce(T2DPhysicsComponent physics, float strength, Vector2 offset, Vector2 direction, float dt)
 {
     strength = strength * (MaxStrength - MinStrength) + MinStrength;
     if (offset.LengthSquared() < 0.0001f || physics.Immovable)
         // skip the mass route -- will work on immovable
         physics.Velocity -= direction * strength * dt;
     else
         // have to use real impulse, multiply by mass
         physics.ApplyImpulse(-direction * strength * physics.Mass * dt, offset);
 }
            protected void _ApplyDrag(Vector2 vel, T2DPhysicsComponent physics, float strength, float rotStrength, Vector2 offset, Vector2 direction, float dt)
            {
                // adjust rotation velocity based on rotation drag
                if (rotStrength < 0.0f)
                    // handle case where negative force is set
                    rotStrength = 0.0f;
                if (!ConstantDrag)
                    rotStrength *= Math.Abs(physics.AngularVelocity);
                if (rotStrength > AbsoluteDragRotationCap)
                    rotStrength = AbsoluteDragFactor * AbsoluteDragRotationCap;
                rotStrength *= dt;
                if (rotStrength > Math.Abs(physics.AngularVelocity))
                    physics.AngularVelocity = 0.0f;
                else if (physics.AngularVelocity > 0.0f)
                    physics.AngularVelocity -= rotStrength;
                else
                    physics.AngularVelocity += rotStrength;

                float velLen = vel.Length();
                if (velLen > Epsilon.Value)
                    vel.Normalize();

                // adjust by velocity and update interval
                if (!ConstantDrag)
                    strength *= velLen;
                if (strength > AbsoluteDragCap)
                    strength = AbsoluteDragFactor * AbsoluteDragCap;
                strength *= dt;

                // make sure we don't overshoot
                if (strength > velLen)
                    strength = velLen;

                if (!physics.Immovable)
                    physics.ApplyImpulse(-strength * vel * physics.Mass, offset);
                else
                    physics.Velocity -= strength * vel;
            }