Exemplo n.º 1
0
 private void OnChangeContractTermLineQuantity(ContractTermLine contractTermLine)
 {
     if (this.DiplomaticContract == null)
     {
         Diagnostics.LogWarning("Diplomatic contract is null");
         return;
     }
     if (contractTermLine.ContractTerm is DiplomaticTermResourceExchange)
     {
         DiplomaticTermResourceExchange diplomaticTermResourceExchange = contractTermLine.ContractTerm as DiplomaticTermResourceExchange;
         DiplomaticTermResourceExchange term = new DiplomaticTermResourceExchange((DiplomaticTermResourceExchangeDefinition)diplomaticTermResourceExchange.Definition, diplomaticTermResourceExchange.EmpireWhichProposes, diplomaticTermResourceExchange.EmpireWhichProvides, diplomaticTermResourceExchange.EmpireWhichReceives, diplomaticTermResourceExchange.ResourceName, contractTermLine.CurrentQuantity);
         DiplomaticTermChange[]         diplomaticTermChanges = new DiplomaticTermChange[]
         {
             DiplomaticTermChange.Refresh(term, contractTermLine.ContractTerm.Index)
         };
         OrderChangeDiplomaticContractTermsCollection order = new OrderChangeDiplomaticContractTermsCollection(this.DiplomaticContract, diplomaticTermChanges);
         Ticket ticket;
         base.PlayerController.PostOrder(order, out ticket, new EventHandler <TicketRaisedEventArgs>(this.OnOrderChangeDiplomaticContractTermsCollectionResponse));
     }
     else
     {
         if (!(contractTermLine.ContractTerm is DiplomaticTermBoosterExchange))
         {
             Diagnostics.LogError("Trying to change quantity on a term that doesn't have any quantity.");
             return;
         }
         DiplomaticTermBoosterExchange termBoosterExchange = contractTermLine.ContractTerm as DiplomaticTermBoosterExchange;
         DepartmentOfEducation         agency = termBoosterExchange.EmpireWhichProvides.GetAgency <DepartmentOfEducation>();
         List <GameEntityGUID>         list   = (from match in agency
                                                 where match.Constructible.Name == termBoosterExchange.BoosterDefinitionName
                                                 select match into selectedBooster
                                                 select selectedBooster.GUID).ToList <GameEntityGUID>();
         int num = (int)contractTermLine.CurrentQuantity;
         if (num < list.Count)
         {
             list.RemoveRange(num, list.Count - num);
             list.TrimExcess();
         }
         GameEntityGUID[] boosterGUIDs       = list.ToArray();
         DiplomaticTermBoosterExchange term2 = new DiplomaticTermBoosterExchange((DiplomaticTermBoosterExchangeDefinition)termBoosterExchange.Definition, termBoosterExchange.EmpireWhichProposes, termBoosterExchange.EmpireWhichProvides, termBoosterExchange.EmpireWhichReceives, boosterGUIDs, termBoosterExchange.BoosterDefinitionName);
         DiplomaticTermChange[]        diplomaticTermChanges2 = new DiplomaticTermChange[]
         {
             DiplomaticTermChange.Refresh(term2, contractTermLine.ContractTerm.Index)
         };
         OrderChangeDiplomaticContractTermsCollection order2 = new OrderChangeDiplomaticContractTermsCollection(this.DiplomaticContract, diplomaticTermChanges2);
         Ticket ticket2;
         base.PlayerController.PostOrder(order2, out ticket2, new EventHandler <TicketRaisedEventArgs>(this.OnOrderChangeDiplomaticContractTermsCollectionResponse));
     }
 }
Exemplo n.º 2
0
 public void GenerateTooltip(AgeTooltip ageTooltip)
 {
     if (this.Type == GuiDiplomaticTerm.TermType.Dust)
     {
         ageTooltip.Class      = "Simple";
         ageTooltip.Content    = string.Empty;
         ageTooltip.ClientData = null;
         return;
     }
     if (this.Type == GuiDiplomaticTerm.TermType.City && this.Term.Definition.Name == DiplomaticTermCityExchange.MimicsCityDeal)
     {
         string text = this.Term.EmpireWhichProvides.Faction.Affinity.Name.ToString();
         text = text.Replace("Affinity", "");
         if (text == "Mezari")
         {
             text = "Vaulters";
         }
         ageTooltip.Class      = "Simple";
         ageTooltip.Content    = "#FFB43F#" + AgeLocalizer.Instance.LocalizeString("%" + text + "IntegrationDescriptor1Title") + "#REVERT#\n\n" + AgeLocalizer.Instance.LocalizeString("%" + text + "IntegrationDescriptor1EffectOverride");
         ageTooltip.ClientData = null;
         return;
     }
     if (this.Type == GuiDiplomaticTerm.TermType.Strategic || this.Type == GuiDiplomaticTerm.TermType.Luxury)
     {
         DiplomaticTermResourceExchange diplomaticTermResourceExchange = this.Term as DiplomaticTermResourceExchange;
         ResourceDefinition             resourceDefinition;
         if (diplomaticTermResourceExchange != null && Databases.GetDatabase <ResourceDefinition>(false).TryGetValue(diplomaticTermResourceExchange.ResourceName, out resourceDefinition))
         {
             IPlayerControllerRepositoryService service = Services.GetService <IGameService>().Game.Services.GetService <IPlayerControllerRepositoryService>();
             Diagnostics.Assert(service != null);
             ResourceTooltipData resourceTooltipData = new ResourceTooltipData(resourceDefinition, service.ActivePlayerController.Empire as global::Empire);
             if (this.Type == GuiDiplomaticTerm.TermType.Luxury)
             {
                 IDatabase <BoosterDefinition> database = Databases.GetDatabase <BoosterDefinition>(false);
                 if (database != null)
                 {
                     resourceTooltipData.Constructible = database.GetValue("Booster" + resourceDefinition.Name);
                 }
             }
             ageTooltip.Class      = resourceTooltipData.TooltipClass;
             ageTooltip.Content    = resourceDefinition.Name;
             ageTooltip.ClientData = resourceTooltipData;
             return;
         }
     }
     else if (this.Type == GuiDiplomaticTerm.TermType.Booster)
     {
         DiplomaticTermBoosterExchange diplomaticTermBoosterExchange = this.Term as DiplomaticTermBoosterExchange;
         BoosterDefinition             boosterDefinition;
         if (diplomaticTermBoosterExchange != null && Databases.GetDatabase <BoosterDefinition>(false).TryGetValue(diplomaticTermBoosterExchange.BoosterDefinitionName, out boosterDefinition))
         {
             GuiStackedBooster guiStackedBooster = new GuiStackedBooster(boosterDefinition);
             ageTooltip.Class      = guiStackedBooster.BoosterDefinition.TooltipClass;
             ageTooltip.Content    = guiStackedBooster.BoosterDefinition.Name;
             ageTooltip.ClientData = guiStackedBooster;
             return;
         }
     }
     else
     {
         if (this.Type == GuiDiplomaticTerm.TermType.Technology)
         {
             DepartmentOfScience.BuildTechnologyTooltip((this.Term as DiplomaticTermTechnologyExchange).TechnologyDefinition, this.Term.EmpireWhichProvides, ageTooltip, MultipleConstructibleTooltipData.TechnologyState.Normal);
             return;
         }
         if (this.Type == GuiDiplomaticTerm.TermType.Orb)
         {
             ageTooltip.Class      = "OrbResource";
             ageTooltip.Content    = "Orb";
             ageTooltip.ClientData = null;
             return;
         }
         ageTooltip.Class      = "Simple";
         ageTooltip.Content    = this.Description;
         ageTooltip.ClientData = this;
     }
 }