public override void HandleInput(InputState input)
 {
     if (input.InGameSelect)
     {
         Viewport viewport = base.ScreenManager.GraphicsDevice.Viewport;
         Vector3 nearPoint = viewport.Unproject(new Vector3(input.CursorPosition, 0f), this.projection, this.view, Matrix.Identity);
         Viewport viewport1 = base.ScreenManager.GraphicsDevice.Viewport;
         Vector3 farPoint = viewport1.Unproject(new Vector3(input.CursorPosition, 1f), this.projection, this.view, Matrix.Identity);
         Vector3 direction = farPoint - nearPoint;
         direction.Normalize();
         Ray pickRay = new Ray(nearPoint, direction);
         float k = -pickRay.Position.Z / pickRay.Direction.Z;
         Vector3 pickedPosition = new Vector3(pickRay.Position.X + k * pickRay.Direction.X, pickRay.Position.Y + k * pickRay.Direction.Y, 0f);
         if (Vector3.Distance(pickedPosition, this.planetSO.WorldBoundingSphere.Center) < this.planetSO.WorldBoundingSphere.Radius)
         {
             AudioManager.PlayCue("sd_bomb_impact_01");
             Vector3 VectorToCenter = pickedPosition - this.planetSO.WorldBoundingSphere.Center;
             VectorToCenter = Vector3.Normalize(VectorToCenter);
             VectorToCenter = this.planetSO.WorldBoundingSphere.Center + (VectorToCenter * this.planetSO.WorldBoundingSphere.Radius);
         }
     }
     this.currentMouse = input.CurrentMouseState;
     Vector2 MousePos = new Vector2((float)this.currentMouse.X, (float)this.currentMouse.Y);
     bool okcomet = true;
     foreach (UIButton b in this.Buttons)
     {
         if (!HelperFunctions.CheckIntersection(b.Rect, MousePos))
         {
             b.State = UIButton.PressState.Normal;
         }
         else
         {
             okcomet = false;
             if (b.State != UIButton.PressState.Hover && b.State != UIButton.PressState.Pressed)
             {
                 AudioManager.PlayCue("mouse_over4");
             }
             b.State = UIButton.PressState.Hover;
             if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Pressed)
             {
                 b.State = UIButton.PressState.Pressed;
             }
             if (this.currentMouse.LeftButton != ButtonState.Pressed || this.previousMouse.LeftButton != ButtonState.Released)
             {
                 continue;
             }
             string launches = b.Launches;
             string str = launches;
             if (launches == null)
             {
                 continue;
             }
             if (str == "New Campaign")
             {
                 AudioManager.PlayCue("sd_ui_tactical_pause");
                 this.OnPlayGame();
             }
             else if (str == "Tutorials")
             {
                 AudioManager.PlayCue("sd_ui_tactical_pause");
                 base.ScreenManager.AddScreen(new TutorialScreen());
             }
             else if (str == "Load Game")
             {
                 AudioManager.PlayCue("sd_ui_tactical_pause");
                 base.ScreenManager.AddScreen(new LoadSaveScreen(this));
             }
             else if (str == "Options")
             {
                 OptionsScreen opt = new OptionsScreen(this, new Rectangle(0, 0, 600, 600))
                 {
                     TitleText = Localizer.Token(4),
                     MiddleText = Localizer.Token(4004)
                 };
                 base.ScreenManager.AddScreen(opt);
             }
             else if (str == "Mods")
             {
                 ModManager mm = new ModManager(this);
                 base.ScreenManager.AddScreen(mm);
             }
             else if (str == "Exit")
             {
                 Game1.Instance.Exit();
             }
         }
     }
     if (input.C && input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift))
     {
         base.ScreenManager.AddScreen(new ShipToolScreen());
         this.ExitScreen();
     }
     if (okcomet && input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released)
     {
         MainMenuScreen.Comet c = new MainMenuScreen.Comet();
         //{
         c.Position = new Vector2(RandomMath.RandomBetween(-100f, (float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth + 100)), 0f);
             c.Velocity = HelperFunctions.FindVectorToTarget(c.Position, input.CursorPosition);
         //};
         c.Velocity = Vector2.Normalize(c.Velocity);
         c.Rotation = (float)MathHelper.ToRadians(HelperFunctions.findAngleToTarget(c.Position, c.Position + c.Velocity));
         this.CometList.Add(c);
     }
     this.previousMouse = input.LastMouseState;
     base.HandleInput(input);
 }
 public override void Draw(GameTime gameTime)
 {
     float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds;
     MainMenuScreen mainMenuScreen = this;
     mainMenuScreen.rotate = mainMenuScreen.rotate + elapsedTime / 350f;
     if ((double)RandomMath.RandomBetween(0f, 100f) > 99.75)
     {
         MainMenuScreen.Comet c = new MainMenuScreen.Comet()
         {
             Position = new Vector2(RandomMath.RandomBetween(-100f, (float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth + 100)), 0f),
             Velocity = new Vector2(RandomMath.RandomBetween(-1f, 1f), 1f)
         };
         c.Velocity = Vector2.Normalize(c.Velocity);
         c.Rotation = (float)MathHelper.ToRadians(HelperFunctions.findAngleToTarget(c.Position, c.Position + c.Velocity));
         this.CometList.Add(c);
     }
     Vector2 CometOrigin = new Vector2((float)(Ship_Game.ResourceManager.TextureDict["GameScreens/comet"].Width / 2), (float)(Ship_Game.ResourceManager.TextureDict["GameScreens/comet"].Height / 2));
     if (SplashScreen.DisplayComplete)
     {
         base.ScreenManager.splashScreenGameComponent.Visible = false;
         base.ScreenManager.sceneState.BeginFrameRendering(this.view, this.projection, gameTime, base.ScreenManager.environment, true);
         base.ScreenManager.editor.BeginFrameRendering(base.ScreenManager.sceneState);
         try
         {
             base.ScreenManager.inter.BeginFrameRendering(base.ScreenManager.sceneState);
         }
         catch { }
         this.DrawNew(gameTime);
         base.ScreenManager.inter.RenderManager.Render();
         base.ScreenManager.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None);
         base.ScreenManager.GraphicsDevice.RenderState.SourceBlend = Blend.InverseDestinationColor;
         base.ScreenManager.GraphicsDevice.RenderState.DestinationBlend = Blend.One;
         base.ScreenManager.GraphicsDevice.RenderState.BlendFunction = BlendFunction.Add;
         Viewport viewport = base.ScreenManager.GraphicsDevice.Viewport;
         Vector3 mp = viewport.Project(this.planetSO.WorldBoundingSphere.Center, this.projection, this.view, Matrix.Identity);
         Vector2 MoonFlarePos = new Vector2(mp.X - 40f - 2f, mp.Y - 40f + 24f) + this.FlareAdd;
         Vector2 Origin = new Vector2(184f, 184f);
         Rectangle? nullable = null;
         base.ScreenManager.SpriteBatch.Draw(Ship_Game.ResourceManager.TextureDict["MainMenu/moon_flare"], MoonFlarePos, nullable, Color.White, 0f, Origin, 0.95f, SpriteEffects.None, 1f);
         base.ScreenManager.SpriteBatch.End();
         base.ScreenManager.SpriteBatch.Begin();
         if (this.AnimationFrame >= 41 && this.AnimationFrame < 52)
         {
             float alphaStep = (float)(255 / 12);
             float Alpha = (float)(this.AnimationFrame - 41) * alphaStep;
             if (Alpha > 220f)
             {
                 Alpha = 220f;
             }
             Rectangle moon1 = new Rectangle((int)MoonFlarePos.X - 220, (int)MoonFlarePos.Y - 130, 201, 78);
             base.ScreenManager.SpriteBatch.Draw(Ship_Game.ResourceManager.TextureDict["MainMenu/moon_1"], moon1, new Color(Color.White, (byte)Alpha));
         }
         if (this.AnimationFrame >= 52 && this.AnimationFrame <= 67)
         {
             float Alpha = 220f;
             Rectangle moon1 = new Rectangle((int)MoonFlarePos.X - 220, (int)MoonFlarePos.Y - 130, 201, 78);
             base.ScreenManager.SpriteBatch.Draw(Ship_Game.ResourceManager.TextureDict["MainMenu/moon_1"], moon1, new Color(Color.White, (byte)Alpha));
         }
         if (this.AnimationFrame > 67 && this.AnimationFrame <= 95)
         {
             float alphaStep = (float)(255 / 28);
             float Alpha = 255f - (float)(this.AnimationFrame - 67) * alphaStep;
             if (Alpha < 0f)
             {
                 Alpha = 0f;
             }
             if (Alpha > 220f)
             {
                 Alpha = 220f;
             }
             Rectangle moon1 = new Rectangle((int)MoonFlarePos.X - 220, (int)MoonFlarePos.Y - 130, 201, 78);
             base.ScreenManager.SpriteBatch.Draw(Ship_Game.ResourceManager.TextureDict["MainMenu/moon_1"], moon1, new Color(Color.White, (byte)Alpha));
         }
         if (this.AnimationFrame >= 161 && this.AnimationFrame < 172)
         {
             float alphaStep = (float)(255 / 12);
             float Alpha = (float)(this.AnimationFrame - 161) * alphaStep;
             if (Alpha > 220f)
             {
                 Alpha = 220f;
             }
             Rectangle moon1 = new Rectangle((int)MoonFlarePos.X - 250, (int)MoonFlarePos.Y + 60, 254, 82);
             base.ScreenManager.SpriteBatch.Draw(Ship_Game.ResourceManager.TextureDict["MainMenu/moon_2"], moon1, new Color(Color.White, (byte)Alpha));
         }
         if (this.AnimationFrame >= 172 && this.AnimationFrame <= 187)
         {
             float Alpha = 220f;
             Rectangle moon1 = new Rectangle((int)MoonFlarePos.X - 250, (int)MoonFlarePos.Y + 60, 254, 82);
             base.ScreenManager.SpriteBatch.Draw(Ship_Game.ResourceManager.TextureDict["MainMenu/moon_2"], moon1, new Color(Color.White, (byte)Alpha));
         }
         if (this.AnimationFrame > 187 && this.AnimationFrame <= 215)
         {
             float alphaStep = (float)(255 / 28);
             float Alpha = 255f - (float)(this.AnimationFrame - 187) * alphaStep;
             if (Alpha < 0f)
             {
                 Alpha = 0f;
             }
             if (Alpha > 220f)
             {
                 Alpha = 220f;
             }
             Rectangle moon1 = new Rectangle((int)MoonFlarePos.X - 250, (int)MoonFlarePos.Y + 60, 254, 82);
             base.ScreenManager.SpriteBatch.Draw(Ship_Game.ResourceManager.TextureDict["MainMenu/moon_2"], moon1, new Color(Color.White, (byte)Alpha));
         }
         if (this.AnimationFrame >= 232 && this.AnimationFrame < 243)
         {
             float alphaStep = (float)(255 / 12);
             float Alpha = (float)(this.AnimationFrame - 232) * alphaStep;
             if (Alpha > 220f)
             {
                 Alpha = 220f;
             }
             Rectangle moon1 = new Rectangle((int)MoonFlarePos.X + 60, (int)MoonFlarePos.Y + 80, 156, 93);
             base.ScreenManager.SpriteBatch.Draw(Ship_Game.ResourceManager.TextureDict["MainMenu/moon_3"], moon1, new Color(Color.White, (byte)Alpha));
         }
         if (this.AnimationFrame >= 243 && this.AnimationFrame <= 258)
         {
             float Alpha = 220f;
             Rectangle moon1 = new Rectangle((int)MoonFlarePos.X + 60, (int)MoonFlarePos.Y + 80, 156, 93);
             base.ScreenManager.SpriteBatch.Draw(Ship_Game.ResourceManager.TextureDict["MainMenu/moon_3"], moon1, new Color(Color.White, (byte)Alpha));
         }
         if (this.AnimationFrame > 258 && this.AnimationFrame <= 286)
         {
             float alphaStep = (float)(255 / 28);
             float Alpha = 255f - (float)(this.AnimationFrame - 258) * alphaStep;
             if (Alpha < 0f)
             {
                 Alpha = 0f;
             }
             if (Alpha > 220f)
             {
                 Alpha = 220f;
             }
             Rectangle moon1 = new Rectangle((int)MoonFlarePos.X + 60, (int)MoonFlarePos.Y + 80, 156, 93);
             base.ScreenManager.SpriteBatch.Draw(Ship_Game.ResourceManager.TextureDict["MainMenu/moon_3"], moon1, new Color(Color.White, (byte)Alpha));
         }
         base.ScreenManager.SpriteBatch.End();
         base.ScreenManager.SpriteBatch.Begin(SpriteBlendMode.Additive);
         foreach (MainMenuScreen.Comet c in this.CometList)
         {
             float Alpha = 255f;
             if (c.Position.Y > 100f)
             {
                 Alpha = 25500f / c.Position.Y;
                 if (Alpha > 255f)
                 {
                     Alpha = 255f;
                 }
             }
             Rectangle? nullable1 = null;
             base.ScreenManager.SpriteBatch.Draw(Ship_Game.ResourceManager.TextureDict["GameScreens/comet2"], c.Position, nullable1, new Color(255, 255, 255, (byte)Alpha), c.Rotation, CometOrigin, 0.45f, SpriteEffects.None, 1f);
             MainMenuScreen.Comet position = c;
             position.Position = position.Position + ((c.Velocity * 2400f) * elapsedTime);
             if (c.Position.Y <= 1050f)
             {
                 continue;
             }
             this.CometList.QueuePendingRemoval(c);
         }
         this.CometList.ApplyPendingRemovals();
         base.ScreenManager.SpriteBatch.End();
         base.ScreenManager.SpriteBatch.Begin();
         int numEntries = 5;
         int k = 5;
         foreach (UIButton b in this.Buttons)
         {
             Rectangle r = b.Rect;
             float transitionOffset = MathHelper.Clamp((base.TransitionPosition - 0.5f * (float)k / (float)numEntries) / 0.5f, 0f, 1f);
             k--;
             if (base.ScreenState != Ship_Game.ScreenState.TransitionOn)
             {
                 r.X = r.X + (int)transitionOffset * 512;
             }
             else
             {
                 r.X = r.X + (int)(transitionOffset * 512f);
                 if (transitionOffset == 0f)
                 {
                     AudioManager.PlayCue("blip_click");
                 }
             }
             b.Draw(base.ScreenManager.SpriteBatch, r);
         }
         if (GlobalStats.ActiveMod != null)
         {
             base.ScreenManager.SpriteBatch.Draw(GlobalStats.ActiveMod.MainMenuTex, this.Portrait, Color.White);
         }
         base.ScreenManager.SpriteBatch.Draw(this.LogoAnimation[0], this.LogoRect, Color.White);
         if (this.LogoAnimation.Count > 1)
         {
             this.LogoAnimation.RemoveAt(0);
         }
         base.ScreenManager.SpriteBatch.End();
         base.ScreenManager.inter.EndFrameRendering();
         base.ScreenManager.editor.EndFrameRendering();
         base.ScreenManager.sceneState.EndFrameRendering();
     }
 }