public void OrderLandAllTroops(Planet target) { if ((this.Owner.Role == "troop" || this.Owner.HasTroopBay || this.Owner.hasTransporter) && this.Owner.TroopList.Count > 0 && target.GetGroundLandingSpots() >0 ) { this.HasPriorityOrder = true; this.State = AIState.AssaultPlanet; this.OrbitTarget = target; this.OrderQueue.Clear(); ArtificialIntelligence.ShipGoal goal = new ArtificialIntelligence.ShipGoal(ArtificialIntelligence.Plan.LandTroop, Vector2.Zero, 0f) { TargetPlanet = target }; this.OrderQueue.AddLast(goal); } else if (this.Owner.BombBays.Count > 0 && target.GetGroundStrength(this.Owner.loyalty) ==0) //universeScreen.player == this.Owner.loyalty && { this.State = AIState.Bombard; this.OrderBombardTroops(target); } }
//added by gremlin replace redundant code with method private void RightClickship(Ship ship, Planet planet, bool audio) { if (ship.Role == "construction") { if(audio) AudioManager.PlayCue("UI_Misc20"); return; } else { if(audio) AudioManager.PlayCue("echo_affirm1"); if (ship.isColonyShip) { if (planet.Owner == null && planet.habitable) ship.GetAI().OrderColonization(planet); else ship.GetAI().OrderToOrbit(planet, true); } else if (ship.Role == "troop" || (ship.TroopList.Count > 0 && (ship.HasTroopBay || ship.hasTransporter))) { if (planet.Owner != null && planet.Owner == this.player && (!ship.HasTroopBay && !ship.hasTransporter)) { if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift)) ship.GetAI().OrderToOrbit(planet, false); else ship.GetAI().OrderRebase(planet, true); } else //add new right click troop and troop ship options on planets if (planet.habitable && (planet.Owner == null || planet.Owner != this.player && (ship.loyalty.GetRelations()[planet.Owner].AtWar || planet.Owner.isFaction || planet.Owner.data.Defeated || planet.Owner == null))) { if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift)) ship.GetAI().OrderToOrbit(planet, false); else { ship.GetAI().State = AIState.AssaultPlanet; ship.GetAI().OrderLandAllTroops(planet); } } else { ship.GetAI().OrderOrbitPlanet(planet);// OrderRebase(planet, true); } } else if (ship.BombBays.Count > 0) { float enemies = planet.GetGroundStrengthOther(this.player) * 1.5f; float friendlies = planet.GetGroundStrength(this.player); if (planet.Owner != this.player) { if (planet.Owner == null || this.player.GetRelations()[planet.Owner].AtWar || planet.Owner.isFaction || planet.Owner.data.Defeated) { if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift)) ship.GetAI().OrderBombardPlanet(planet); else if (enemies > friendlies || planet.Population > 0f) ship.GetAI().OrderBombardPlanet(planet); else { ship.GetAI().OrderToOrbit(planet, false); } } else { ship.GetAI().OrderToOrbit(planet, false); } } else if (enemies > friendlies && input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift)) { ship.GetAI().OrderBombardPlanet(planet); } else ship.GetAI().OrderToOrbit(planet, true); } else if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift)) ship.GetAI().OrderToOrbit(planet, false); else ship.GetAI().OrderToOrbit(planet, true); } }