public void AcceptOffer(Offer ToUs, Offer FromUs, Empire us, Empire Them)
 {
     if (ToUs.PeaceTreaty)
     {
         this.empire.GetRelations()[Them].AtWar = false;
         this.empire.GetRelations()[Them].PreparingForWar = false;
         this.empire.GetRelations()[Them].ActiveWar.EndStarDate = this.empire.GetUS().StarDate;
         this.empire.GetRelations()[Them].WarHistory.Add(this.empire.GetRelations()[Them].ActiveWar);
         if (this.empire.data.DiplomaticPersonality != null)
         {
             this.empire.GetRelations()[Them].Posture = Posture.Neutral;
             if (this.empire.GetRelations()[Them].Anger_FromShipsInOurBorders > (float)(this.empire.data.DiplomaticPersonality.Territorialism / 3))
             {
                 this.empire.GetRelations()[Them].Anger_FromShipsInOurBorders = (float)(this.empire.data.DiplomaticPersonality.Territorialism / 3);
             }
             if (this.empire.GetRelations()[Them].Anger_TerritorialConflict > (float)(this.empire.data.DiplomaticPersonality.Territorialism / 3))
             {
                 this.empire.GetRelations()[Them].Anger_TerritorialConflict = (float)(this.empire.data.DiplomaticPersonality.Territorialism / 3);
             }
         }
         this.empire.GetRelations()[Them].Anger_MilitaryConflict = 0f;
         this.empire.GetRelations()[Them].WarnedAboutShips = false;
         this.empire.GetRelations()[Them].WarnedAboutColonizing = false;
         this.empire.GetRelations()[Them].HaveRejected_Demand_Tech = false;
         this.empire.GetRelations()[Them].HaveRejected_OpenBorders = false;
         this.empire.GetRelations()[Them].HaveRejected_TRADE = false;
         this.empire.GetRelations()[Them].HasDefenseFleet = false;
         if (this.empire.GetRelations()[Them].DefenseFleet != -1)
         {
             this.empire.GetFleetsDict()[this.empire.GetRelations()[Them].DefenseFleet].Task.EndTask();
         }
         lock (GlobalStats.TaskLocker)
         {
             foreach (MilitaryTask task in this.TaskList)
             {
                 if (task.GetTargetPlanet() == null || task.GetTargetPlanet().Owner == null || task.GetTargetPlanet().Owner != Them)
                 {
                     continue;
                 }
                 task.EndTask();
             }
         }
         this.empire.GetRelations()[Them].ActiveWar = null;
         Them.GetRelations()[this.empire].AtWar = false;
         Them.GetRelations()[this.empire].PreparingForWar = false;
         Them.GetRelations()[this.empire].ActiveWar.EndStarDate = Them.GetUS().StarDate;
         Them.GetRelations()[this.empire].WarHistory.Add(Them.GetRelations()[this.empire].ActiveWar);
         Them.GetRelations()[this.empire].Posture = Posture.Neutral;
         if (EmpireManager.GetEmpireByName(Them.GetUS().PlayerLoyalty) != Them)
         {
             if (Them.GetRelations()[this.empire].Anger_FromShipsInOurBorders > (float)(Them.data.DiplomaticPersonality.Territorialism / 3))
             {
                 Them.GetRelations()[this.empire].Anger_FromShipsInOurBorders = (float)(Them.data.DiplomaticPersonality.Territorialism / 3);
             }
             if (Them.GetRelations()[this.empire].Anger_TerritorialConflict > (float)(Them.data.DiplomaticPersonality.Territorialism / 3))
             {
                 Them.GetRelations()[this.empire].Anger_TerritorialConflict = (float)(Them.data.DiplomaticPersonality.Territorialism / 3);
             }
             Them.GetRelations()[this.empire].Anger_MilitaryConflict = 0f;
             Them.GetRelations()[this.empire].WarnedAboutShips = false;
             Them.GetRelations()[this.empire].WarnedAboutColonizing = false;
             Them.GetRelations()[this.empire].HaveRejected_Demand_Tech = false;
             Them.GetRelations()[this.empire].HaveRejected_OpenBorders = false;
             Them.GetRelations()[this.empire].HaveRejected_TRADE = false;
             if (Them.GetRelations()[this.empire].DefenseFleet != -1)
             {
                 Them.GetFleetsDict()[Them.GetRelations()[this.empire].DefenseFleet].Task.EndTask();
             }
             lock (GlobalStats.TaskLocker)
             {
                 foreach (MilitaryTask task in Them.GetGSAI().TaskList)
                 {
                     if (task.GetTargetPlanet() == null || task.GetTargetPlanet().Owner == null || task.GetTargetPlanet().Owner != this.empire)
                     {
                         continue;
                     }
                     task.EndTask();
                 }
             }
         }
         Them.GetRelations()[this.empire].ActiveWar = null;
         if (Them == EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty) || this.empire == EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty))
         {
             Ship.universeScreen.NotificationManager.AddPeaceTreatyEnteredNotification(this.empire, Them);
         }
         else if (EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty).GetRelations()[Them].Known && EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty).GetRelations()[this.empire].Known)
         {
             Ship.universeScreen.NotificationManager.AddPeaceTreatyEnteredNotification(this.empire, Them);
         }
     }
     if (ToUs.NAPact)
     {
         us.GetRelations()[Them].Treaty_NAPact = true;
         TrustEntry te = new TrustEntry();
         if (EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty) != us)
         {
             string name = us.data.DiplomaticPersonality.Name;
             string str = name;
             if (name != null)
             {
                 if (str == "Pacifist")
                 {
                     te.TrustCost = 0f;
                 }
                 else if (str == "Cunning")
                 {
                     te.TrustCost = 0f;
                 }
                 else if (str == "Xenophobic")
                 {
                     te.TrustCost = 15f;
                 }
                 else if (str == "Aggressive")
                 {
                     te.TrustCost = 35f;
                 }
                 else if (str == "Honorable")
                 {
                     te.TrustCost = 5f;
                 }
                 else if (str == "Ruthless")
                 {
                     te.TrustCost = 50f;
                 }
             }
         }
         te.Type = TrustEntryType.Treaty;
         us.GetRelations()[Them].TrustEntries.Add(te);
     }
     if (FromUs.NAPact)
     {
         Them.GetRelations()[us].Treaty_NAPact = true;
         if (EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty) != Them)
         {
             TrustEntry te = new TrustEntry();
             string name1 = Them.data.DiplomaticPersonality.Name;
             string str1 = name1;
             if (name1 != null)
             {
                 if (str1 == "Pacifist")
                 {
                     te.TrustCost = 0f;
                 }
                 else if (str1 == "Cunning")
                 {
                     te.TrustCost = 0f;
                 }
                 else if (str1 == "Xenophobic")
                 {
                     te.TrustCost = 15f;
                 }
                 else if (str1 == "Aggressive")
                 {
                     te.TrustCost = 35f;
                 }
                 else if (str1 == "Honorable")
                 {
                     te.TrustCost = 5f;
                 }
                 else if (str1 == "Ruthless")
                 {
                     te.TrustCost = 50f;
                 }
             }
             te.Type = TrustEntryType.Treaty;
             Them.GetRelations()[us].TrustEntries.Add(te);
         }
     }
     if (ToUs.TradeTreaty)
     {
         us.GetRelations()[Them].Treaty_Trade = true;
         us.GetRelations()[Them].Treaty_Trade_TurnsExisted = 0;
         TrustEntry te = new TrustEntry()
         {
             TrustCost = 0.1f,
             Type = TrustEntryType.Treaty
         };
         us.GetRelations()[Them].TrustEntries.Add(te);
     }
     if (FromUs.TradeTreaty)
     {
         Them.GetRelations()[us].Treaty_Trade = true;
         Them.GetRelations()[us].Treaty_Trade_TurnsExisted = 0;
         TrustEntry te = new TrustEntry()
         {
             TrustCost = 0.1f,
             Type = TrustEntryType.Treaty
         };
         Them.GetRelations()[us].TrustEntries.Add(te);
     }
     if (ToUs.OpenBorders)
     {
         us.GetRelations()[Them].Treaty_OpenBorders = true;
         TrustEntry te = new TrustEntry()
         {
             TrustCost = 5f,
             Type = TrustEntryType.Treaty
         };
         us.GetRelations()[Them].TrustEntries.Add(te);
     }
     if (FromUs.OpenBorders)
     {
         Them.GetRelations()[us].Treaty_OpenBorders = true;
         TrustEntry te = new TrustEntry()
         {
             TrustCost = 5f,
             Type = TrustEntryType.Treaty
         };
         Them.GetRelations()[us].TrustEntries.Add(te);
     }
     foreach (string tech in FromUs.TechnologiesOffered)
     {
         //Added by McShooterz:
         //Them.UnlockTech(tech);
         Them.AcquireTech(tech, us);
         if (EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty) == us)
         {
             continue;
         }
         TrustEntry te = new TrustEntry()
         {
             TrustCost = (us.data.EconomicPersonality.Name == "Technologists" ? ResourceManager.TechTree[tech].Cost / 100f * 0.25f + ResourceManager.TechTree[tech].Cost / 100f : ResourceManager.TechTree[tech].Cost / 100f),
             TurnTimer = 40,
             Type = TrustEntryType.Technology
         };
         us.GetRelations()[Them].TrustEntries.Add(te);
     }
     foreach (string tech in ToUs.TechnologiesOffered)
     {
         //Added by McShooterz:
         //us.UnlockTech(tech);
         us.AcquireTech(tech, Them);
         if (EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty) == Them)
         {
             continue;
         }
         TrustEntry te = new TrustEntry()
         {
             TrustCost = (Them.data.EconomicPersonality.Name == "Technologists" ? ResourceManager.TechTree[tech].Cost / 100f * 0.25f + ResourceManager.TechTree[tech].Cost / 100f : ResourceManager.TechTree[tech].Cost / 100f),
             Type = TrustEntryType.Treaty
         };
         Them.GetRelations()[us].TrustEntries.Add(te);
     }
     foreach (string Art in FromUs.ArtifactsOffered)
     {
         Artifact toGive = ResourceManager.ArtifactsDict[Art];
         foreach (Artifact arti in us.data.OwnedArtifacts)
         {
             if (arti.Name != Art)
             {
                 continue;
             }
             toGive = arti;
         }
         us.RemoveArtifact(toGive);
         Them.AddArtifact(toGive);
     }
     foreach (string Art in ToUs.ArtifactsOffered)
     {
         Artifact toGive = ResourceManager.ArtifactsDict[Art];
         foreach (Artifact arti in Them.data.OwnedArtifacts)
         {
             if (arti.Name != Art)
             {
                 continue;
             }
             toGive = arti;
         }
         Them.RemoveArtifact(toGive);
         us.AddArtifact(toGive);
     }
     foreach (string planetName in FromUs.ColoniesOffered)
     {
         List<Planet> toRemove = new List<Planet>();
         List<Ship> TroopShips = new List<Ship>();
         foreach (Planet p in us.GetPlanets())
         {
             if (p.Name != planetName)
             {
                 continue;
             }
             foreach (PlanetGridSquare pgs in p.TilesList)
             {
                 if (pgs.TroopsHere.Count <= 0 || pgs.TroopsHere[0].GetOwner() != this.empire)
                 {
                     continue;
                 }
                 pgs.TroopsHere[0].SetPlanet(p);
                 TroopShips.Add(pgs.TroopsHere[0].Launch());
             }
             toRemove.Add(p);
             p.Owner = Them;
             Them.AddPlanet(p);
             if (Them != EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
             {
                 p.colonyType = Them.AssessColonyNeeds(p);
             }
             p.system.OwnerList.Clear();
             foreach (Planet pl in p.system.PlanetList)
             {
                 if (pl.Owner == null || p.system.OwnerList.Contains(pl.Owner))
                 {
                     continue;
                 }
                 p.system.OwnerList.Add(pl.Owner);
             }
             float value = p.Population / 1000f + p.FoodHere / 50f + p.ProductionHere / 50f + p.Fertility + p.MineralRichness + p.MaxPopulation / 10000f;
             foreach (Building b in p.BuildingList)
             {
                 value = value + b.Cost / 50f;
             }
             TrustEntry te = new TrustEntry()
             {
                 TrustCost = (us.data.EconomicPersonality.Name == "Expansionists" ? value + value : value + 0.5f * value),
                 TurnTimer = 40,
                 Type = TrustEntryType.Technology
             };
             us.GetRelations()[Them].TrustEntries.Add(te);
         }
         foreach (Planet p in toRemove)
         {
             us.GetPlanets().Remove(p);
         }
         foreach (Ship ship in TroopShips)
         {
             ship.GetAI().OrderRebaseToNearest();
         }
     }
     foreach (string planetName in ToUs.ColoniesOffered)
     {
         List<Planet> toRemove = new List<Planet>();
         List<Ship> TroopShips = new List<Ship>();
         foreach (Planet p in Them.GetPlanets())
         {
             if (p.Name != planetName)
             {
                 continue;
             }
             toRemove.Add(p);
             p.Owner = us;
             us.AddPlanet(p);
             p.system.OwnerList.Clear();
             foreach (Planet pl in p.system.PlanetList)
             {
                 if (pl.Owner == null || p.system.OwnerList.Contains(pl.Owner))
                 {
                     continue;
                 }
                 p.system.OwnerList.Add(pl.Owner);
             }
             float value = p.Population / 1000f + p.FoodHere / 50f + p.ProductionHere / 50f + p.Fertility + p.MineralRichness + p.MaxPopulation / 10000f;
             foreach (Building b in p.BuildingList)
             {
                 value = value + b.Cost / 50f;
             }
             foreach (PlanetGridSquare pgs in p.TilesList)
             {
                 if (pgs.TroopsHere.Count <= 0 || pgs.TroopsHere[0].GetOwner() != Them)
                 {
                     continue;
                 }
                 pgs.TroopsHere[0].SetPlanet(p);
                 TroopShips.Add(pgs.TroopsHere[0].Launch());
             }
             if (EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty) != Them)
             {
                 TrustEntry te = new TrustEntry()
                 {
                     TrustCost = (Them.data.EconomicPersonality.Name == "Expansionists" ? value + value : value + 0.5f * value),
                     TurnTimer = 40,
                     Type = TrustEntryType.Technology
                 };
                 Them.GetRelations()[us].TrustEntries.Add(te);
             }
             if (us == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
             {
                 continue;
             }
             p.colonyType = us.AssessColonyNeeds(p);
         }
         foreach (Planet p in toRemove)
         {
             Them.GetPlanets().Remove(p);
         }
         foreach (Ship ship in TroopShips)
         {
             ship.GetAI().OrderRebaseToNearest();
         }
     }
 }
        //added by gremlin Domission from devek mod.
        public void DoMission(Empire Owner)
        {
            spyMute = AgentComponent.SpyMute;
            Planet target;
            Empire Target = EmpireManager.GetEmpireByName(this.TargetEmpire);
            AgentMission startingmission = this.Mission;
            #region EmpireDefeated
            if (Target != null && Target.data.Defeated)
            {
                this.Mission = AgentMission.Defending;
                this.MissionNameIndex = 2183;
                return;
            }
            #endregion
            #region New DiceRoll
            float DiceRoll = RandomMath.RandomBetween(this.Level * ResourceManager.AgentMissionData.MinRollPerLevel, ResourceManager.AgentMissionData.MaxRoll);
            float DefensiveRoll = 0f;
            DiceRoll += (float)this.Level * RandomMath.RandomBetween(1f, ResourceManager.AgentMissionData.RandomLevelBonus);
            DiceRoll += Owner.data.SpyModifier;
            DiceRoll += Owner.data.OffensiveSpyBonus;
            if (Target != null)
            {
                for (int i = 0; i < Target.data.AgentList.Count; i++)
                {
                    if (Target.data.AgentList[i].Mission == AgentMission.Defending)
                    {
                        DefensiveRoll += (float)Target.data.AgentList[i].Level * ResourceManager.AgentMissionData.DefenceLevelBonus;
                    }
                }
                DefensiveRoll /= Owner.GetPlanets().Count / 3 + 1;
                DefensiveRoll += Target.data.SpyModifier;
                DefensiveRoll += Target.data.DefensiveSpyBonus;

                DiceRoll -= DefensiveRoll;
            }
            #endregion
            switch (this.Mission)
            {
                #region Training
                case AgentMission.Training:
                {
                    this.Mission = AgentMission.Defending;
                    this.MissionNameIndex = 2183;
                    if (DiceRoll >= ResourceManager.AgentMissionData.TrainingRollPerfect)
                    {
                        //Added by McShooterz
                        this.AddExperience(ResourceManager.AgentMissionData.TrainingExpPerfect, Owner);
                        if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6025)), Owner);
                        this.Training++;
                        break;
                    }
                    else if (DiceRoll > ResourceManager.AgentMissionData.TrainingRollGood)
                    {
                        //Added by McShooterz
                        this.AddExperience(ResourceManager.AgentMissionData.TrainingExpGood, Owner);
                        if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6026)), Owner);
                        this.Training++;
                        break;
                    }
                    else if (DiceRoll < ResourceManager.AgentMissionData.TrainingRollBad)
                    {
                        if (DiceRoll >= ResourceManager.AgentMissionData.TrainingRollWorst)
                        {
                            if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6027)), Owner);
                            this.AssignMission(AgentMission.Recovering, Owner, "");
                            this.PrevisousMission = AgentMission.Training;
                            break;
                        }
                        if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6028)), Owner);
                        Owner.data.AgentList.QueuePendingRemoval(this);
                        break;
                    }
                    else
                    {
                        if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6029)), Owner);
                        break;
                    }
                }
                #endregion
                #region Infiltrate easy
                case AgentMission.Infiltrate:
                    {
                        if (Target == null || Target.GetPlanets().Count == 0)
                        {
                            this.Mission = AgentMission.Defending;
                            this.MissionNameIndex = 2183;
                            return;
                        }
                        if (DiceRoll >= ResourceManager.AgentMissionData.InfiltrateRollGood)
                        {
                            this.Mission = AgentMission.Undercover;
                            this.MissionNameIndex = 2201;
                            //Added by McShooterz
                            this.AddExperience(ResourceManager.AgentMissionData.InfiltrateExpGood, Owner);
                            Mole m = Mole.PlantMole(Owner, Target);
                            this.TargetGUID = m.PlanetGuid;
                            if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6030), " ", Ship.universeScreen.PlanetsDict[m.PlanetGuid].Name, Localizer.Token(6031)), Owner);
                            this.Infiltrations++;
                            break;
                        }
                        else if (DiceRoll < ResourceManager.AgentMissionData.InfiltrateRollBad)
                        {
                            if (DiceRoll >= ResourceManager.AgentMissionData.InfiltrateRollWorst)
                            {
                                this.Mission = AgentMission.Defending;
                                this.MissionNameIndex = 2183;
                                if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6032)), Owner);
                                if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                                {
                                    if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6033), " ", Owner.data.Traits.Name), Target);
                                }
                                this.AssignMission(AgentMission.Recovering, Owner, "");
                                this.PrevisousMission = AgentMission.Infiltrate;
                                this.PreviousTarget = this.TargetEmpire;
                                break;
                            }
                            this.Mission = AgentMission.Defending;
                            this.MissionNameIndex = 2183;
                            Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying Failed", 20f, null);
                            if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6034)), Owner);
                            Owner.data.AgentList.QueuePendingRemoval(this);
                            if (Target != EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                            {
                                break;
                            }

                            if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6035), " ", Owner.data.Traits.Name), Target);
                            break;
                        }
                        else
                        {
                            //Added by McShooterz
                            this.AddExperience(ResourceManager.AgentMissionData.InfiltrateExp, Owner);
                            this.Mission = AgentMission.Defending;
                            this.MissionNameIndex = 2183;
                            if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6036)), Owner);
                            if (Target != EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                            {
                                break;
                            }
                            if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6033), " ", Owner.data.Traits.Name), Target);
                            break;
                        }
                    }
                #endregion
                #region Assassinate hard
                case AgentMission.Assassinate:
                    {
                        this.Mission = AgentMission.Defending;
                        this.MissionNameIndex = 2183;
                        if (Target == null || Target.data.AgentList.Count == 0)
                        {
                            if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6038)), Owner);
                            return;
                        }
                        if (DiceRoll >= ResourceManager.AgentMissionData.AssassinateRollPerfect)
                        {
                            //Added by McShooterz
                            this.AddExperience(ResourceManager.AgentMissionData.AssassinateExpPerfect, Owner);
                            Agent m = Target.data.AgentList[HelperFunctions.GetRandomIndex(Target.data.AgentList.Count)];
                            Target.data.AgentList.Remove(m);
                            if (m.Mission == AgentMission.Undercover)
                            {
                                foreach (Mole mole in Owner.data.MoleList)
                                {
                                    if (mole.PlanetGuid != m.TargetGUID)
                                    {
                                        continue;
                                    }
                                    Owner.data.MoleList.QueuePendingRemoval(mole);
                                    break;
                                }
                            }
                            Owner.data.MoleList.ApplyPendingRemovals();
                            if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                            {
                                //if (!GremlinAgentComponent.AutoTrain) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat("One of our Agents was mysteriously assassinated: ", m.Name), Target);
                            }
                            if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6039), " ", m.Name, Localizer.Token(6040)), Owner);
                            this.Assassinations++;
                            break;
                        }
                        else if (DiceRoll >= ResourceManager.AgentMissionData.AssassinateRollGood)
                        {
                            Agent m = Target.data.AgentList[HelperFunctions.GetRandomIndex(Target.data.AgentList.Count)];
                            Target.data.AgentList.Remove(m);
                            if (m.Mission == AgentMission.Undercover)
                            {
                                foreach (Mole mole in Owner.data.MoleList)
                                {
                                    if (mole.PlanetGuid != m.TargetGUID)
                                    {
                                        continue;
                                    }
                                    Owner.data.MoleList.QueuePendingRemoval(mole);
                                    break;
                                }
                            }
                            //Added by McShooterz
                            this.AddExperience(ResourceManager.AgentMissionData.AssassinateExpGood, Owner);
                            Owner.data.MoleList.ApplyPendingRemovals();
                            if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                            {
                                if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(Localizer.Token(6037), " ", m.Name, Localizer.Token(6041), " ", Owner.data.Traits.Name), Target);
                            }
                            if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6039), " ", m.Name, Localizer.Token(6042)), Owner);
                            this.Assassinations++;
                            break;
                        }
                        else if (DiceRoll < ResourceManager.AgentMissionData.AssassinateRollBad)
                        {
                            if (DiceRoll >= ResourceManager.AgentMissionData.AssassinateRollWorst)
                            {
                                if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                                {
                                    if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6043), " ", Owner.data.Traits.Name), Target);
                                }
                                if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6044)), Owner);
                                this.AssignMission(AgentMission.Recovering, Owner, "");
                                this.PrevisousMission = AgentMission.Assassinate;
                                this.PreviousTarget = this.TargetEmpire;
                                break;
                            }
                            this.Mission = AgentMission.Defending;
                            this.MissionNameIndex = 2183;
                            Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying Failed", 20f, null);
                            if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                            {
                                if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6045), " ", Owner.data.Traits.Name), Target);
                            }
                            if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6046)), Owner);
                            Owner.data.AgentList.QueuePendingRemoval(this);
                            break;
                        }
                        else
                        {
                            //Added by McShooterz
                            this.AddExperience(ResourceManager.AgentMissionData.AssassinateExp, Owner);
                            if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                            {
                                if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6043), " ", Owner.data.Traits.Name), Target);
                            }
                            if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6047)), Owner);
                            break;
                        }
                    }
                #endregion
                #region Sabotage easy
                case AgentMission.Sabotage:
                    {
                        this.Mission = AgentMission.Defending;
                        this.MissionNameIndex = 2183;
                        if (Target==null || Target.GetPlanets().Count == 0)
                        {
                            return;
                        }
                        target = EmpireManager.GetEmpireByName(this.TargetEmpire).GetPlanets()[HelperFunctions.GetRandomIndex(EmpireManager.GetEmpireByName(this.TargetEmpire).GetPlanets().Count)];
                        this.TargetGUID = target.guid;
                        if (DiceRoll >= ResourceManager.AgentMissionData.SabotageRollPerfect)
                        {
                            Planet crippledTurns = target;
                            crippledTurns.Crippled_Turns = crippledTurns.Crippled_Turns + 5 + this.Level * 5;
                            if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                            {
                                if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(Localizer.Token(6048), " ", target.Name), Target);
                            }
                            NotificationManager notificationManager = Ship.universeScreen.NotificationManager;
                            string[] name = new string[] { this.Name, " " + Localizer.Token(6084) + " ", null, null, null, null };
                            int num = 5 + this.Level * 5;
                            name[2] = num.ToString();
                            name[3] = " " + Localizer.Token(6085) + " ";
                            name[4] = target.Name;
                            name[5] = Localizer.Token(6031);
                            if (!spyMute) notificationManager.AddAgentResultNotification(true, string.Concat(name), Owner);
                            //Added by McShooterz
                            this.AddExperience(ResourceManager.AgentMissionData.SabotageExpPerfect, Owner);
                            this.Sabotages++;
                            break;
                        }
                        else if (DiceRoll > ResourceManager.AgentMissionData.SabotageRollGood)
                        {
                            Planet planet = target;
                            planet.Crippled_Turns = planet.Crippled_Turns + 5 + this.Level * 3;
                            if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                            {
                                if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(Localizer.Token(6048), " ", target.Name, Localizer.Token(6049),  " ", Owner.data.Traits.Name), Target);
                            }
                            NotificationManager notificationManager1 = Ship.universeScreen.NotificationManager;
                            string[] str = new string[] { this.Name, " " + Localizer.Token(6084) + " ", null, null, null, null };
                            int num1 = 5 + this.Level * 3;
                            str[2] = num1.ToString();
                            str[3] = " " + Localizer.Token(6085) + " ";
                            str[4] = target.Name;
                            str[5] = Localizer.Token(6031);
                            if (!spyMute) notificationManager1.AddAgentResultNotification(true, string.Concat(str), Owner);
                            //Added by McShooterz
                            this.AddExperience(ResourceManager.AgentMissionData.SabotageExpGood, Owner);
                            this.Sabotages++;
                            break;
                        }
                        else if (DiceRoll < ResourceManager.AgentMissionData.SabotageRollBad)
                        {
                            if (DiceRoll >= ResourceManager.AgentMissionData.SabotageRollWorst)
                            {
                                if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                                {
                                    if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6051), " ", target.Name, Localizer.Token(6049), " ", Owner.data.Traits.Name), Target);
                                }
                                Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying", 20f, null);
                                if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6052), " ", target.Name), Owner);
                                this.AssignMission(AgentMission.Recovering, Owner, "");
                                this.PrevisousMission = AgentMission.Sabotage;
                                this.PreviousTarget = this.TargetEmpire;
                                break;
                            }
                            if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                            {
                                if (!AgentComponent.AutoTrain) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(Localizer.Token(6053), " ", target.Name, Localizer.Token(6049), " ", Owner.data.Traits.Name), Target);
                            }
                            Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying Failed", 20f, null);
                            if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6054)), Owner);
                            Owner.data.AgentList.QueuePendingRemoval(this);
                            break;
                        }
                        else
                        {
                            //Added by McShooterz
                            this.AddExperience(ResourceManager.AgentMissionData.SabotageExp, Owner);
                            if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                            {
                                if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6051)," ", target.Name, Localizer.Token(6049)," ", Owner.data.Traits.Name), Target);
                            }
                            Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying", 20f, null);
                            if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6055), " ", target.Name), Owner);
                            break;
                        }
                    }
                #endregion
                #region StealTech hard
                case AgentMission.StealTech:
                    {
                        this.Mission = AgentMission.Defending;
                        this.MissionNameIndex = 2183;
                        if (Target == null)
                            return;
                        List<string> PotentialUIDs = new List<string>();
                        foreach (KeyValuePair<string, TechEntry> entry in Target.GetTDict())
                        {
                            //Added by McShooterz: Root nodes cannot be stolen
                            if (!entry.Value.Unlocked || !Owner.HavePreReq(entry.Value.UID) || Owner.GetTDict()[entry.Value.UID].Unlocked || entry.Value.GetTech().RootNode == 1)
                            {
                                continue;
                            }
                            PotentialUIDs.Add(entry.Value.UID);
                        }
                        string theUID = "";
                        if (PotentialUIDs.Count != 0)
                        {
                            theUID = PotentialUIDs[HelperFunctions.GetRandomIndex(PotentialUIDs.Count)];
                            if (DiceRoll >= ResourceManager.AgentMissionData.StealTechRollPerfect)
                            {
                                //Added by McShooterz
                                this.AddExperience(ResourceManager.AgentMissionData.StealTechExpPerfect, Owner);
                                if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                                {
                                    if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, Localizer.Token(6056), Target);
                                }
                                //Added by McShooterz: new acquire method, unlocks targets bonuses as well
                                //Owner.UnlockTech(theUID);
                                Owner.AcquireTech(theUID, Target);
                                if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6057), " ", Localizer.Token(ResourceManager.TechTree[theUID].NameIndex), Localizer.Token(6031)), Owner);
                                this.TechStolen++;
                                break;
                            }
                            else if (DiceRoll > ResourceManager.AgentMissionData.StealTechRollGood)
                            {
                                //Added by McShooterz
                                this.AddExperience(ResourceManager.AgentMissionData.StealTechExpGood, Owner);
                                if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                                {
                                    if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(Localizer.Token(6058), " ", Localizer.Token(ResourceManager.TechTree[theUID].NameIndex), Localizer.Token(6049), " ", Owner.data.Traits.Name), Target);
                                }
                                //Added by McShooterz: new acquire method, unlocks targets bonuses as well
                                //Owner.UnlockTech(theUID);
                                Owner.AcquireTech(theUID, Target);
                                Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying", 20f, null);
                                if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6057), " ", Localizer.Token(ResourceManager.TechTree[theUID].NameIndex), Localizer.Token(6042)), Owner);
                                this.TechStolen++;
                                break;
                            }
                            else if (DiceRoll < ResourceManager.AgentMissionData.StealTechRollBad)
                            {
                                if (DiceRoll >= ResourceManager.AgentMissionData.StealTechRollWorst)
                                {
                                    if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                                    {
                                        if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6059), Localizer.Token(6049), " ", Owner.data.Traits.Name), Target);
                                    }
                                    Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying", 20f, null);
                                    if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6050)), Owner);
                                    this.AssignMission(AgentMission.Recovering, Owner, "");
                                    this.PrevisousMission = AgentMission.StealTech;
                                    this.PreviousTarget = this.TargetEmpire;
                                    break;
                                }
                                if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                                {
                                    if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(Localizer.Token(6060), Localizer.Token(6049), " ", Owner.data.Traits.Name), Target);
                                }
                                Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying Failed", 20f, null);
                                if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6061)), Owner);
                                Owner.data.AgentList.QueuePendingRemoval(this);
                                break;
                            }
                            else
                            {
                                if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                                {
                                    if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6059), Localizer.Token(6049), " ", Owner.data.Traits.Name), Target);
                                }
                                Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying", 20f, null);
                                if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6062)), Owner);
                                break;
                            }
                        }
                        else
                        {
                            this.AddExperience(ResourceManager.AgentMissionData.StealTechExp, Owner);
                            if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6063), " ", (ResourceManager.AgentMissionData.StealTechCost / 2).ToString(), " ", Localizer.Token(6064)), Owner);
                            Empire owner = Owner;
                            owner.Money += ResourceManager.AgentMissionData.StealTechCost / 2;
                            break;
                        }
                    }
                #endregion
                #region Robbery
                case AgentMission.Robbery:
                    {
                        this.Mission = AgentMission.Defending;
                        this.MissionNameIndex = 2183;
                        if (Target == null)
                            return;
                        int amount = (int)(RandomMath.RandomBetween(1f, (float)Target.GetPlanets().Count * 10f) * (float)this.Level);
                        if ((float)amount > Target.Money && Target.Money > 0f)
                        {
                            amount = (int)Target.Money;
                        }
                        else if (Target.Money <= 0f)
                        {
                            if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6066), " ", this.TargetEmpire, Localizer.Token(6067)), Owner);
                            return;
                        }
                        if (DiceRoll >= ResourceManager.AgentMissionData.RobberyRollPerfect)
                        {
                            //Added by McShooterz
                            this.AddExperience(ResourceManager.AgentMissionData.RobberyExpPerfect, Owner);
                            Empire money = Target;
                            money.Money = money.Money - (float)amount;
                            Empire empire = Owner;
                            empire.Money = empire.Money + (float)amount;
                            NotificationManager notificationManager2 = Ship.universeScreen.NotificationManager;
                            object[] objArray = new object[] { this.Name, " ", Localizer.Token(6068), " ", amount, " ", Localizer.Token(6069), " ", this.TargetEmpire, Localizer.Token(6031) };
                            if (!spyMute) notificationManager2.AddAgentResultNotification(true, string.Concat(objArray), Owner);
                            if (Target != EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                            {
                                break;
                            }
                            if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(amount, " ", Localizer.Token(6065)), Target);
                            this.Robberies++;
                            break;
                        }
                        else if (DiceRoll > ResourceManager.AgentMissionData.RobberyRollGood)
                        {
                            //Added by McShooterz
                            this.AddExperience(ResourceManager.AgentMissionData.RobberyExpGood, Owner);
                            Empire money1 = Target;
                            money1.Money = money1.Money - (float)amount;
                            Empire owner1 = Owner;
                            owner1.Money = owner1.Money + (float)amount;
                            if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                            {
                                if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(amount, " ", Localizer.Token(6070), Localizer.Token(6049), " ", Owner.data.Traits.Name), Target);
                            }
                            Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying", 20f, null);
                            NotificationManager notificationManager3 = Ship.universeScreen.NotificationManager;
                            object[] name1 = new object[] { this.Name, " ", Localizer.Token(6068), " ", amount, " ", Localizer.Token(6069), " ", this.TargetEmpire, Localizer.Token(6042) };
                            if (!spyMute) notificationManager3.AddAgentResultNotification(true, string.Concat(name1), Owner);
                            this.Robberies++;
                            break;
                        }
                        else if (DiceRoll < ResourceManager.AgentMissionData.RobberyRollBad)
                        {
                            if (DiceRoll >= ResourceManager.AgentMissionData.RobberyRollWorst)
                            {
                                if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                                {
                                    if (!AgentComponent.AutoTrain && !spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6071), Localizer.Token(6049), " ", Owner.data.Traits.Name), Target);
                                }
                                Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying", 20f, null);
                                if (!spyMute) if (!AgentComponent.AutoTrain) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6072)), Owner);
                                this.AssignMission(AgentMission.Recovering, Owner, "");
                                this.PrevisousMission = AgentMission.Robbery;
                                this.PreviousTarget = this.TargetEmpire;
                                break;
                            }
                            if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                            {
                                if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6073), Localizer.Token(6049), " ", Owner.data.Traits.Name), Target);
                            }
                            Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying Failed", 20f, null);
                            if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6074), " ", this.TargetEmpire), Owner);
                            Owner.data.AgentList.QueuePendingRemoval(this);
                            break;
                        }
                        else
                        {
                            this.AddExperience(ResourceManager.AgentMissionData.RobberyExp, Owner);
                            if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                            {
                                if (!AgentComponent.AutoTrain && !spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6071), Localizer.Token(6049), " ", Owner.data.Traits.Name), Target);
                            }
                            Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying", 20f, null);
                            if (!spyMute) if (!AgentComponent.AutoTrain) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6075)), Owner);
                            break;
                        }
                    }
                #endregion
                #region Rebellion
                case AgentMission.InciteRebellion:
                    {
                        this.Mission = AgentMission.Defending;
                        this.MissionNameIndex = 2183;
                        if (Target == null)
                            return;
                        if (Target.GetPlanets().Count == 0)
                        {
                            return;
                        }
                        target = EmpireManager.GetEmpireByName(this.TargetEmpire).GetPlanets()[HelperFunctions.GetRandomIndex(EmpireManager.GetEmpireByName(this.TargetEmpire).GetPlanets().Count)];
                        if (DiceRoll >= ResourceManager.AgentMissionData.RebellionRollPerfect)
                        {
                            this.AddExperience(ResourceManager.AgentMissionData.RebellionExpPerfect, Owner);
                            if (!EmpireManager.GetEmpireByName(this.TargetEmpire).data.RebellionLaunched)
                            {
                                Empire rebels = CreatingNewGameScreen.CreateRebelsFromEmpireData(EmpireManager.GetEmpireByName(this.TargetEmpire).data, EmpireManager.GetEmpireByName(this.TargetEmpire));
                                rebels.data.IsRebelFaction = true;
                                rebels.data.Traits.Name = EmpireManager.GetEmpireByName(this.TargetEmpire).data.RebelName;
                                rebels.data.Traits.Singular = EmpireManager.GetEmpireByName(this.TargetEmpire).data.RebelSing;
                                rebels.data.Traits.Plural = EmpireManager.GetEmpireByName(this.TargetEmpire).data.RebelPlur;
                                rebels.isFaction = true;
                                foreach (Empire e in EmpireManager.EmpireList)
                                {
                                    e.GetRelations().Add(rebels, new Relationship(rebels.data.Traits.Name));
                                    rebels.GetRelations().Add(e, new Relationship(e.data.Traits.Name));
                                }
                                EmpireManager.EmpireList.Add(rebels);
                                EmpireManager.GetEmpireByName(this.TargetEmpire).data.RebellionLaunched = true;
                            }
                            Empire darebels = EmpireManager.GetEmpireByName(EmpireManager.GetEmpireByName(this.TargetEmpire).data.RebelName);
                            for (int i = 0; i < 4; i++)
                            {
                                foreach (KeyValuePair<string, Troop> troop in ResourceManager.TroopsDict)
                                {
                                    if (!EmpireManager.GetEmpireByName(this.TargetEmpire).WeCanBuildTroop(troop.Key))
                                    {
                                        continue;
                                    }
                                    Troop t = ResourceManager.CreateTroop(troop.Value, darebels);
                                    t.Name = Localizer.Token(darebels.data.TroopNameIndex);
                                    t.Description = Localizer.Token(darebels.data.TroopDescriptionIndex);
                                    target.AssignTroopToTile(t);
                                    break;
                                }
                            }
                            if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                            {
                                if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(Localizer.Token(6078), " ", target.Name), Target);
                            }
                            if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6077), " ", target.Name, Localizer.Token(6031)), Owner);
                            this.Rebellions++;
                            break;
                        }
                        else if (DiceRoll > ResourceManager.AgentMissionData.RebellionRollGood)
                        {
                            this.AddExperience(ResourceManager.AgentMissionData.RebellionExpGood, Owner);
                            if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                            {
                                if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(Localizer.Token(6078), " ", target.Name, Localizer.Token(6049), " ", Owner.data.Traits.Name), Target);
                            }
                            if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6077), " ", target.Name, Localizer.Token(6079)), Owner);
                            this.Rebellions++;
                            break;
                        }
                        else if (DiceRoll < ResourceManager.AgentMissionData.RebellionRollBad)
                        {
                            if (DiceRoll >= ResourceManager.AgentMissionData.RebellionRollWorst)
                            {
                                if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                                {
                                    if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6076), " ", target.Name, Localizer.Token(6049), " ", Owner.data.Traits.Name), Target);
                                }
                                Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying", 20f, null);
                                if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6080), " ", target.Name), Owner);
                                this.AssignMission(AgentMission.Recovering, Owner, "");
                                this.PrevisousMission = AgentMission.InciteRebellion;
                                this.PreviousTarget = this.TargetEmpire;
                                break;
                            }
                            if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                            {
                                if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6081), " ", target.Name, Localizer.Token(6049), " ", Owner.data.Traits.Name), Target);
                            }
                            Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying Failed", 20f, null);
                            if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6082), " ", target.Name), Owner);
                            Owner.data.AgentList.QueuePendingRemoval(this);
                            break;
                        }
                        else
                        {
                            this.AddExperience(ResourceManager.AgentMissionData.RebellionExp, Owner);
                            if (Target == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty))
                            {
                                if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(Localizer.Token(6076), " ", target.Name, Localizer.Token(6049), " ", Owner.data.Traits.Name), Target);
                            }
                            Target.GetRelations()[Owner].DamageRelationship(Target, Owner, "Caught Spying", 20f, null);
                            if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(false, string.Concat(this.Name, " ", Localizer.Token(6083), " ", target.Name), Owner);
                            break;
                        }
                    }
                #endregion
                #region Recovery
                case AgentMission.Recovering :
                        {
                            this.Mission = AgentMission.Defending;
                            startingmission = this.PrevisousMission;
                            this.TargetEmpire = this.PreviousTarget;
                            this.MissionNameIndex = 2183;
                            if (!spyMute) Ship.universeScreen.NotificationManager.AddAgentResultNotification(true, string.Concat(this.Name, " ", Localizer.Token(6086)), Owner);
                            break;
                        }
                #endregion
            }
            #region Mission Repeat
            if (Owner == EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty)
                && Mission == AgentMission.Defending && Owner.Money > 500
                && AgentComponent.AutoTrain == true
                && (startingmission != AgentMission.Training || (startingmission == AgentMission.Training && this.Level < 10)))
            {
                this.AssignMission(startingmission, Owner, this.TargetEmpire);
                return;
            }
            this.TargetEmpire = "";
            #endregion
        }