private void EventService_EventRaise(object sender, EventRaiseEventArgs e) { if (!base.AgeTransform.Visible) { return; } EventTechnologyEnded eventTechnologyEnded = e.RaisedEvent as EventTechnologyEnded; if (eventTechnologyEnded != null) { TechnologyDefinition technologyDefinition = eventTechnologyEnded.ConstructibleElement as TechnologyDefinition; if (technologyDefinition.Name == "TechnologyDefinitionMarketplaceHeroes" || technologyDefinition.Name == "TechnologyDefinitionMarketplaceMercenaries" || technologyDefinition.Name == "TechnologyDefinitionMarketplaceResources") { this.RefreshEmpireFilters(); this.RefreshContent(); } } EventHeroInfiltrated eventHeroInfiltrated = e.RaisedEvent as EventHeroInfiltrated; if (eventHeroInfiltrated != null) { this.RefreshEmpireFilters(); this.RefreshContent(); } EventHeroExfiltrated eventHeroExfiltrated = e.RaisedEvent as EventHeroExfiltrated; if (eventHeroExfiltrated != null) { this.RefreshEmpireFilters(); this.RefreshContent(); } }
private void FillDecisionMakerVariables() { if (this.decisionMaker.Context == null) { return; } this.decisionMaker.Context.Register("GlobalWarNeed", this.aiLayerDiplomacy.GetGlobalWarNeed()); this.decisionMaker.Context.Register("IndustryReferenceTurnCount", this.aiLayerResourceAmas.Amas.GetAgentCriticityMaxIntensity(AILayer_ResourceAmas.AgentNames.IndustryReferenceTurnCount)); this.decisionMaker.Context.Register("TechnologyReferenceTurnCount", this.aiLayerResourceAmas.Amas.GetAgentCriticityMaxIntensity(AILayer_ResourceAmas.AgentNames.TechnologyReferenceTurnCount)); this.decisionMaker.Context.Register("MoneyReferenceRatio", this.aiLayerResourceAmas.Amas.GetAgentCriticityMaxIntensity(AILayer_ResourceAmas.AgentNames.MoneyReferenceRatio)); int num = this.departmentOfScience.CurrentTechnologyEraNumber - 1; int num2 = 0; int num3 = 0; foreach (DepartmentOfScience.ConstructibleElement constructibleElement in this.departmentOfScience.TechnologyDatabase) { TechnologyDefinition technologyDefinition = constructibleElement as TechnologyDefinition; if (technologyDefinition != null) { int technologyEraNumber = DepartmentOfScience.GetTechnologyEraNumber(technologyDefinition); DepartmentOfScience.ConstructibleElement.State technologyState = this.departmentOfScience.GetTechnologyState(constructibleElement); if (technologyState == DepartmentOfScience.ConstructibleElement.State.Available) { num3++; if (technologyEraNumber < num) { num2++; } } } } float num4 = 0f; if (num3 > 0) { num4 = (float)num2 / (float)num3; } this.decisionMaker.Context.Register("OldTechnologyRatio", num4); AILayer_Strategy layer = base.AIEntity.GetLayer <AILayer_Strategy>(); float agentValue = layer.StrategicNetwork.GetAgentValue("Expansion"); this.decisionMaker.Context.Register("ColonizationPriority", agentValue); DepartmentOfTheInterior agency = base.AIEntity.Empire.GetAgency <DepartmentOfTheInterior>(); float num5 = 0f; if (agency.Cities.Count > 0) { for (int i = 0; i < agency.Cities.Count; i++) { AgentGroup cityAgentGroup = this.aiLayerResourceAmas.GetCityAgentGroup(agency.Cities[i]); if (cityAgentGroup != null) { num5 += cityAgentGroup.GetAgentCriticityMaxIntensity(AILayer_ResourceAmas.AgentNames.PopulationReferenceTurnCount); } } num5 /= (float)agency.Cities.Count; } this.decisionMaker.Context.Register("PopulationReferenceTurnCount", num5); }
private void InitializeAIEvaluableElement(SeasonEffectDefinition seasonEffectDefinition) { if (seasonEffectDefinition == null) { throw new ArgumentNullException("seasonEffect"); } Diagnostics.Assert(seasonEffectDefinition.Name != null); Diagnostics.Assert(this.aiParametersByElement != null); if (this.aiParametersByElement.ContainsKey(seasonEffectDefinition.Name)) { return; } List <IAIParameter <InterpreterContext> > list = new List <IAIParameter <InterpreterContext> >(); if (this.aiParameterDatabase != null && this.aiParameterDatabase.ContainsKey(seasonEffectDefinition.Name)) { AIParameterDatatableElement value = this.aiParameterDatabase.GetValue(seasonEffectDefinition.Name); if (value == null) { Diagnostics.LogWarning("Cannot retrieve ai parameters for constructible element '{0}'", new object[] { seasonEffectDefinition.Name }); return; } if (value.AIParameters == null) { Diagnostics.LogWarning("There aren't any parameters in aiParameters '{0}'", new object[] { seasonEffectDefinition.Name }); return; } for (int i = 0; i < value.AIParameters.Length; i++) { AIParameterDatatableElement.AIParameter aiparameter = value.AIParameters[i]; Diagnostics.Assert(aiparameter != null); list.Add(aiparameter.Instantiate()); } } if (this.orbUnlockDefinitions == null) { this.aiParametersByElement.Add(seasonEffectDefinition.Name, list.ToArray()); IEnumerable <DepartmentOfScience.ConstructibleElement> database = Databases.GetDatabase <DepartmentOfScience.ConstructibleElement>(false); List <TechnologyDefinition> list2 = new List <TechnologyDefinition>(); foreach (DepartmentOfScience.ConstructibleElement constructibleElement in database) { TechnologyDefinition technologyDefinition = constructibleElement as TechnologyDefinition; if (technologyDefinition != null && technologyDefinition.Visibility == TechnologyDefinitionVisibility.Visible && (technologyDefinition.TechnologyFlags & DepartmentOfScience.ConstructibleElement.TechnologyFlag.OrbUnlock) == DepartmentOfScience.ConstructibleElement.TechnologyFlag.OrbUnlock) { list2.Add(technologyDefinition); } } this.orbUnlockDefinitions = list2.ToArray(); } }
private void FocusOnTechnology(TechnologyDefinition technology) { List <ResearchEraFrame> children = this.ResearchErasTable.GetChildren <ResearchEraFrame>(true); for (int i = 0; i < children.Count; i++) { if (children[i].Technologies.Contains(technology)) { this.FocusOnEra(children[i].Era.EraNumber); this.OnSelectTechnology(children[i].GetTechnologyAgeTransform(technology)); break; } } }
public override bool IsConcernedByEvent(Event gameEvent, Army army) { if (army == null || army.Empire == null) { return(false); } EventTechnologyEnded eventTechnologyEnded = gameEvent as EventTechnologyEnded; if (eventTechnologyEnded != null && eventTechnologyEnded.Empire == army.Empire) { TechnologyDefinition technologyDefinition = eventTechnologyEnded.ConstructibleElement as TechnologyDefinition; if (technologyDefinition.Name == "TechnologyDefinitionMapActionArchaeology") { return(true); } } EventInteractionComplete eventInteractionComplete = gameEvent as EventInteractionComplete; return((eventInteractionComplete != null && eventInteractionComplete.InstigatorGUID == army.GUID) || base.IsConcernedByEvent(gameEvent, army)); }
private void RefreshCurrentResearch() { DepartmentOfScience agency = base.Empire.GetAgency <DepartmentOfScience>(); DepartmentOfTheTreasury agency2 = base.Empire.GetAgency <DepartmentOfTheTreasury>(); Construction construction = agency.ResearchQueue.Peek(); IDownloadableContentService service = Services.GetService <IDownloadableContentService>(); if (service != null && service.IsShared(DownloadableContent11.ReadOnlyName) && base.Empire.SimulationObject.Tags.Contains(FactionTrait.FactionTraitReplicants1)) { this.ResearchBuyoutButton.AgeTransform.Visible = true; this.ResearchBuyoutLabel.AgeTransform.Visible = true; this.CurrentResearchTitle.AgeTransform.Visible = false; this.EmpireResearchPanel.Enable = true; this.EmpireResearchPanel.AgeTooltip.Class = string.Empty; this.EmpireResearchPanel.AgeTooltip.Content = string.Empty; this.EmpireResearchPanel.AgeTooltip.ClientData = null; ConstructibleElement technology = null; if (this.departmentOfScience.ResearchQueue.Peek() != null) { technology = this.departmentOfScience.ResearchQueue.Peek().ConstructibleElement; } float buyOutTechnologyCost = this.departmentOfScience.GetBuyOutTechnologyCost(technology); float num = -buyOutTechnologyCost; string newValue = GuiFormater.FormatInstantCost(base.Empire, buyOutTechnologyCost, DepartmentOfTheTreasury.Resources.EmpireMoney, true, 0); string content; if (construction != null) { this.ResearchBuyoutLabel.AgeTransform.Alpha = 1f; TechnologyDefinition technologyDefinition = construction.ConstructibleElement as TechnologyDefinition; if (technologyDefinition != null) { AgeUtils.TruncateString(AgeLocalizer.Instance.LocalizeString(DepartmentOfScience.GetTechnologyTitle(technologyDefinition)), this.ResearchBuyoutLabel, out this.format, '.'); DepartmentOfScience.BuildTechnologyTooltip(technologyDefinition, base.Empire, this.ResearchBuyoutLabel.AgeTransform.AgeTooltip, MultipleConstructibleTooltipData.TechnologyState.Normal); } if (agency2.IsTransferOfResourcePossible(base.Empire, DepartmentOfTheTreasury.Resources.TechnologiesBuyOut, ref num) && this.interactionsAllowed) { this.ResearchBuyoutButton.AgeTransform.Enable = true; this.ResearchBuyoutButton.AgeTransform.Alpha = 1f; this.ResearchBuyoutLabel.Text = this.format; content = AgeLocalizer.Instance.LocalizeString("%ResearchBuyoutAvailableFormat").Replace("$Cost", newValue); } else { this.ResearchBuyoutButton.AgeTransform.Enable = false; this.ResearchBuyoutButton.AgeTransform.Alpha = 0.5f; this.ResearchBuyoutLabel.Text = this.format; content = AgeLocalizer.Instance.LocalizeString("%ResearchBuyoutUnavailableFormat").Replace("$Cost", newValue); } } else { this.ResearchBuyoutButton.AgeTransform.Enable = false; this.ResearchBuyoutButton.AgeTransform.Alpha = 0.5f; this.ResearchBuyoutLabel.Text = "%ResearchNoneTitle"; this.ResearchBuyoutLabel.AgeTransform.Alpha = 0.5f; content = AgeLocalizer.Instance.LocalizeString("%ResearchBuyoutNoSelection"); this.ResearchBuyoutLabel.AgeTransform.AgeTooltip.Class = string.Empty; this.ResearchBuyoutLabel.AgeTransform.AgeTooltip.Content = "%ResearchNoneDescription"; this.ResearchBuyoutLabel.AgeTransform.AgeTooltip.ClientData = null; } if (this.ResearchBuyoutButton.AgeTransform.AgeTooltip != null) { this.ResearchBuyoutButton.AgeTransform.AgeTooltip.Content = content; return; } } else { this.ResearchBuyoutButton.AgeTransform.Visible = false; this.ResearchBuyoutLabel.AgeTransform.Visible = false; this.CurrentResearchTitle.AgeTransform.Visible = true; if (construction != null) { this.EmpireResearchPanel.Enable = true; int num2 = agency2.ComputeConstructionRemainingTurn(base.Empire, construction); if (num2 == 2147483647) { this.format = string.Format("$Tech ({0})", GuiFormater.Infinite.ToString()); } else { this.format = string.Format("$Tech ({0})", QueueGuiItem.FormatNumberOfTurns(num2)); } TechnologyDefinition technologyDefinition2 = construction.ConstructibleElement as TechnologyDefinition; if (technologyDefinition2 != null) { AgeUtils.TruncateStringWithSubst(this.format, "$Tech", AgeLocalizer.Instance.LocalizeString(DepartmentOfScience.GetTechnologyTitle(technologyDefinition2)), this.CurrentResearchTitle, out this.format, '.'); this.CurrentResearchTitle.Text = this.format; DepartmentOfScience.BuildTechnologyTooltip(technologyDefinition2, base.Empire, this.EmpireResearchPanel.AgeTooltip, MultipleConstructibleTooltipData.TechnologyState.Normal); } } else { this.EmpireResearchPanel.Enable = false; AgeUtils.TruncateString(AgeLocalizer.Instance.LocalizeString("%ResearchNoneTitle"), this.CurrentResearchTitle, out this.format, '.'); this.CurrentResearchTitle.Text = this.format; this.EmpireResearchPanel.AgeTooltip.Class = string.Empty; this.EmpireResearchPanel.AgeTooltip.Content = "%ResearchNoneDescription"; this.EmpireResearchPanel.AgeTooltip.ClientData = null; } this.CurrentResearchTitle.Text = this.format; } }
public override bool Execute(Quest quest) { Diagnostics.Assert(quest != null); if (this.StepNumber >= 0 && this.StepNumber < quest.StepStates.Length) { quest.StepStates[this.StepNumber] = this.State; QuestState state = this.State; if (state != QuestState.InProgress) { if (state != QuestState.Completed || quest.QuestRewards == null) { return(true); } IGameService service = Services.GetService <IGameService>(); if (service == null || service.Game.Services.GetService <IGameEntityRepositoryService>() == null || service.Game.Services.GetService <IPlayerControllerRepositoryService>() == null) { return(true); } IQuestManagementService service2 = service.Game.Services.GetService <IQuestManagementService>(); if (service2 == null) { return(true); } List <QuestReward> list = new List <QuestReward>(quest.QuestRewards); list.RemoveAll((QuestReward reward) => reward.JustForShow); if (quest.QuestDefinition.GlobalWinner == GlobalQuestWinner.Participants) { List <QuestReward> list2 = (from reward in list where reward.StepNumber == this.StepNumber && reward.MinimumRank > 0 select reward).ToList <QuestReward>(); if (list2.Count > 0) { int num = 0; int rank = service2.GetGlobalQuestRank(quest, ref num, quest.QuestDefinition.Steps[this.StepNumber].Name) + 1; list2.RemoveAll((QuestReward reward) => reward.MinimumRank >= rank); for (int i = 0; i < list2.Count; i++) { list.Remove(list2[i]); } } } service2.AddStepRewards(quest.QuestDefinition, this.StepNumber, list, null, quest); Dictionary <StaticString, DroppableResource> dictionary = new Dictionary <StaticString, DroppableResource>(); for (int j = list.Count - 1; j >= 0; j--) { QuestReward questReward = list[j]; if (!questReward.Hidden && questReward.StepNumber == this.StepNumber && questReward.Droppables != null) { List <IDroppable> list3 = new List <IDroppable>(questReward.Droppables); for (int k = list3.Count - 1; k >= 0; k--) { DroppableResource droppableResource = list3[k] as DroppableResource; if (droppableResource != null) { if (dictionary.ContainsKey(droppableResource.ResourceName)) { dictionary[droppableResource.ResourceName].Quantity += droppableResource.Quantity; } else { dictionary.Add(droppableResource.ResourceName, new DroppableResource(droppableResource.ResourceName, droppableResource.Quantity)); } list3.RemoveAt(k); if (list3.Count == 0 && string.IsNullOrEmpty(questReward.LocalizationKey)) { list.RemoveAt(j); break; } } } questReward.Droppables = list3.ToArray(); } } List <QuestReward> list4 = list; int stepNumber = this.StepNumber; bool hidden = false; IDroppable[] array = dictionary.Select(delegate(KeyValuePair <StaticString, DroppableResource> kvp) { KeyValuePair <StaticString, DroppableResource> keyValuePair = kvp; return(keyValuePair.Value); }).ToArray <DroppableResource>(); list4.Add(new QuestReward(stepNumber, hidden, array, string.Empty, false, -1)); quest.QuestRewards = list.ToArray(); using (IEnumerator <QuestReward> enumerator = (from reward in quest.QuestRewards where reward.StepNumber == this.StepNumber select reward).GetEnumerator()) { while (enumerator.MoveNext()) { QuestReward questReward2 = enumerator.Current; if (questReward2.Droppables == null) { Diagnostics.LogWarning("Quest reward has no droppables."); } else { for (int l = 0; l < questReward2.Droppables.Length; l++) { if (questReward2.Droppables[l] != null) { IDroppableWithRewardAllocation droppableWithRewardAllocation = questReward2.Droppables[l] as IDroppableWithRewardAllocation; if (droppableWithRewardAllocation != null) { for (int m = 0; m < 32; m++) { if ((quest.EmpireBits & 1 << m) != 0) { try { global::Empire empire = (service.Game as global::Game).Empires[m]; if (!empire.SimulationObject.Tags.Contains(global::Empire.TagEmpireEliminated)) { droppableWithRewardAllocation.AllocateRewardTo(empire, new object[0]); } } catch { } } } } } } } } return(true); } } if (quest.QuestRewards != null) { IGameService service3 = Services.GetService <IGameService>(); if (service3 != null) { IQuestManagementService service4 = service3.Game.Services.GetService <IQuestManagementService>(); if (service4 != null) { global::Empire empire2 = null; for (int n = 0; n < 32; n++) { if ((quest.EmpireBits & 1 << n) != 0) { try { empire2 = (service3.Game as global::Game).Empires[n]; break; } catch { } } } if (empire2 != null) { bool flag = false; List <QuestReward> list5 = new List <QuestReward>(quest.QuestRewards); foreach (QuestReward questReward3 in from reward in quest.QuestRewards where reward.StepNumber == this.StepNumber select reward) { questReward3.Hidden = this.HideRewards; if (questReward3.Droppables != null) { foreach (IDroppable droppable in questReward3.Droppables) { if (droppable != null && droppable is DroppableReferenceTechnology) { TechnologyDefinition technologyDefinition = (droppable as DroppableReferenceTechnology).ConstructibleElement as TechnologyDefinition; if (technologyDefinition != null && empire2.GetAgency <DepartmentOfScience>().GetTechnologyState(technologyDefinition.Name) == DepartmentOfScience.ConstructibleElement.State.Researched) { list5.Remove(questReward3); flag = true; } } } } } if (flag) { foreach (QuestReward item in service4.ComputeRewards(quest, quest.QuestDefinition, this.StepNumber, null)) { if (!list5.Contains(item)) { list5.Add(item); } } quest.QuestRewards = list5.ToArray(); } } } } } return(true); } return(false); }
public override void RefreshContent() { base.RefreshContent(); base.Empire.Refresh(false); DepartmentOfScience agency = base.Empire.GetAgency <DepartmentOfScience>(); DepartmentOfTheTreasury agency2 = base.Empire.GetAgency <DepartmentOfTheTreasury>(); this.ComputeCurrentEraNumber(); this.CurrentEraNumber.Text = AgeUtils.ToRoman(this.currentEraNumber); this.ResearchErasTable.RefreshChildrenIList <ResearchEraFrame.TechnologyEra>(this.eras, this.refreshEraDelegate, true, false); Construction construction = agency.ResearchQueue.Peek(); bool flag = construction != null; float quantity; if (flag) { quantity = DepartmentOfTheTreasury.GetProductionCostWithBonus(base.Empire.SimulationObject, construction.ConstructibleElement, DepartmentOfTheTreasury.Resources.EmpireResearch); } else { quantity = agency.GetResearchPropertyValue(SimulationProperties.TechnologyCost); } this.TechnologyCostValue.Text = GuiFormater.FormatQuantity(quantity, SimulationProperties.EmpireResearch, 1); float quantity2; agency2.TryGetNetResourceValue(base.Empire.SimulationObject, DepartmentOfTheTreasury.Resources.EmpireResearch, out quantity2, false); this.EmpireOutputValue.Text = GuiFormater.FormatQuantity(quantity2, SimulationProperties.EmpireResearch, 0); if (flag) { float num = agency2.ComputeConstructionProgress(base.Empire, construction); this.ResearchProgress.Text = Mathf.RoundToInt(num * 100f).ToString() + "%"; int num2 = agency2.ComputeConstructionRemainingTurn(base.Empire, construction); num2 = Mathf.Max(num2, 1); if (num2 == 2147483647) { this.ResearchTurns.Text = GuiFormater.Infinite.ToString(); } else { this.ResearchTurns.Text = num2.ToString(); } TechnologyDefinition technologyDefinition = construction.ConstructibleElement as TechnologyDefinition; if (technologyDefinition != null) { this.TechnologyName.Text = DepartmentOfScience.GetTechnologyTitle(technologyDefinition); this.TechnologyImage.Image = DepartmentOfScience.GetTechnologyImage(technologyDefinition, GuiPanel.IconSize.Small); } DepartmentOfScience.BuildTechnologyTooltip(technologyDefinition, base.Empire, this.TechnologyName.AgeTransform.AgeTooltip, MultipleConstructibleTooltipData.TechnologyState.Normal); } else { this.TechnologyName.Text = "%ResearchNoneTitle"; this.TechnologyImage.Image = null; this.ResearchProgress.Text = "%ResearchVoidSymbol"; this.ResearchTurns.Text = "%ResearchVoidSymbol"; if (this.TechnologyName.AgeTransform.AgeTooltip != null) { this.TechnologyName.AgeTransform.AgeTooltip.Class = string.Empty; this.TechnologyName.AgeTransform.AgeTooltip.Content = string.Empty; this.TechnologyName.AgeTransform.AgeTooltip.ClientData = null; } if (this.TechnologyImage.AgeTransform.AgeTooltip != null) { this.TechnologyImage.AgeTransform.AgeTooltip.Class = string.Empty; this.TechnologyImage.AgeTransform.AgeTooltip.Content = string.Empty; this.TechnologyImage.AgeTransform.AgeTooltip.ClientData = null; } } IDownloadableContentService service = Services.GetService <IDownloadableContentService>(); if (service != null && service.IsShared(DownloadableContent11.ReadOnlyName) && base.Empire.SimulationObject.Tags.Contains(FactionTrait.FactionTraitReplicants1)) { this.TechnologyStatsGroup.Visible = false; this.ResearchBuyoutButton.AgeTransform.Visible = true; this.ResearchCompletionGroup.Visible = false; this.RefreshBuyout(this.ResearchBuyoutButton); return; } this.TechnologyStatsGroup.Visible = true; this.ResearchBuyoutButton.AgeTransform.Visible = false; this.ResearchCompletionGroup.Visible = true; }
public void SetupTechnology(global::Empire empire, TechnologyDefinition technologyDefinition, GameObject client) { this.empire = empire; this.TechnologyDefinition = technologyDefinition; this.selectionClient = client; if (this.TagsList == null) { this.TagsList = new List <string>(); } else { this.TagsList.Clear(); } if (this.empire == null) { return; } this.BuildTags(); if (technologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.Quest)) { this.EraLabel.Text = string.Empty; AgePrimitiveLabel eraLabel = this.EraLabel; eraLabel.Text += (char)this.QuestCharNumber; } else if (technologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.Medal)) { this.EraLabel.Text = string.Empty; AgePrimitiveLabel eraLabel2 = this.EraLabel; eraLabel2.Text += (char)this.MedalCharNumber; } else if (technologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.Affinity)) { this.EraLabel.Text = string.Empty; AgePrimitiveLabel eraLabel3 = this.EraLabel; eraLabel3.Text += GuiEmpire.GetFactionSymbolString(this.empire, this.empire); } else if (technologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.OrbUnlock)) { this.EraLabel.Text = string.Empty; } else if (technologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.KaijuUnlock)) { this.EraLabel.Text = string.Empty; } else { int technologyEraNumber = DepartmentOfScience.GetTechnologyEraNumber(technologyDefinition); if (technologyEraNumber > 0) { this.EraLabel.Text = AgeUtils.ToRoman(technologyEraNumber); } else { this.EraLabel.Text = "-"; } } this.GlowImage.AgeTransform.Visible = false; IDownloadableContentService service = Services.GetService <IDownloadableContentService>(); if (service != null && service.IsShared(DownloadableContent9.ReadOnlyName) && technologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.Unique)) { this.GlowImage.AgeTransform.Visible = true; } if (this.UnlockImage != null) { this.UnlockImage.Image = DepartmentOfScience.GetTechnologyImage(technologyDefinition, global::GuiPanel.IconSize.Small); } this.CategoryIcon.Image = DepartmentOfScience.GetCategoryIcon(technologyDefinition, global::GuiPanel.IconSize.Small); this.CategoryFullIcon.Image = this.CategoryIcon.Image; if (this.SubCategoryIcon.Image != null) { this.CategoryIcon.AgeTransform.PixelOffsetLeft = -this.CategoryIcon.AgeTransform.Width; this.CategoryFullIcon.AgeTransform.PixelOffsetLeft = -this.CategoryFullIcon.AgeTransform.Width; } else { this.CategoryIcon.AgeTransform.PixelOffsetLeft = -(0.5f * this.CategoryIcon.AgeTransform.Width); this.CategoryFullIcon.AgeTransform.PixelOffsetLeft = -(0.5f * this.CategoryFullIcon.AgeTransform.Width); } this.SubCategoryIcon.Image = DepartmentOfScience.GetSubCategoryIcon(technologyDefinition, global::GuiPanel.IconSize.Small); this.SubCategoryFullIcon.Image = this.SubCategoryIcon.Image; DepartmentOfScience.BuildTechnologyTooltip(technologyDefinition, this.empire, this.AgeTransform.AgeTooltip, MultipleConstructibleTooltipData.TechnologyState.Normal); this.InProgressSector.TintColor = this.InProgressColor; this.MarkupGroup.Visible = false; DepartmentOfScience agency = empire.GetAgency <DepartmentOfScience>(); DepartmentOfScience.ConstructibleElement.State technologyState = agency.GetTechnologyState(technologyDefinition); this.Refresh(empire, technologyState); }
protected override void EvaluateNeeds(StaticString context, StaticString pass) { base.EvaluateNeeds(context, pass); if (!this.CanUseAltar()) { return; } if (!this.seasonService.IsAlive || this.seasonService.Target == null) { return; } Season winterSeason = this.seasonService.Target.GetWinterSeason(); if (this.seasonService.Target.IsCurrentSeason(winterSeason)) { return; } global::Game game = Services.GetService <IGameService>().Game as global::Game; List <SeasonEffect> candidateEffectsForSeasonType = this.seasonService.Target.GetCandidateEffectsForSeasonType(Season.ReadOnlyWinter); Diagnostics.Assert(this.elementEvaluator != null); this.decisions.Clear(); this.RegisterInterpreterContextData(); if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools) { EvaluationData <SeasonEffect, InterpreterContext> evaluationData = new EvaluationData <SeasonEffect, InterpreterContext>(); this.elementEvaluator.Evaluate(candidateEffectsForSeasonType, ref this.decisions, evaluationData); evaluationData.Turn = game.Turn; this.SeasonEffectsEvaluationDataHistoric.Add(evaluationData); } else { this.elementEvaluator.Evaluate(candidateEffectsForSeasonType, ref this.decisions, null); } if (this.decisions.Count <= 0) { return; } int num = 0; int num2 = 0; for (int i = 0; i < candidateEffectsForSeasonType.Count; i++) { SeasonEffect seasonEffect = candidateEffectsForSeasonType[i]; int seasonEffectDisplayedScoreForEmpire = this.seasonService.Target.GetSeasonEffectDisplayedScoreForEmpire(base.AIEntity.Empire, seasonEffect); if (seasonEffectDisplayedScoreForEmpire > num) { num = seasonEffectDisplayedScoreForEmpire; num2 = 1; } else if (seasonEffectDisplayedScoreForEmpire == num) { num2++; } } DecisionResult decisionResult = this.decisions[0]; float score = decisionResult.Score; float score2 = this.decisions[this.decisions.Count - 1].Score; float num3 = score - score2; num3 = Mathf.Clamp01(num3 / this.maximumGainFromXml); SeasonEffect seasonEffect2 = decisionResult.Element as SeasonEffect; Diagnostics.Assert(seasonEffect2 != null); int seasonEffectScore = this.seasonService.Target.GetSeasonEffectScore(seasonEffect2); if (seasonEffectScore == num && num2 == 1) { return; } int neededVoteCount = num - seasonEffectScore + 1; List <EvaluableMessage_VoteForSeasonEffect> list = new List <EvaluableMessage_VoteForSeasonEffect>(base.AIEntity.AIPlayer.Blackboard.GetMessages <EvaluableMessage_VoteForSeasonEffect>(BlackboardLayerID.Empire, (EvaluableMessage_VoteForSeasonEffect message) => message.EvaluationState != EvaluableMessage.EvaluableMessageState.Obtained && message.EvaluationState != EvaluableMessage.EvaluableMessageState.Cancel)); EvaluableMessage_VoteForSeasonEffect evaluableMessage_VoteForSeasonEffect; if (list.Count == 0) { evaluableMessage_VoteForSeasonEffect = new EvaluableMessage_VoteForSeasonEffect(seasonEffect2.SeasonEffectDefinition.Name, 1, AILayer_AccountManager.OrbAccountName); base.AIEntity.AIPlayer.Blackboard.AddMessage(evaluableMessage_VoteForSeasonEffect); } else { evaluableMessage_VoteForSeasonEffect = list[0]; if (seasonEffect2.SeasonEffectDefinition.Name != evaluableMessage_VoteForSeasonEffect.SeasonEffectReference) { Diagnostics.Log("AI don't want to vote for the season effect {0} anymore. AI now wants season effect {1}.", new object[] { evaluableMessage_VoteForSeasonEffect.SeasonEffectReference, seasonEffect2.SeasonEffectDefinition.Name }); evaluableMessage_VoteForSeasonEffect.Cancel(); evaluableMessage_VoteForSeasonEffect = new EvaluableMessage_VoteForSeasonEffect(seasonEffect2.SeasonEffectDefinition.Name, 1, AILayer_AccountManager.OrbAccountName); base.AIEntity.AIPlayer.Blackboard.AddMessage(evaluableMessage_VoteForSeasonEffect); } } float num4 = this.seasonService.Target.ComputePrayerOrbCost(base.AIEntity.Empire); float num5 = 10f * base.AIEntity.Empire.GetPropertyValue(SimulationProperties.GameSpeedMultiplier); int num6 = this.seasonService.Target.GetExactSeasonStartTurn(winterSeason) - game.Turn; float num7 = Mathf.Clamp01((num5 - (float)num6) / num5); float num8 = num3 * (0.5f + num7 / 2f); num8 = Mathf.Clamp01(num8); int num9 = this.ComputeWantedNumberOfOrbs(neededVoteCount); DepartmentOfScience agency = base.AIEntity.Empire.GetAgency <DepartmentOfScience>(); float num10 = 0f; float num11 = 0f; for (int j = 0; j < this.orbUnlockDefinitions.Length; j++) { TechnologyDefinition technologyDefinition = this.orbUnlockDefinitions[j]; if (DepartmentOfTheTreasury.CheckConstructiblePrerequisites(base.AIEntity.Empire, technologyDefinition, new string[] { ConstructionFlags.Prerequisite })) { DepartmentOfScience.ConstructibleElement.State technologyState = agency.GetTechnologyState(technologyDefinition); if (technologyState != DepartmentOfScience.ConstructibleElement.State.Researched && technologyState != DepartmentOfScience.ConstructibleElement.State.NotAvailable) { num11 += 1f; } else if (technologyState == DepartmentOfScience.ConstructibleElement.State.Researched) { num10 += 1f; } } } float num12 = num11 / (num11 + num10); num12 = Mathf.Min(1f, Mathf.Max(0f, 2f * num12 - 0.6f)); if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools) { Diagnostics.Log("[ELCP: AILayer_Altar] {0} has reasearched {1} of {2} Orb Techs", new object[] { base.AIEntity.Empire, num10, num11 + num10 }); Diagnostics.Log("... Season Effect Voting score altered from {0} to {1}", new object[] { num8, num8 * num12 }); } evaluableMessage_VoteForSeasonEffect.VoteCount = num9; evaluableMessage_VoteForSeasonEffect.Refresh(0.5f, num8 * num12, (float)num9 * num4, int.MaxValue); }