public void AddSolid( Solid solid )
            {
                if ( solid == null )
                    return;

                mSolids.Add( solid );
            }
        public void Cancel()
        {
            mFace = null;
            Started = false;

            if ( Game.Input.CheckFocus( mSelectedSolid ) )
                Game.Input.Focus = null;

            mSelectedSolid = null;
            mStartPos = Vector2.Zero;
        }
            protected void MoveSolid( Solid solid, CompassDirection dir )
            {
                Face nextFace = AdjacentFace( dir );
                var backDir = nextFace.BackwardsDirectionFrom( this );

                mSolids.Remove( solid );
                solid.World = nextFace.World;
                nextFace.mSolids.Add( solid );

                Body body = solid.Body;

                float pastRotation = body.Rotation;

                body.Rotation += nextFace.Rotation;
                body.AdHocGravity = Vector2.UnitY.Rotate( -body.Rotation ).Rounded();
                body.Awake = true;

                body.Position = body.Position.Rotate( pastRotation - body.Rotation );
                body.LinearVelocity = body.LinearVelocity.Rotate( pastRotation - body.Rotation );
            }
            private IEnumerable<CompassDirection> ClampSolid( Solid solid )
            {
                Vector2 pos = solid.Body.Position.ToPixels();

                if ( pos.X > WIDTH )
                {
                    solid.Body.Position = new Vector2( WIDTH, pos.Y ).ToUnits();

                    var dir = VectorToDirection( Vector3.UnitX );
                    if ( dir != null )
                        yield return dir.Value;
                }
                else if ( pos.X < 0 )
                {
                    solid.Body.Position = new Vector2( 0, pos.Y ).ToUnits();

                    var dir = VectorToDirection( -Vector3.UnitX );
                    if ( dir != null )
                        yield return dir.Value;
                }

                if ( pos.Y > HEIGHT )
                {
                    solid.Body.Position = new Vector2( pos.X, HEIGHT ).ToUnits();

                    var dir = VectorToDirection( Vector3.UnitY );
                    if ( dir != null )
                        yield return dir.Value;
                }
                else if ( pos.Y < 0 )
                {
                    solid.Body.Position = new Vector2( pos.X, 0 ).ToUnits();

                    var dir = VectorToDirection( -Vector3.UnitY );
                    if ( dir != null )
                        yield return dir.Value;
                }
            }
 public void RemoveSolid( Solid solid )
 {
     mSolids.Remove( solid );
     World.RemoveBody( solid.Body );
 }
        public void Start( EditableCube.Face face, Vector2 mousePos, GameTime gameTime )
        {
            Solid selectedSolid = face.FindSolidAt( mousePos.ToUnits() );

            if ( selectedSolid != mSelectedSolid )
                Cancel();

            if ( selectedSolid != null )
            {
                mFace = face;
                Started = true;
                mStartPos = mousePos;
                mSelectedSolid = selectedSolid;
                mOriginalPos = mSelectedSolid.Position;
                Game.Input.Focus = mSelectedSolid;
            }
        }