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; } }