Esempio n. 1
0
 private void RemoveSettlerResponse(object sender, TicketRaisedEventArgs args)
 {
     if (args.Result == PostOrderResponse.Processed)
     {
         City  city           = this.departmentOfTheInterior.Cities[this.cityWithRemovedSettlerIndex];
         float propertyValue  = city.GetPropertyValue(SimulationProperties.Population);
         float propertyValue2 = city.GetPropertyValue(SimulationProperties.CityGrowthStock);
         float num            = DepartmentOfTheInterior.ComputeGrowthLimit(city.Empire.SimulationObject, propertyValue);
         float num2           = DepartmentOfTheInterior.ComputeGrowthLimit(city.Empire.SimulationObject, propertyValue + 1f);
         float num3           = propertyValue2 / num;
         num3  = num2 * num3;
         num3 -= propertyValue2;
         if (num3 > 0f)
         {
             Diagnostics.Log("ELCP {0} Disbanded Settler in {1}, tranfering {2} food ({3} -> {4})", new object[]
             {
                 city.Empire,
                 city.LocalizedName,
                 num3,
                 propertyValue2,
                 propertyValue2 + num3
             });
             OrderTransferResources order = new OrderTransferResources(base.AIEntity.Empire.Index, DepartmentOfTheTreasury.Resources.CityGrowth, num3, city.GUID);
             base.AIEntity.Empire.PlayerControllers.AI.PostOrder(order);
         }
     }
     this.cityWithRemovedSettlerIndex = -1;
 }
Esempio n. 2
0
 public override bool Execute(City infiltratedCity, PlayerController playerController, out Ticket ticket, EventHandler <TicketRaisedEventArgs> ticketRaisedEventHandler, params object[] parameters)
 {
     ticket = null;
     if (playerController != null)
     {
         float num = this.ComputeAmountToSteal(infiltratedCity.Empire);
         OrderTransferResourcesByInfiltration order = new OrderTransferResourcesByInfiltration(playerController.Empire.Index, this.ResourceName, -num, infiltratedCity.GUID, this.Name);
         playerController.PostOrder(order);
         OrderTransferResources order2 = new OrderTransferResources(playerController.Empire.Index, this.ResourceName, num, 0UL);
         playerController.PostOrder(order2);
         return(true);
     }
     return(false);
 }
Esempio n. 3
0
 private void OrderSpawnArmy_TicketRaised(object sender, TicketRaisedEventArgs e)
 {
     if (e.Result == PostOrderResponse.Processed)
     {
         OrderSpawnArmy orderSpawnArmy = e.Order as OrderSpawnArmy;
         IGameEntity    gameEntity;
         if (this.gameEntityRepositoryService != null && this.gameEntityRepositoryService.TryGetValue(orderSpawnArmy.GameEntityGUID, out gameEntity) && gameEntity != null)
         {
             Army army = gameEntity as Army;
             if (army != null && army.StandardUnits.Count > 0)
             {
                 OrderTransferResources order = new OrderTransferResources(this.EmpireArmyOwner.Index, this.TransferResourceName, (float)this.TransferResourceAmount, army.StandardUnits[0].GUID);
                 this.EmpireArmyOwner.PlayerControllers.Server.PostOrder(order);
             }
         }
     }
 }
 protected override State Execute(QuestBehaviour questBehaviour, params object[] parameters)
 {
     if (!string.IsNullOrEmpty(this.ResourceName))
     {
         if (!string.IsNullOrEmpty(this.EmpireIndexVarName))
         {
             int num = -1;
             if (!questBehaviour.TryGetQuestVariableValueByName <int>(this.EmpireIndexVarName, out num))
             {
                 Diagnostics.LogError("Cannot retrieve quest variable (varname: '{0}')", new object[]
                 {
                     this.EmpireIndexVarName
                 });
                 return(State.Failure);
             }
             if (num != questBehaviour.Initiator.Index)
             {
                 return(State.Success);
             }
         }
         if (questBehaviour.Initiator is MajorEmpire && (questBehaviour.Initiator as MajorEmpire).ELCPIsEliminated)
         {
             return(State.Success);
         }
         if (this.ResourceName.Contains("Booster"))
         {
             for (int i = 0; i < this.Amount; i++)
             {
                 OrderBuyoutAndActivateBooster order = new OrderBuyoutAndActivateBooster(questBehaviour.Initiator.Index, this.ResourceName, 0UL, false);
                 questBehaviour.Initiator.PlayerControllers.Server.PostOrder(order);
             }
         }
         else
         {
             Order order2 = new OrderTransferResources(questBehaviour.Initiator.Index, this.ResourceName, (float)this.Amount, 0UL);
             questBehaviour.Initiator.PlayerControllers.Server.PostOrder(order2);
         }
     }
     return(State.Success);
 }