private void InstallModuleOrig(SlotStruct slot)
        {
            int num = 0;
            for (int index1 = 0; index1 < (int)this.ActiveModule.YSIZE; ++index1)
            {
                for (int index2 = 0; index2 < (int)this.ActiveModule.XSIZE; ++index2)
                {
                    foreach (SlotStruct slotStruct in this.Slots)
                    {
                        if (slotStruct.pq.Y == slot.pq.Y + 16 * index1 && slotStruct.pq.X == slot.pq.X + 16 * index2 && slotStruct.ShowValid)
                        {
                            if (slotStruct.module == null && slotStruct.parent == null)
                            {   //make sure they are actually empty!
                                ++num;
                            }
                        }

                    }
                }
            }
            if (num == (int)this.ActiveModule.XSIZE * (int)this.ActiveModule.YSIZE)
            {
                DesignAction designAction = new DesignAction();
                designAction.clickedSS = new SlotStruct();
                designAction.clickedSS.pq = slot.pq;
                designAction.clickedSS.Restrictions = slot.Restrictions;
                designAction.clickedSS.facing = slot.module != null ? slot.module.facing : 0.0f;
                designAction.clickedSS.ModuleUID = slot.ModuleUID;
                designAction.clickedSS.module = slot.module;
                designAction.clickedSS.tex = slot.tex;
                designAction.clickedSS.slotReference = slot.slotReference;
                designAction.clickedSS.state = slot.state;
                this.DesignStack.Push(designAction);
                this.ClearSlot(slot);
                this.ClearDestinationSlots(slot);
                slot.ModuleUID = this.ActiveModule.UID;
                slot.module = this.ActiveModule;
                slot.module.SetAttributesNoParent();
                slot.state = this.ActiveModState;
                slot.module.facing = this.ActiveModule.facing;
                slot.tex = ResourceManager.TextureDict[ResourceManager.ShipModulesDict[this.ActiveModule.UID].IconTexturePath];
                for (int index1 = 0; index1 < (int)this.ActiveModule.YSIZE; ++index1)
                {
                    for (int index2 = 0; index2 < (int)this.ActiveModule.XSIZE; ++index2)
                    {
                        if (!(index2 == 0 & index1 == 0))
                        {
                            foreach (SlotStruct slotStruct in this.Slots)
                            {
                                if (slotStruct.pq.Y == slot.pq.Y + 16 * index1 && slotStruct.pq.X == slot.pq.X + 16 * index2)
                                {
                                    slot.facing = 0.0f;
                                    slotStruct.facing = 0.0f;
                                    slotStruct.ModuleUID = (string)null;
                                    slotStruct.isDummy = true;
                                    slotStruct.tex = (Texture2D)null;
                                    slotStruct.module = (ShipModule)null;
                                    slotStruct.parent = slot;
                                }
                            }
                        }
                    }
                }
                this.RecalculatePower();
                this.ShipSaved = false;
                if (this.ActiveModule.ModuleType != ShipModuleType.Hangar)
                {
                    this.ActiveModule = Ship_Game.ResourceManager.GetModule(this.ActiveModule.UID);
                }
                this.ChangeModuleState(this.ActiveModState);
            }
            else
                this.PlayNegativeSound();
        }
        public override void HandleInput(InputState input)
        {
            this.CategoryList.HandleInput(input);
            this.CarrierOnlyBox.HandleInput(input);

            if (this.ActiveModule != null && (this.ActiveModule.InstalledWeapon != null && this.ActiveModule.ModuleType != ShipModuleType.Turret || this.ActiveModule.XSIZE != this.ActiveModule.YSIZE))
            {
                if (input.Left)
                    this.ChangeModuleState(ShipDesignScreen.ActiveModuleState.Left);
                if (input.Right)
                    this.ChangeModuleState(ShipDesignScreen.ActiveModuleState.Right);
                if (input.Down)
                    this.ChangeModuleState(ShipDesignScreen.ActiveModuleState.Rear);
                if (input.Up)
                    this.ChangeModuleState(ShipDesignScreen.ActiveModuleState.Normal);
            }
            if (input.CurrentKeyboardState.IsKeyDown(Keys.Y) && !input.LastKeyboardState.IsKeyDown(Keys.Y) && !GlobalStats.TakingInput)
            {
                AudioManager.PlayCue("echo_affirm");
                this.ExitScreen();
            }
            if (this.close.HandleInput(input))
                this.ExitScreen();
            else if (input.CurrentKeyboardState.IsKeyDown(Keys.Z) && input.LastKeyboardState.IsKeyUp(Keys.Z) && input.CurrentKeyboardState.IsKeyDown(Keys.LeftControl))
            {
                if (this.DesignStack.Count <= 0)
                    return;
                ShipModule shipModule = this.ActiveModule;
                DesignAction designAction = this.DesignStack.Pop();
                SlotStruct slot1 = new SlotStruct();
                foreach (SlotStruct slot2 in this.Slots)
                {
                    if (slot2.pq == designAction.clickedSS.pq)
                    {
                        this.ClearSlotNoStack(slot2);
                        slot1 = slot2;
                        slot1.facing = designAction.clickedSS.facing;
                    }
                    foreach (SlotStruct slotStruct in designAction.AlteredSlots)
                    {
                        if (slot2.pq == slotStruct.pq)
                        {
                            this.ClearSlotNoStack(slot2);
                            break;
                        }
                    }
                }
                if (designAction.clickedSS.ModuleUID != null)
                {
                    this.ActiveModule = ResourceManager.GetModule(designAction.clickedSS.ModuleUID);
                    this.ResetModuleState();
                    this.InstallModuleNoStack(slot1);
                }
                foreach (SlotStruct slotStruct in designAction.AlteredSlots)
                {
                    foreach (SlotStruct slot2 in this.Slots)
                    {
                        if (slot2.pq == slotStruct.pq && slotStruct.ModuleUID != null)
                        {
                            this.ActiveModule = ResourceManager.GetModule(slotStruct.ModuleUID);
                            this.ResetModuleState();
                            this.InstallModuleNoStack(slot2);
                            slot2.facing = slotStruct.facing;
                            slot2.ModuleUID = slotStruct.ModuleUID;
                        }
                    }
                }
                this.ActiveModule = shipModule;
                this.ResetModuleState();
            }
            else
            {
                if (!HelperFunctions.CheckIntersection(this.ModuleSelectionMenu.Menu, input.CursorPosition) && !HelperFunctions.CheckIntersection(this.HullSelectionRect, input.CursorPosition) && !HelperFunctions.CheckIntersection(this.ChooseFighterSub.Menu, input.CursorPosition))
                {
                    if (input.ScrollOut)
                    {
                        this.TransitionZoom -= 0.1f;
                        if ((double)this.TransitionZoom < 0.300000011920929)
                            this.TransitionZoom = 0.3f;
                        if ((double)this.TransitionZoom > 2.65000009536743)
                            this.TransitionZoom = 2.65f;
                    }
                    if (input.ScrollIn)
                    {
                        this.TransitionZoom += 0.1f;
                        if ((double)this.TransitionZoom < 0.300000011920929)
                            this.TransitionZoom = 0.3f;
                        if ((double)this.TransitionZoom > 2.65000009536743)
                            this.TransitionZoom = 2.65f;
                    }
                }
                if (input.CurrentKeyboardState.IsKeyDown(Keys.OemTilde))
                    input.LastKeyboardState.IsKeyUp(Keys.OemTilde);
                if (this.Debug)
                {
                    if (input.CurrentKeyboardState.IsKeyDown(Keys.Enter) && input.LastKeyboardState.IsKeyUp(Keys.Enter))
                    {
                        foreach (ModuleSlotData moduleSlotData in this.ActiveHull.ModuleSlotList)
                            moduleSlotData.InstalledModuleUID = (string)null;
                        new XmlSerializer(typeof(ShipData)).Serialize((TextWriter)new StreamWriter("Content/Hulls/" + this.ActiveHull.ShipStyle + "/" + this.ActiveHull.Name + ".xml"), (object)this.ActiveHull);
                    }
                    if (input.Right)
                        ++this.operation;
                    if (this.operation > (ShipDesignScreen.SlotModOperation)6)
                        this.operation = ShipDesignScreen.SlotModOperation.Delete;
                }
                this.HoveredModule = (ShipModule)null;
                this.mouseStateCurrent = Mouse.GetState();
                Vector2 vector2 = new Vector2((float)this.mouseStateCurrent.X, (float)this.mouseStateCurrent.Y);
                this.selector = (Selector)null;
                this.EmpireUI.HandleInput(input, (GameScreen)this);
                this.activeModSubMenu.HandleInputNoReset((object)this);
                this.hullSL.HandleInput(input);
                for (int index = this.hullSL.indexAtTop; index < this.hullSL.Copied.Count && index < this.hullSL.indexAtTop + this.hullSL.entriesToDisplay; ++index)
                {
                    ScrollList.Entry e = this.hullSL.Copied[index];
                    if (e.item is ModuleHeader)
                    {
                        if ((e.item as ModuleHeader).HandleInput(input, e))
                            return;
                    }
                    else if (HelperFunctions.CheckIntersection(e.clickRect, vector2))
                    {
                        this.selector = new Selector(this.ScreenManager, e.clickRect);
                        e.clickRectHover = 1;
                        this.selector = new Selector(this.ScreenManager, e.clickRect);
                        if (input.InGameSelect)
                        {
                            AudioManager.PlayCue("sd_ui_accept_alt3");
                            if (!this.ShipSaved && !this.CheckDesign())
                            {
                                MessageBoxScreen messageBoxScreen = new MessageBoxScreen(Localizer.Token(2121), "Save", "No");
                                messageBoxScreen.Accepted += new EventHandler<EventArgs>(this.SaveWIPThenChangeHull);
                                messageBoxScreen.Cancelled += new EventHandler<EventArgs>(this.JustChangeHull);
                                this.changeto = e.item as ShipData;
                                this.ScreenManager.AddScreen((GameScreen)messageBoxScreen);
                                return;
                            }
                            else
                            {
                                this.ChangeHull(e.item as ShipData);
                                return;
                            }
                        }
                    }
                    else
                        e.clickRectHover = 0;
                }
                this.modSel.HandleInput((object)this);
                if (this.ActiveModule != null)
                {
                    if (this.ActiveModule.ModuleType == ShipModuleType.Hangar && !this.ActiveModule.IsTroopBay && !this.ActiveModule.IsSupplyBay)
                    {
                        this.UpdateHangarOptions(this.ActiveModule);
                        this.ChooseFighterSL.HandleInput(input);
                        for (int index = this.ChooseFighterSL.indexAtTop; index < this.ChooseFighterSL.Copied.Count && index < this.ChooseFighterSL.indexAtTop + this.ChooseFighterSL.entriesToDisplay; ++index)
                        {
                            ScrollList.Entry entry = this.ChooseFighterSL.Copied[index];
                            if (HelperFunctions.CheckIntersection(entry.clickRect, vector2))
                            {
                                this.selector = new Selector(this.ScreenManager, entry.clickRect);
                                entry.clickRectHover = 1;
                                this.selector = new Selector(this.ScreenManager, entry.clickRect);
                                if (input.InGameSelect)
                                {
                                    this.ActiveModule.hangarShipUID = (entry.item as Ship).Name;
                                    this.HangarShipUIDLast = (entry.item as Ship).Name;
                                    AudioManager.PlayCue("sd_ui_accept_alt3");
                                    return;
                                }
                            }
                        }
                    }
                }
                else if (this.HighlightedModule != null && this.HighlightedModule.ModuleType == ShipModuleType.Hangar && (!this.HighlightedModule.IsTroopBay && !this.HighlightedModule.IsSupplyBay))
                {
                    this.ChooseFighterSL.HandleInput(input);
                    for (int index = this.ChooseFighterSL.indexAtTop; index < this.ChooseFighterSL.Copied.Count && index < this.ChooseFighterSL.indexAtTop + this.ChooseFighterSL.entriesToDisplay; ++index)
                    {
                        ScrollList.Entry entry = this.ChooseFighterSL.Copied[index];
                        if (HelperFunctions.CheckIntersection(entry.clickRect, vector2))
                        {
                            this.selector = new Selector(this.ScreenManager, entry.clickRect);
                            entry.clickRectHover = 1;
                            this.selector = new Selector(this.ScreenManager, entry.clickRect);
                            if (input.InGameSelect)
                            {
                                this.HighlightedModule.hangarShipUID = (entry.item as Ship).Name;
                                this.HangarShipUIDLast = (entry.item as Ship).Name;
                                AudioManager.PlayCue("sd_ui_accept_alt3");
                                return;
                            }
                        }
                    }
                }
                for (int index = this.weaponSL.indexAtTop; index < this.weaponSL.Copied.Count && index < this.weaponSL.indexAtTop + this.weaponSL.entriesToDisplay; ++index)
                {
                    ScrollList.Entry e = this.weaponSL.Copied[index];
                    if (e.item is ModuleHeader)
                    {
                        if ((e.item as ModuleHeader).HandleInput(input, e))
                            return;
                    }
                    else if (HelperFunctions.CheckIntersection(e.clickRect, vector2))
                    {
                        this.selector = new Selector(this.ScreenManager, e.clickRect);
                        e.clickRectHover = 1;
                        this.selector = new Selector(this.ScreenManager, e.clickRect);
                        if (input.InGameSelect)
                        {
                            this.SetActiveModule(ResourceManager.GetModule((e.item as ShipModule).UID));
                            this.ResetModuleState();
                            return;
                        }
                    }
                    else
                        e.clickRectHover = 0;
                }
                this.weaponSL.HandleInput(input);
                if (HelperFunctions.CheckIntersection(this.HullSelectionRect, input.CursorPosition) && input.CurrentMouseState.LeftButton == ButtonState.Pressed || HelperFunctions.CheckIntersection(this.modSel.Menu, input.CursorPosition) && input.CurrentMouseState.LeftButton == ButtonState.Pressed || HelperFunctions.CheckIntersection(this.activeModSubMenu.Menu, input.CursorPosition) && input.CurrentMouseState.LeftButton == ButtonState.Pressed)
                    return;
                if (HelperFunctions.CheckIntersection(this.modSel.Menu, vector2))
                {
                    if (this.mouseStateCurrent.ScrollWheelValue > this.mouseStatePrevious.ScrollWheelValue && this.weaponSL.indexAtTop > 0)
                        --this.weaponSL.indexAtTop;
                    if (this.mouseStateCurrent.ScrollWheelValue < this.mouseStatePrevious.ScrollWheelValue && this.weaponSL.indexAtTop + this.weaponSL.entriesToDisplay < this.weaponSL.Entries.Count)
                        ++this.weaponSL.indexAtTop;
                }
                if (HelperFunctions.CheckIntersection(this.ArcsButton.R, input.CursorPosition))
                    ToolTip.CreateTooltip(134, this.ScreenManager);
                if (this.ArcsButton.HandleInput(input))
                {
                    this.ArcsButton.ToggleOn = !this.ArcsButton.ToggleOn;
                    this.ShowAllArcs = this.ArcsButton.ToggleOn;
                }
                if (input.Tab)
                {
                    this.ShowAllArcs = !this.ShowAllArcs;
                    this.ArcsButton.ToggleOn = this.ShowAllArcs;
                }
                if (input.CurrentMouseState.RightButton == ButtonState.Pressed && input.LastMouseState.RightButton == ButtonState.Released)
                {
                    this.StartDragPos = input.CursorPosition;
                    this.cameraVelocity.X = 0.0f;
                    this.cameraVelocity.Y = 0.0f;
                }
                if (input.CurrentMouseState.RightButton == ButtonState.Pressed && input.LastMouseState.RightButton == ButtonState.Pressed)
                {
                    float num1 = input.CursorPosition.X - this.StartDragPos.X;
                    float num2 = input.CursorPosition.Y - this.StartDragPos.Y;
                    this.camera._pos += new Vector2(-num1, -num2);
                    this.StartDragPos = input.CursorPosition;
                    this.cameraPosition.X += -num1;
                    this.cameraPosition.Y += -num2;
                }
                else
                {
                    this.cameraVelocity.X = 0.0f;
                    this.cameraVelocity.Y = 0.0f;
                }
                this.cameraVelocity.X = MathHelper.Clamp(this.cameraVelocity.X, -10f, 10f);
                this.cameraVelocity.Y = MathHelper.Clamp(this.cameraVelocity.Y, -10f, 10f);
                if (input.Escaped)
                    this.ExitScreen();
                if (this.ToggleOverlay)
                {
                    foreach (SlotStruct slotStruct in this.Slots)
                    {
                        Vector2 spaceFromWorldSpace = this.camera.GetScreenSpaceFromWorldSpace(new Vector2((float)slotStruct.pq.enclosingRect.X, (float)slotStruct.pq.enclosingRect.Y));
                        if (HelperFunctions.CheckIntersection(new Rectangle((int)spaceFromWorldSpace.X, (int)spaceFromWorldSpace.Y, (int)(16.0 * (double)this.camera.Zoom), (int)(16.0 * (double)this.camera.Zoom)), vector2))
                        {
                            if (slotStruct.isDummy && slotStruct.parent.module != null)
                                this.HoveredModule = slotStruct.parent.module;
                            else if (slotStruct.module != null)
                                this.HoveredModule = slotStruct.module;
                            if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released)
                            {
                                AudioManager.GetCue("simple_beep").Play();
                                if (this.Debug)
                                {
                                    this.DebugAlterSlot(slotStruct.slotReference.Position, this.operation);
                                    return;
                                }
                                else if (slotStruct.isDummy && slotStruct.parent.module != null)
                                    this.HighlightedModule = slotStruct.parent.module;
                                else if (slotStruct.module != null)
                                    this.HighlightedModule = slotStruct.module;
                            }
                        }
                    }
                }
                if (HelperFunctions.CheckIntersection(this.upArrow, vector2) && this.mouseStateCurrent.LeftButton == ButtonState.Released && (this.mouseStatePrevious.LeftButton == ButtonState.Pressed && this.scrollPosition > 0))
                {
                    --this.scrollPosition;
                    AudioManager.GetCue("blip_click").Play();
                    foreach (ModuleButton moduleButton in this.ModuleButtons)
                        moduleButton.moduleRect.Y += 128;
                }
                if (HelperFunctions.CheckIntersection(this.downArrow, vector2) && this.mouseStateCurrent.LeftButton == ButtonState.Released && this.mouseStatePrevious.LeftButton == ButtonState.Pressed)
                {
                    ++this.scrollPosition;
                    AudioManager.GetCue("blip_click").Play();
                    foreach (ModuleButton moduleButton in this.ModuleButtons)
                        moduleButton.moduleRect.Y -= 128;
                }
                if (HelperFunctions.CheckIntersection(this.ModuleSelectionArea, vector2))
                {
                    if (input.ScrollIn && this.scrollPosition > 0)
                    {
                        --this.scrollPosition;
                        AudioManager.GetCue("blip_click").Play();
                        foreach (ModuleButton moduleButton in this.ModuleButtons)
                            moduleButton.moduleRect.Y += 128;
                    }
                    if (input.ScrollOut)
                    {
                        ++this.scrollPosition;
                        AudioManager.GetCue("blip_click").Play();
                        foreach (ModuleButton moduleButton in this.ModuleButtons)
                            moduleButton.moduleRect.Y -= 128;
                    }
                }
                if (this.mouseStateCurrent.RightButton == ButtonState.Released && this.mouseStatePrevious.RightButton == ButtonState.Pressed)
                {
                    //this should actually clear slots
                    this.ActiveModule = (ShipModule)null;
                    foreach (SlotStruct parent in this.Slots)
                    {
                        parent.ShowInvalid = false;
                        parent.ShowValid = false;
                        Vector2 spaceFromWorldSpace = this.camera.GetScreenSpaceFromWorldSpace(new Vector2((float)parent.pq.enclosingRect.X, (float)parent.pq.enclosingRect.Y));
                        Rectangle rect = new Rectangle((int)spaceFromWorldSpace.X, (int)spaceFromWorldSpace.Y, (int)(16.0 * (double)this.camera.Zoom), (int)(16.0 * (double)this.camera.Zoom));
                        if ((parent.module != null || parent.isDummy) && HelperFunctions.CheckIntersection(rect, vector2)) //if clicked at this slot
                        {
                            DesignAction designAction = new DesignAction();
                            designAction.clickedSS = new SlotStruct();
                            designAction.clickedSS.pq = parent.isDummy ? parent.parent.pq : parent.pq;
                            designAction.clickedSS.Restrictions = parent.Restrictions;
                            designAction.clickedSS.facing = parent.module != null ? parent.module.facing : 0.0f;
                            designAction.clickedSS.ModuleUID = parent.isDummy ? parent.parent.ModuleUID : parent.ModuleUID;
                            designAction.clickedSS.module = parent.module;
                            designAction.clickedSS.slotReference = parent.isDummy ? parent.parent.slotReference : parent.slotReference;
                            this.DesignStack.Push(designAction);
                            AudioManager.GetCue("sub_bass_whoosh").Play();
                            if (parent.isDummy)
                                this.ClearParentSlot(parent.parent);
                            else
                                this.ClearParentSlot(parent);
                            this.RecalculatePower();
                        }
                    }
                }
                foreach (ModuleButton moduleButton in this.ModuleButtons)
                {
                    if (HelperFunctions.CheckIntersection(this.ModuleSelectionArea, new Vector2((float)(moduleButton.moduleRect.X + 30), (float)(moduleButton.moduleRect.Y + 30))))
                    {
                        if (HelperFunctions.CheckIntersection(moduleButton.moduleRect, vector2))
                        {
                            if (input.InGameSelect)
                                this.SetActiveModule(ResourceManager.GetModule(moduleButton.ModuleUID));
                            moduleButton.isHighlighted = true;
                        }
                        else
                            moduleButton.isHighlighted = false;
                    }
                }
                if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && this.ActiveModule != null)
                {
                    foreach (SlotStruct slot in this.Slots)
                    {
                        Vector2 spaceFromWorldSpace = this.camera.GetScreenSpaceFromWorldSpace(new Vector2((float)slot.pq.enclosingRect.X, (float)slot.pq.enclosingRect.Y));
                        if (HelperFunctions.CheckIntersection(new Rectangle((int)spaceFromWorldSpace.X, (int)spaceFromWorldSpace.Y, (int)(16.0 * (double)this.camera.Zoom), (int)(16.0 * (double)this.camera.Zoom)), vector2))
                        {
                            AudioManager.GetCue("sub_bass_mouseover").Play();
                            this.InstallModule(slot);
                        }
                    }
                }
                else if (this.mouseStateCurrent.LeftButton == ButtonState.Pressed && this.mouseStatePrevious.LeftButton == ButtonState.Pressed)
                    this.HoldTimer -= .01666f;
                else
                    this.HoldTimer = 0.50f;

                foreach (SlotStruct slotStruct in this.Slots)
                {
                    if (slotStruct.ModuleUID != null && this.HighlightedModule != null && (slotStruct.module == this.HighlightedModule && (double)slotStruct.module.FieldOfFire != 0.0) && slotStruct.module.ModuleType == ShipModuleType.Turret)
                    {
                        float num1 = slotStruct.module.FieldOfFire / 2f;
                        Vector2 spaceFromWorldSpace = this.camera.GetScreenSpaceFromWorldSpace(new Vector2((float)(slotStruct.pq.enclosingRect.X + 16 * (int)slotStruct.module.XSIZE / 2), (float)(slotStruct.pq.enclosingRect.Y + 16 * (int)slotStruct.module.YSIZE / 2)));
                        float num2 = Math.Abs(this.findAngleToTarget(spaceFromWorldSpace, vector2));
                        float num3 = this.HighlightedModule.facing;
                        float num4 = Math.Abs(num2 - num3);
                        if ((double)num4 > (double)num1)
                        {
                            if ((double)num2 > 180.0)
                                num2 = (float)(-1.0 * (360.0 - (double)num2));
                            if ((double)num3 > 180.0)
                                num3 = (float)(-1.0 * (360.0 - (double)num3));
                            num4 = Math.Abs(num2 - num3);
                        }

                        if (GlobalStats.AltArcControl)
                        {
                            //The Doctor: ALT (either) + LEFT CLICK to pick and move arcs. This way, it's impossible to accidentally pick the wrong arc, while it's just as responsive and smooth as the original method when you are trying to.
                            if ((double)num4 < (double)num1 && (this.mouseStateCurrent.LeftButton == ButtonState.Pressed && this.mouseStatePrevious.LeftButton == ButtonState.Pressed && ((input.CurrentKeyboardState.IsKeyDown(Keys.LeftAlt) || input.LastKeyboardState.IsKeyDown(Keys.LeftAlt)) || (input.CurrentKeyboardState.IsKeyDown(Keys.RightAlt) || input.LastKeyboardState.IsKeyDown(Keys.RightAlt)))))
                            {

                                this.HighlightedModule.facing = Math.Abs(this.findAngleToTarget(spaceFromWorldSpace, vector2));
                            }
                        }
                        else
                        {
                            //Delay method
                            if ((double)num4 < (double)num1 && (this.mouseStateCurrent.LeftButton == ButtonState.Pressed && this.mouseStatePrevious.LeftButton == ButtonState.Pressed && this.HoldTimer < 0))
                            {
                                this.HighlightedModule.facing = Math.Abs(this.findAngleToTarget(spaceFromWorldSpace, vector2));
                            }

                        }

                    }
                }
                foreach (UIButton uiButton in this.Buttons)
                {
                    if (HelperFunctions.CheckIntersection(uiButton.Rect, vector2))
                    {
                        uiButton.State = UIButton.PressState.Hover;
                        if (this.mouseStateCurrent.LeftButton == ButtonState.Pressed && this.mouseStatePrevious.LeftButton == ButtonState.Pressed)
                            uiButton.State = UIButton.PressState.Pressed;
                        if (this.mouseStateCurrent.LeftButton == ButtonState.Released && this.mouseStatePrevious.LeftButton == ButtonState.Pressed)
                        {
                            switch (uiButton.Launches)
                            {
                                case "Toggle Overlay":
                                    AudioManager.PlayCue("blip_click");
                                    this.ToggleOverlay = !this.ToggleOverlay;
                                    continue;
                                case "Save As...":
                                    if (this.CheckDesign())
                                    {
                                        this.ScreenManager.AddScreen((GameScreen)new DesignManager(this, this.ActiveHull.Name));
                                        continue;
                                    }
                                    else
                                    {
                                        AudioManager.PlayCue("UI_Misc20");
                                        this.ScreenManager.AddScreen((GameScreen)new MessageBoxScreen(Localizer.Token(2049)));
                                        continue;
                                    }
                                case "Load":
                                    this.ScreenManager.AddScreen((GameScreen)new LoadDesigns(this));
                                    continue;
                                default:
                                    continue;
                            }
                        }
                    }
                    else
                        uiButton.State = UIButton.PressState.Normal;
                }
                if (this.ActiveHull != null)
                {
                    foreach (ToggleButton toggleButton in this.CombatStatusButtons)
                    {
                        if (HelperFunctions.CheckIntersection(toggleButton.r, input.CursorPosition))
                        {
                            if (toggleButton.HasToolTip)
                                ToolTip.CreateTooltip(toggleButton.WhichToolTip, this.ScreenManager);
                            if (input.InGameSelect)
                            {
                                AudioManager.PlayCue("sd_ui_accept_alt3");
                                switch (toggleButton.Action)
                                {
                                    case "attack":
                                        this.CombatState = CombatState.AttackRuns;
                                        break;
                                    case "arty":
                                        this.CombatState = CombatState.Artillery;
                                        break;
                                    case "hold":
                                        this.CombatState = CombatState.HoldPosition;
                                        break;
                                    case "orbit_left":
                                        this.CombatState = CombatState.OrbitLeft;
                                        break;
                                    case "broadside_left":
                                        this.CombatState = CombatState.BroadsideLeft;
                                        break;
                                    case "orbit_right":
                                        this.CombatState = CombatState.OrbitRight;
                                        break;
                                    case "broadside_right":
                                        this.CombatState = CombatState.BroadsideRight;
                                        break;
                                    case "evade":
                                        this.CombatState = CombatState.Evade;
                                        break;
                                }
                            }
                        }
                        else
                            toggleButton.Hover = false;
                        switch (toggleButton.Action)
                        {
                            case "attack":
                                toggleButton.Active = this.CombatState == CombatState.AttackRuns;
                                continue;
                            case "arty":
                                toggleButton.Active = this.CombatState == CombatState.Artillery;
                                continue;
                            case "hold":
                                toggleButton.Active = this.CombatState == CombatState.HoldPosition;
                                continue;
                            case "orbit_left":
                                toggleButton.Active = this.CombatState == CombatState.OrbitLeft;
                                continue;
                            case "broadside_left":
                                toggleButton.Active = this.CombatState == CombatState.BroadsideLeft;
                                continue;
                            case "orbit_right":
                                toggleButton.Active = this.CombatState == CombatState.OrbitRight;
                                continue;
                            case "broadside_right":
                                toggleButton.Active = this.CombatState == CombatState.BroadsideRight;
                                continue;
                            case "evade":
                                toggleButton.Active = this.CombatState == CombatState.Evade;
                                continue;
                            default:
                                continue;
                        }
                    }
                }
                this.mouseStatePrevious = this.mouseStateCurrent;
                base.HandleInput(input);
            }
        }