public override void Reset() { AILayer_AccountManager layer = this.aiEntityEmpire.GetLayer <AILayer_AccountManager>(); if (layer == null) { base.Enable = false; return; } this.economyAccount = layer.TryGetAccount(AILayer_AccountManager.EconomyAccountName); if (this.economyAccount == null) { Diagnostics.LogError("Can't get resource account credit."); base.Enable = false; return; } this.moneyAccountCredit = this.economyAccount.GetAvailableAmount(); this.moneyAccountRatio = this.economyAccount.CurrentProfitPercent; this.wantedMoney = this.economyAccount.WantedAmount; base.Reset(); if (!base.Enable) { return; } (base.ContextObject as AIPlayer_MajorEmpire).GetEntity <AIEntity_Empire>(); }
private SynchronousJobState SynchronousJob_ChangeEmpirePlan() { if (this.empirePlanClasses == null) { this.empirePlanMessages.Clear(); return(SynchronousJobState.Failure); } float num = 0f; AILayer_AccountManager layer = base.AIEntity.GetLayer <AILayer_AccountManager>(); Diagnostics.Assert(layer != null); Account account = layer.TryGetAccount(AILayer_AccountManager.EmpirePlanAccountName); if (account == null) { this.empirePlanMessages.Clear(); return(SynchronousJobState.Failure); } if (this.empirePlanMessages.Count != this.empirePlanClasses.Length) { Diagnostics.LogError("There must be one empire plan evaluable message by empire plan class."); this.empirePlanMessages.Clear(); return(SynchronousJobState.Failure); } for (int i = 0; i < this.empirePlanMessages.Count; i++) { EvaluableMessage_EmpirePlan evaluableMessage_EmpirePlan = this.empirePlanMessages[i]; if (this.departmentOfPlanification.IsEmpirePlanChoiced) { evaluableMessage_EmpirePlan.SetObtained(); } else { EmpirePlanDefinition empirePlanDefinition = this.departmentOfPlanification.GetEmpirePlanDefinition(evaluableMessage_EmpirePlan.EmpirePlanClass, evaluableMessage_EmpirePlan.EmpirePlanLevel); if (empirePlanDefinition != null) { float productionCostWithBonus = DepartmentOfTheTreasury.GetProductionCostWithBonus(base.AIEntity.Empire.SimulationObject, empirePlanDefinition, DepartmentOfTheTreasury.Resources.EmpirePoint); if (num + productionCostWithBonus <= account.PromisedAmount) { num += productionCostWithBonus; OrderChangeEmpirePlan order = new OrderChangeEmpirePlan(base.AIEntity.Empire.Index, empirePlanDefinition.EmpirePlanClass, empirePlanDefinition.EmpirePlanLevel); Ticket ticket; base.AIEntity.Empire.PlayerControllers.Client.PostOrder(order, out ticket, new EventHandler <TicketRaisedEventArgs>(this.OrderChangeEmpirePlan_TicketRaised)); } } } } this.empirePlanMessages.Clear(); return(SynchronousJobState.Success); }