protected void HandleSelectionBox(InputState input) { if (this.LookingAtPlanet) return; if (this.SelectedShip != null) { //if (input.CurrentKeyboardState.IsKeyDown(Keys.R) && !input.LastKeyboardState.IsKeyDown(Keys.R)) //fbedard: what is that !!!! // this.SelectedShip.FightersOut = !this.SelectedShip.FightersOut; if (input.CurrentKeyboardState.IsKeyDown(Keys.Q) && !input.LastKeyboardState.IsKeyDown(Keys.Q)) { if (!this.pieMenu.Visible) { if (this.SelectedShip != null) this.LoadShipMenuNodes(this.SelectedShip.loyalty == this.player ? 1 : 0); this.pieMenu.RootNode = this.shipMenu; this.pieMenu.Show(this.pieMenu.Position); } else this.pieMenu.ChangeTo((PieMenuNode)null); } } Vector2 vector2 = input.CursorPosition - this.pieMenu.Position; vector2.Y *= -1f; Vector2 selectionVector = vector2 / this.pieMenu.Radius; this.pieMenu.HandleInput(input, selectionVector); if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released && !this.pieMenu.Visible) { this.SelectedShip = (Ship)null; this.SelectedPlanet = (Planet)null; this.SelectedFleet = (Fleet)null; this.SelectedFlank = (List<Fleet.Squad>)null; this.SelectedSystem = (SolarSystem)null; this.SelectedItem = (UniverseScreen.ClickableItemUnderConstruction)null; this.ProjectingPosition = false; this.projectedGroup = (ShipGroup)null; bool flag1 = false; if (this.viewState >= UniverseScreen.UnivScreenState.SectorView) { lock (GlobalStats.ClickableSystemsLock) { for (int local_2 = 0; local_2 < this.ClickableSystems.Count; ++local_2) { UniverseScreen.ClickableSystem local_3 = this.ClickableSystems[local_2]; if ((double)Vector2.Distance(input.CursorPosition, local_3.ScreenPos) <= (double)local_3.Radius) { AudioManager.PlayCue("mouse_over4"); this.SelectedSystem = local_3.systemToClick; this.sInfoUI.SetSystem(this.SelectedSystem); flag1 = true; } } } } bool flag2 = false; if (!flag1) { foreach (UniverseScreen.ClickableFleet clickableFleet in this.ClickableFleetsList) { if ((double)Vector2.Distance(input.CursorPosition, clickableFleet.ScreenPos) <= (double)clickableFleet.ClickRadius) { this.SelectedShipList.Clear(); this.SelectedFleet = clickableFleet.fleet; flag2 = true; this.pickedSomethingThisFrame = true; AudioManager.PlayCue("techy_affirm1"); using (List<Ship>.Enumerator enumerator = this.SelectedFleet.Ships.GetEnumerator()) { while (enumerator.MoveNext()) this.SelectedShipList.Add(enumerator.Current); break; } } } if (!flag2) { foreach (UniverseScreen.ClickableShip clickableShip in this.ClickableShipsList) { if ((double)Vector2.Distance(input.CursorPosition, clickableShip.ScreenPos) <= (double)clickableShip.Radius) { if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftControl) && this.SelectedShipList.Count > 1 && this.SelectedShipList.Contains(clickableShip.shipToClick)) { this.SelectedShipList.Remove(clickableShip.shipToClick); this.pickedSomethingThisFrame = true; AudioManager.GetCue("techy_affirm1").Play(); break; } else { if (this.SelectedShipList.Count > 0 && !input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift) && !this.pickedSomethingThisFrame) this.SelectedShipList.Clear(); this.pickedSomethingThisFrame = true; AudioManager.GetCue("techy_affirm1").Play(); this.SelectedShip = clickableShip.shipToClick; this.SelectedSomethingTimer = 3f; if (!this.SelectedShipList.Contains(clickableShip.shipToClick)) { if (clickableShip.shipToClick != null) { if (clickableShip.shipToClick.inSensorRange) { this.SelectedShipList.Add(clickableShip.shipToClick); break; } else break; } else break; } else break; } } } if (this.SelectedShip != null && this.SelectedShipList.Count == 1) this.ShipInfoUIElement.SetShip(this.SelectedShip); else if (this.SelectedShipList.Count > 1) this.shipListInfoUI.SetShipList((List<Ship>)this.SelectedShipList, false); bool flag3 = false; if (this.SelectedShipList.Count == 1) { if (this.SelectedShipList[0] == this.playerShip) this.LoadShipMenuNodes(1); else if (this.SelectedShipList[0].loyalty == this.player) this.LoadShipMenuNodes(1); else this.LoadShipMenuNodes(0); } else { lock (GlobalStats.ClickableSystemsLock) { foreach (UniverseScreen.ClickablePlanets item_2 in this.ClickPlanetList) { if ((double)Vector2.Distance(input.CursorPosition, item_2.ScreenPos) <= (double)item_2.Radius) { if ((double)this.ClickTimer2 < (double)this.TimerDelay) { this.SelectedPlanet = item_2.planetToClick; this.pInfoUI.SetPlanet(this.SelectedPlanet); this.SelectedSomethingTimer = 3f; flag3 = true; this.ViewPlanet((object)null); this.SelectionBox = new Rectangle(); } else { AudioManager.GetCue("techy_affirm1").Play(); this.SelectedPlanet = item_2.planetToClick; this.pInfoUI.SetPlanet(this.SelectedPlanet); this.SelectedSomethingTimer = 3f; flag3 = true; this.ClickTimer2 = 0.0f; } } } } } if (!flag3) { lock (GlobalStats.ClickableItemLocker) { for (int local_17 = 0; local_17 < this.ItemsToBuild.Count; ++local_17) { UniverseScreen.ClickableItemUnderConstruction local_18 = this.ItemsToBuild[local_17]; if (local_18 != null && (double)Vector2.Distance(input.CursorPosition, local_18.ScreenPos) <= (double)local_18.Radius) { AudioManager.GetCue("techy_affirm1").Play(); this.SelectedItem = local_18; } } } } } } } if (this.SelectedShip == null && this.SelectedShipList.Count == 0 && (this.SelectedPlanet != null && input.CurrentKeyboardState.IsKeyDown(Keys.Q)) && !input.LastKeyboardState.IsKeyDown(Keys.Q)) { if (!this.pieMenu.Visible) { this.pieMenu.RootNode = this.planetMenu; if (this.SelectedPlanet.Owner == null && this.SelectedPlanet.habitable) this.LoadMenuNodes(false, true); else this.LoadMenuNodes(false, false); this.pieMenu.Show(this.pieMenu.Position); } else this.pieMenu.ChangeTo((PieMenuNode)null); } if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released) this.SelectionBox = new Rectangle(input.CurrentMouseState.X, input.CurrentMouseState.Y, 0, 0); if (this.SelectedShipList.Count == 1) this.SelectedShip = this.SelectedShipList[0]; if (input.CurrentMouseState.LeftButton == ButtonState.Pressed) { this.SelectingWithBox = true; if (this.SelectionBox.X == 0 || this.SelectionBox.Y == 0) return; this.SelectionBox = new Rectangle(this.SelectionBox.X, this.SelectionBox.Y, input.CurrentMouseState.X - this.SelectionBox.X, input.CurrentMouseState.Y - this.SelectionBox.Y); } else if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift) && input.CurrentMouseState.LeftButton == ButtonState.Released && input.LastMouseState.LeftButton == ButtonState.Pressed) { if (input.CurrentMouseState.X < this.SelectionBox.X) this.SelectionBox.X = input.CurrentMouseState.X; if (input.CurrentMouseState.Y < this.SelectionBox.Y) this.SelectionBox.Y = input.CurrentMouseState.Y; this.SelectionBox.Width = Math.Abs(this.SelectionBox.Width); this.SelectionBox.Height = Math.Abs(this.SelectionBox.Height); bool flag1 = true; List<Ship> list = new List<Ship>(); foreach (UniverseScreen.ClickableShip clickableShip in this.ClickableShipsList) { if (this.SelectionBox.Contains(new Point((int)clickableShip.ScreenPos.X, (int)clickableShip.ScreenPos.Y)) && !this.SelectedShipList.Contains(clickableShip.shipToClick)) { this.SelectedPlanet = (Planet)null; this.SelectedShipList.Add(clickableShip.shipToClick); this.SelectedSomethingTimer = 3f; list.Add(clickableShip.shipToClick); } } if (this.SelectedShipList.Count > 0 && flag1) { bool flag2 = false; bool flag3 = false; foreach (Ship ship in list) { if (ship.Role == "station" || ship.Role == "construction" || (ship.Role == "platform" || ship.Role == "supply")) flag2 = true; else flag3 = true; } if (flag3 && flag2) { foreach (Ship ship in (List<Ship>)this.SelectedShipList) { if (ship.Role == "station" || ship.Role == "construction" || (ship.Role == "platform" || ship.Role == "supply")) this.SelectedShipList.QueuePendingRemoval(ship); } } this.SelectedShipList.ApplyPendingRemovals(); } if (this.SelectedShipList.Count > 1) { bool flag2 = false; bool flag3 = false; foreach (Ship ship in (List<Ship>)this.SelectedShipList) { if (ship.loyalty == this.player) flag2 = true; if (ship.loyalty != this.player) flag3 = true; } if (flag2 && flag3) { foreach (Ship ship in (List<Ship>)this.SelectedShipList) { if (ship.loyalty != this.player) this.SelectedShipList.QueuePendingRemoval(ship); } this.SelectedShipList.ApplyPendingRemovals(); } this.SelectedShip = (Ship)null; this.shipListInfoUI.SetShipList((List<Ship>)this.SelectedShipList, true); } else if (this.SelectedShipList.Count == 1) { this.SelectedShip = this.SelectedShipList[0]; this.ShipInfoUIElement.SetShip(this.SelectedShip); } this.SelectionBox = new Rectangle(0, 0, -1, -1); } else { if (input.CurrentMouseState.LeftButton != ButtonState.Released || input.LastMouseState.LeftButton != ButtonState.Pressed) return; this.SelectingWithBox = false; if (input.CurrentMouseState.X < this.SelectionBox.X) this.SelectionBox.X = input.CurrentMouseState.X; if (input.CurrentMouseState.Y < this.SelectionBox.Y) this.SelectionBox.Y = input.CurrentMouseState.Y; this.SelectionBox.Width = Math.Abs(this.SelectionBox.Width); this.SelectionBox.Height = Math.Abs(this.SelectionBox.Height); bool flag1 = false; if (this.SelectedShipList.Count == 0) flag1 = true; foreach (UniverseScreen.ClickableShip clickableShip in this.ClickableShipsList) { if (this.SelectionBox.Contains(new Point((int)clickableShip.ScreenPos.X, (int)clickableShip.ScreenPos.Y))) { this.SelectedPlanet = (Planet)null; this.SelectedShipList.Add(clickableShip.shipToClick); this.SelectedSomethingTimer = 3f; } } if (this.SelectedShipList.Count > 0 && flag1) { bool flag2 = false; bool flag3 = false; try { foreach (Ship ship in (List<Ship>)this.SelectedShipList) { if (ship.Role == "station" || ship.Role == "construction" || (ship.Role == "platform" || ship.Role == "supply") || (ship.Role == "freighter" || ship.Role == "colony")) flag2 = true; else flag3 = true; } } catch { } if (flag3) { if (flag2) { try { foreach (Ship ship in (List<Ship>)this.SelectedShipList) { if (ship.Role == "station" || ship.Role == "construction" || (ship.Role == "platform" || ship.Role == "supply") || (ship.Role == "freighter" || ship.Role == "colony")) this.SelectedShipList.QueuePendingRemoval(ship); } } catch { } } } this.SelectedShipList.ApplyPendingRemovals(); } if (this.SelectedShipList.Count > 1) { bool flag2 = false; bool flag3 = false; foreach (Ship ship in (List<Ship>)this.SelectedShipList) { if (ship.loyalty == this.player) flag2 = true; if (ship.loyalty != this.player) flag3 = true; } if (flag2 && flag3) { foreach (Ship ship in (List<Ship>)this.SelectedShipList) { if (ship.loyalty != this.player) this.SelectedShipList.QueuePendingRemoval(ship); } this.SelectedShipList.ApplyPendingRemovals(); } this.SelectedShip = (Ship)null; bool flag4 = true; if (this.SelectedShipList.Count > 0) { if (this.SelectedShipList[0].fleet != null) { if (this.SelectedShipList.Count == this.SelectedShipList[0].fleet.Ships.Count) { try { foreach (Ship ship in (List<Ship>)this.SelectedShipList) { if (ship.fleet == null || ship.fleet != this.SelectedShipList[0].fleet) flag4 = false; } if (flag4) this.SelectedFleet = this.SelectedShipList[0].fleet; } catch { } } } if (this.SelectedFleet != null) this.shipListInfoUI.SetShipList((List<Ship>)this.SelectedShipList, true); else this.shipListInfoUI.SetShipList((List<Ship>)this.SelectedShipList, false); } if (this.SelectedFleet == null) this.ShipInfoUIElement.SetShip(this.SelectedShipList[0]); } else if (this.SelectedShipList.Count == 1) { this.SelectedShip = this.SelectedShipList[0]; this.ShipInfoUIElement.SetShip(this.SelectedShip); if (this.SelectedShipList[0] == this.playerShip) this.LoadShipMenuNodes(1); else if (this.SelectedShipList[0].loyalty == this.player) this.LoadShipMenuNodes(1); else this.LoadShipMenuNodes(0); } this.SelectionBox = new Rectangle(0, 0, -1, -1); } }
protected void HandleRightMouseNew(InputState input) { if (this.SkipRightOnce) { if (input.CurrentMouseState.RightButton != ButtonState.Released || input.LastMouseState.RightButton != ButtonState.Released) return; this.SkipRightOnce = false; } else { Viewport viewport; if (input.CurrentMouseState.RightButton == ButtonState.Pressed && input.LastMouseState.RightButton == ButtonState.Released) { this.SelectedSomethingTimer = 3f; this.startDrag = new Vector2((float)input.CurrentMouseState.X, (float)input.CurrentMouseState.Y); this.startDragWorld = this.GetWorldSpaceFromScreenSpace(this.startDrag); this.ProjectedPosition = this.GetWorldSpaceFromScreenSpace(this.startDrag); Vector3 position = this.ScreenManager.GraphicsDevice.Viewport.Unproject(new Vector3((float)input.CurrentMouseState.X, (float)input.CurrentMouseState.Y, 0.0f), this.projection, this.view, Matrix.Identity); viewport = this.ScreenManager.GraphicsDevice.Viewport; Vector3 direction = viewport.Unproject(new Vector3((float)input.CurrentMouseState.X, (float)input.CurrentMouseState.Y, 1f), this.projection, this.view, Matrix.Identity) - position; direction.Normalize(); Ray ray = new Ray(position, direction); float num = -ray.Position.Z / ray.Direction.Z; Vector3 vector3 = new Vector3(ray.Position.X + num * ray.Direction.X, ray.Position.Y + num * ray.Direction.Y, 0.0f); } if (this.SelectedShip != null && this.SelectedShip.GetAI().State == AIState.ManualControl && (double)Vector2.Distance(this.startDragWorld, this.SelectedShip.Center) < 5000.0) return; if (input.CurrentMouseState.RightButton == ButtonState.Released && input.LastMouseState.RightButton == ButtonState.Pressed) { viewport = this.ScreenManager.GraphicsDevice.Viewport; Vector3 position = viewport.Unproject(new Vector3((float)input.CurrentMouseState.X, (float)input.CurrentMouseState.Y, 0.0f), this.projection, this.view, Matrix.Identity); viewport = this.ScreenManager.GraphicsDevice.Viewport; Vector3 direction = viewport.Unproject(new Vector3((float)input.CurrentMouseState.X, (float)input.CurrentMouseState.Y, 1f), this.projection, this.view, Matrix.Identity) - position; direction.Normalize(); Ray ray = new Ray(position, direction); float num1 = -ray.Position.Z / ray.Direction.Z; Vector3 vector3 = new Vector3(ray.Position.X + num1 * ray.Direction.X, ray.Position.Y + num1 * ray.Direction.Y, 0.0f); Vector2 vector2_1 = new Vector2(vector3.X, vector3.Y); Vector2 target = new Vector2((float)input.CurrentMouseState.X, (float)input.CurrentMouseState.Y); float num2 = Math.Abs(MathHelper.ToRadians(this.findAngleToTarget(this.startDrag, target))); Vector2 vector2_2 = Vector2.Normalize(target - this.startDrag); if ((double)input.RightMouseTimer > 0.0) { if (this.SelectedFleet != null && this.SelectedFleet.Owner == this.player) { AudioManager.PlayCue("echo_affirm1"); this.SelectedSomethingTimer = 3f; float num3 = Math.Abs(MathHelper.ToRadians(this.findAngleToTarget(this.SelectedFleet.Position, vector2_1))); Vector2 vectorToTarget = HelperFunctions.FindVectorToTarget(Vector2.Zero, HelperFunctions.findPointFromAngleAndDistanceUsingRadians(this.SelectedFleet.Position, num3, 1f)); foreach (Ship ship in (List<Ship>)this.SelectedFleet.Ships) this.player.GetGSAI().DefensiveCoordinator.remove(ship); Ship ship1 = this.CheckShipClick(this.startDrag); Planet planet; lock (GlobalStats.ClickableSystemsLock) planet = this.CheckPlanetClick(this.startDrag); if (ship1 != null && ship1.loyalty != this.player) { this.SelectedFleet.Position = ship1.Center; this.SelectedFleet.AssignPositions(0.0f); foreach (Ship ship2 in (List<Ship>)this.SelectedFleet.Ships) { if (ship2.Role == "troop") ship2.GetAI().OrderTroopToBoardShip(ship1); else if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift)) ship2.GetAI().OrderQueueSpecificTarget(ship1); else ship2.GetAI().OrderAttackSpecificTarget(ship1); } } else if (planet != null) { foreach (Ship ship2 in (List<Ship>)this.SelectedFleet.Ships) { RightClickship(ship2, planet,false); } } else if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift)) this.SelectedFleet.FormationWarpToQ(vector2_1, num3, vectorToTarget); else if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftAlt)) this.SelectedFleet.MoveToDirectly(vector2_1, num3, vectorToTarget); else this.SelectedFleet.FormationWarpTo(vector2_1, num3, vectorToTarget); } else if (this.SelectedShip != null && this.SelectedShip.loyalty == this.player) { this.player.GetGSAI().DefensiveCoordinator.DefensiveForcePool.Remove(this.SelectedShip); this.SelectedSomethingTimer = 3f; Ship ship = this.CheckShipClick(this.startDrag); Planet planet; lock (GlobalStats.ClickableSystemsLock) planet = this.CheckPlanetClick(this.startDrag); if (ship != null && ship != this.SelectedShip) #region Target Ship { if (this.SelectedShip.Role == "construction") { AudioManager.PlayCue("UI_Misc20"); return; } else { AudioManager.PlayCue("echo_affirm1"); if (ship.loyalty == this.player) { if (this.SelectedShip.Role == "troop") { if (ship.TroopList.Count < ship.TroopCapacity) this.SelectedShip.GetAI().OrderTroopToShip(ship); else this.SelectedShip.DoEscort(ship); } else this.SelectedShip.DoEscort(ship); } else if (this.SelectedShip.Role == "troop") this.SelectedShip.GetAI().OrderTroopToBoardShip(ship); else if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift)) this.SelectedShip.GetAI().OrderQueueSpecificTarget(ship); else this.SelectedShip.GetAI().OrderAttackSpecificTarget(ship); } } #endregion else if (ship != null && ship == this.SelectedShip) { if (ship.loyalty == this.player) this.LoadShipMenuNodes(1); else this.LoadShipMenuNodes(0); if (!this.pieMenu.Visible) { this.pieMenu.RootNode = this.shipMenu; this.pieMenu.Show(this.pieMenu.Position); } else this.pieMenu.ChangeTo((PieMenuNode)null); } else if (planet != null) { RightClickship(this.SelectedShip, planet,true); } else if (this.SelectedShip.Role == "construction") { AudioManager.PlayCue("UI_Misc20"); return; } else { AudioManager.PlayCue("echo_affirm1"); if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift)) { if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftAlt)) this.SelectedShip.GetAI().OrderMoveDirectlyTowardsPosition(vector2_1, num2, vector2_2, false); else this.SelectedShip.GetAI().OrderMoveTowardsPosition(vector2_1, num2, vector2_2, false,null); } else if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftAlt)) this.SelectedShip.GetAI().OrderMoveDirectlyTowardsPosition(vector2_1, num2, vector2_2, true); else if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftControl)) { this.SelectedShip.GetAI().OrderMoveTowardsPosition(vector2_1, num2, vector2_2, true,null); this.SelectedShip.GetAI().OrderQueue.AddLast(new ArtificialIntelligence.ShipGoal(ArtificialIntelligence.Plan.HoldPosition, vector2_1, num2)); this.SelectedShip.GetAI().HasPriorityOrder = true; this.SelectedShip.GetAI().IgnoreCombat = true; } else this.SelectedShip.GetAI().OrderMoveTowardsPosition(vector2_1, num2, vector2_2, true,null); } } else if (this.SelectedShipList.Count > 0) { this.SelectedSomethingTimer = 3f; foreach (Ship ship in (List<Ship>)this.SelectedShipList) { if (ship.loyalty != this.player || ship.Role == "construction") { AudioManager.PlayCue("UI_Misc20"); return; } } AudioManager.PlayCue("echo_affirm1"); Ship ship1 = this.CheckShipClick(this.startDrag); Planet planet; lock (GlobalStats.ClickableSystemsLock) planet = this.CheckPlanetClick(this.startDrag); if (ship1 != null || planet != null) #region Target Planet { foreach (Ship ship2 in (List<Ship>)this.SelectedShipList) { this.player.GetGSAI().DefensiveCoordinator.remove(ship2); if (ship1 != null && ship1 != ship2) { if (ship1.loyalty == this.player) { if (ship2.Role == "troop") { if (ship1.TroopList.Count < ship1.TroopCapacity) ship2.GetAI().OrderTroopToShip(ship1); else ship2.DoEscort(ship1); } else ship2.DoEscort(ship1); } else if (ship2.Role == "troop") ship2.GetAI().OrderTroopToBoardShip(ship1); else if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift)) ship2.GetAI().OrderQueueSpecificTarget(ship1); else ship2.GetAI().OrderAttackSpecificTarget(ship1); } else if (planet != null) { RightClickship(ship2, planet, false); } } } #endregion else { this.SelectedSomethingTimer = 3f; foreach (Ship ship2 in (List<Ship>)this.SelectedShipList) { if (ship2.Role == "construction") { this.SelectedShipList.Clear(); AudioManager.PlayCue("UI_Misc20"); return; } } AudioManager.PlayCue("echo_affirm1"); this.endDragWorld = this.GetWorldSpaceFromScreenSpace(input.CursorPosition); Enumerable.OrderBy<Ship, float>((IEnumerable<Ship>)this.SelectedShipList, (Func<Ship, float>)(ship => ship.Center.X)); Vector2 fVec = new Vector2(-vector2_2.Y, vector2_2.X); float num3 = Vector2.Distance(this.endDragWorld, this.startDragWorld); int num4 = 0; int num5 = 0; float num6 = 0.0f; for (int index = 0; index < this.SelectedShipList.Count; ++index) { this.player.GetGSAI().DefensiveCoordinator.remove(this.SelectedShipList[index]); if ((double)this.SelectedShipList[index].GetSO().WorldBoundingSphere.Radius > (double)num6) num6 = this.SelectedShipList[index].GetSO().WorldBoundingSphere.Radius; } Fleet fleet = new Fleet(); if ((double)this.SelectedShipList.Count * (double)num6 > (double)num3) { for (int index = 0; index < this.SelectedShipList.Count; ++index) { fleet.AddShip(this.SelectedShipList[index].SoftCopy()); fleet.Ships[index].RelativeFleetOffset = new Vector2((num6 + 200f) * (float)num5, (float)num4 * (num6 + 200f)); ++num5; if ((double)fleet.Ships[index].RelativeFleetOffset.X + (double)num6 > (double)num3) { num5 = 0; ++num4; } } } else { float num7 = num3 / (float)this.SelectedShipList.Count; for (int index = 0; index < this.SelectedShipList.Count; ++index) { fleet.AddShip(this.SelectedShipList[index].SoftCopy()); fleet.Ships[index].RelativeFleetOffset = new Vector2(num7 * (float)index, 0.0f); } } fleet.ProjectPos(this.endDragWorld, num2 - 1.570796f, fVec); foreach (Ship ship2 in (List<Ship>)fleet.Ships) { foreach (Ship ship3 in (List<Ship>)this.SelectedShipList) { if (ship2.guid == ship3.guid) { if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift)) { if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftAlt)) ship3.GetAI().OrderMoveDirectlyTowardsPosition(ship2.projectedPosition, num2 - 1.570796f, fVec, false); else ship3.GetAI().OrderMoveTowardsPosition(ship2.projectedPosition, num2 - 1.570796f, fVec, false,null); } else if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftAlt)) ship3.GetAI().OrderMoveDirectlyTowardsPosition(ship2.projectedPosition, num2 - 1.570796f, fVec, true); else ship3.GetAI().OrderMoveTowardsPosition(ship2.projectedPosition, num2 - 1.570796f, fVec, true,null); } } } this.projectedGroup = (ShipGroup)fleet; fleet.Reset(); } } if (this.SelectedFlank == null && this.SelectedFleet == null && (this.SelectedItem == null && this.SelectedShip == null) && (this.SelectedPlanet == null && this.SelectedShipList.Count == 0)) { Ship ship = this.CheckShipClick(input.CursorPosition); if (ship != null) { this.SelectedShip = ship; if (ship.loyalty == this.player) this.LoadShipMenuNodes(1); else this.LoadShipMenuNodes(0); if (!this.pieMenu.Visible) { this.pieMenu.RootNode = this.shipMenu; this.pieMenu.Show(this.pieMenu.Position); } else this.pieMenu.ChangeTo((PieMenuNode)null); } } } else { this.ProjectingPosition = true; if (this.SelectedFleet != null && this.SelectedFleet.Owner == this.player) { this.SelectedSomethingTimer = 3f; if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift)) this.SelectedFleet.FormationWarpToQ(this.ProjectedPosition, num2, vector2_2); else this.SelectedFleet.FormationWarpTo(this.ProjectedPosition, num2, vector2_2); AudioManager.PlayCue("echo_affirm1"); foreach (Ship ship in (List<Ship>)this.SelectedFleet.Ships) this.player.GetGSAI().DefensiveCoordinator.remove(ship); } else if (this.SelectedShip != null && this.SelectedShip.loyalty == this.player) { this.player.GetGSAI().DefensiveCoordinator.remove(this.SelectedShip); this.SelectedSomethingTimer = 3f; if (this.SelectedShip.Role == "construction") { if (this.SelectedShip != null && this.SelectedShip != this.previousSelection) this.previousSelection = this.SelectedShip; this.SelectedShip = (Ship)null; AudioManager.PlayCue("UI_Misc20"); return; } else { AudioManager.PlayCue("echo_affirm1"); if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift)) { if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftAlt)) this.SelectedShip.GetAI().OrderMoveDirectlyTowardsPosition(this.ProjectedPosition, num2, vector2_2, false); else this.SelectedShip.GetAI().OrderMoveTowardsPosition(this.ProjectedPosition, num2, vector2_2, false,null); } else if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftAlt)) this.SelectedShip.GetAI().OrderMoveDirectlyTowardsPosition(this.ProjectedPosition, num2, vector2_2, true); else this.SelectedShip.GetAI().OrderMoveTowardsPosition(this.ProjectedPosition, num2, vector2_2, true,null); } } else if (this.SelectedShipList.Count > 0) { this.SelectedSomethingTimer = 3f; foreach (Ship ship in (List<Ship>)this.SelectedShipList) { if (ship.loyalty != this.player) return; if (ship.Role == "construction") { this.SelectedShipList.Clear(); AudioManager.PlayCue("UI_Misc20"); return; } } AudioManager.PlayCue("echo_affirm1"); this.endDragWorld = this.GetWorldSpaceFromScreenSpace(input.CursorPosition); Enumerable.OrderBy<Ship, float>((IEnumerable<Ship>)this.SelectedShipList, (Func<Ship, float>)(ship => ship.Center.X)); Vector2 fVec = new Vector2(-vector2_2.Y, vector2_2.X); float num3 = Vector2.Distance(this.endDragWorld, this.startDragWorld); int num4 = 0; int num5 = 0; float num6 = 0.0f; for (int index = 0; index < this.SelectedShipList.Count; ++index) { this.player.GetGSAI().DefensiveCoordinator.remove(this.SelectedShipList[index]); if ((double)this.SelectedShipList[index].GetSO().WorldBoundingSphere.Radius > (double)num6) num6 = this.SelectedShipList[index].GetSO().WorldBoundingSphere.Radius; } Fleet fleet = new Fleet(); if ((double)this.SelectedShipList.Count * (double)num6 > (double)num3) { for (int index = 0; index < this.SelectedShipList.Count; ++index) { fleet.AddShip(this.SelectedShipList[index].SoftCopy()); fleet.Ships[index].RelativeFleetOffset = new Vector2((num6 + 200f) * (float)num5, (float)num4 * (num6 + 200f)); ++num5; if ((double)this.SelectedShipList[index].RelativeFleetOffset.X + (double)num6 > (double)num3) { num5 = 0; ++num4; } } } else { float num7 = num3 / (float)this.SelectedShipList.Count; for (int index = 0; index < this.SelectedShipList.Count; ++index) { fleet.AddShip(this.SelectedShipList[index].SoftCopy()); fleet.Ships[index].RelativeFleetOffset = new Vector2(num7 * (float)index, 0.0f); } } fleet.ProjectPos(this.ProjectedPosition, num2 - 1.570796f, fVec); foreach (Ship ship1 in (List<Ship>)fleet.Ships) { foreach (Ship ship2 in (List<Ship>)this.SelectedShipList) { if (ship1.guid == ship2.guid) { if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift)) { if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftAlt)) ship2.GetAI().OrderMoveDirectlyTowardsPosition(ship1.projectedPosition, num2 - 1.570796f, fVec, false); else ship2.GetAI().OrderMoveTowardsPosition(ship1.projectedPosition, num2 - 1.570796f, fVec, false,null); } else if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftAlt)) ship2.GetAI().OrderMoveDirectlyTowardsPosition(ship1.projectedPosition, num2 - 1.570796f, fVec, true); else ship2.GetAI().OrderMoveTowardsPosition(ship1.projectedPosition, num2 - 1.570796f, fVec, true,null); } } } this.projectedGroup = (ShipGroup)fleet; } } } if (input.CurrentMouseState.RightButton == ButtonState.Pressed && input.LastMouseState.RightButton == ButtonState.Pressed) { Vector2 target = new Vector2((float)input.CurrentMouseState.X, (float)input.CurrentMouseState.Y); float facing = Math.Abs(MathHelper.ToRadians(this.findAngleToTarget(this.startDrag, target))); Vector2 fVec1 = Vector2.Normalize(target - this.startDrag); if ((double)input.RightMouseTimer > 0.0) return; this.ProjectingPosition = true; if (this.SelectedFlank != null) { this.SelectedFleet.ProjectPos(this.ProjectedPosition, facing, this.SelectedFlank); ShipGroup shipGroup = new ShipGroup(); foreach (Fleet.Squad squad in this.SelectedFlank) { foreach (Ship ship in (List<Ship>)squad.Ships) shipGroup.Ships.Add(ship); } shipGroup.ProjectedFacing = facing; this.projectedGroup = shipGroup; } else if (this.SelectedFleet != null && this.SelectedFleet.Owner == this.player) { this.ProjectingPosition = true; this.SelectedFleet.ProjectPos(this.ProjectedPosition, facing, fVec1); this.projectedGroup = (ShipGroup)this.SelectedFleet; } else if (this.SelectedShip != null && this.SelectedShip.loyalty == this.player) { if (this.SelectedShip.Role == "construction") { this.SelectedShip = (Ship)null; AudioManager.PlayCue("UI_Misc20"); } else { ShipGroup shipGroup = new ShipGroup(); shipGroup.Ships.Add(this.SelectedShip); shipGroup.ProjectPos(this.ProjectedPosition, facing, fVec1); this.projectedGroup = shipGroup; } } else { if (this.SelectedShipList.Count <= 0) return; foreach (Ship ship in (List<Ship>)this.SelectedShipList) { if (ship.loyalty != this.player) return; } this.endDragWorld = this.GetWorldSpaceFromScreenSpace(input.CursorPosition); Enumerable.OrderBy<Ship, float>((IEnumerable<Ship>)this.SelectedShipList, (Func<Ship, float>)(ship => ship.Center.X)); Vector2 fVec2 = new Vector2(-fVec1.Y, fVec1.X); float num1 = Vector2.Distance(this.endDragWorld, this.startDragWorld); int num2 = 0; int num3 = 0; float num4 = 0.0f; for (int index = 0; index < this.SelectedShipList.Count; ++index) { if ((double)this.SelectedShipList[index].GetSO().WorldBoundingSphere.Radius > (double)num4) num4 = this.SelectedShipList[index].GetSO().WorldBoundingSphere.Radius; } Fleet fleet = new Fleet(); if ((double)this.SelectedShipList.Count * (double)num4 > (double)num1) { for (int index = 0; index < this.SelectedShipList.Count; ++index) { fleet.AddShip(this.SelectedShipList[index].SoftCopy()); fleet.Ships[index].RelativeFleetOffset = new Vector2((num4 + 200f) * (float)num3, (float)num2 * (num4 + 200f)); ++num3; if ((double)this.SelectedShipList[index].RelativeFleetOffset.X + (double)num4 > (double)num1) { num3 = 0; ++num2; } } } else { float num5 = num1 / (float)this.SelectedShipList.Count; for (int index = 0; index < this.SelectedShipList.Count; ++index) { fleet.AddShip(this.SelectedShipList[index].SoftCopy()); fleet.Ships[index].RelativeFleetOffset = new Vector2(num5 * (float)index, 0.0f); } } fleet.ProjectPos(this.ProjectedPosition, facing - 1.570796f, fVec2); this.projectedGroup = (ShipGroup)fleet; } } else this.ProjectingPosition = false; } }