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