private int GetSettlerCount() { int num = 0; for (int i = 0; i < this.departmentOfDefense.Armies.Count; i++) { num += this.GetSettlerCount(this.departmentOfDefense.Armies[i]); } for (int j = 0; j < this.departmentOfTheInterior.Cities.Count; j++) { num += this.GetSettlerCount(this.departmentOfTheInterior.Cities[j]); if (this.departmentOfTheInterior.Cities[j].Camp != null) { num += this.GetSettlerCount(this.departmentOfTheInterior.Cities[j].Camp); } ConstructionQueue constructionQueue = this.departmentOfIndustry.GetConstructionQueue(this.departmentOfTheInterior.Cities[j]); if (constructionQueue != null) { for (int k = constructionQueue.Length - 1; k >= 0; k--) { if (constructionQueue.PeekAt(k).ConstructibleElementName.ToString().Contains("Settler")) { num++; } } } } return(num); }
private bool CanAffordTechs() { ConstructionQueue constructionQueueForEmpire = this.kaijuTechsService.GetConstructionQueueForEmpire(base.Empire); Dictionary <string, float> dictionary = new Dictionary <string, float>(); for (int i = 0; i < constructionQueueForEmpire.Length; i++) { ConstructibleElement constructibleElement = constructionQueueForEmpire.PeekAt(i).ConstructibleElement; for (int j = 0; j < constructibleElement.Costs.Length; j++) { string key = constructibleElement.Costs[j].ResourceName; float num = -constructibleElement.Costs[j].GetValue(base.Empire); if (!dictionary.ContainsKey(constructibleElement.Costs[j].ResourceName)) { dictionary.Add(constructibleElement.Costs[j].ResourceName, num); } else { num += dictionary[key]; dictionary[key] = num; } } } foreach (KeyValuePair <string, float> keyValuePair in dictionary) { float value = keyValuePair.Value; if (!this.departmentOfTheTreasury.IsTransferOfResourcePossible(base.Empire, keyValuePair.Key, ref value)) { return(false); } } return(true); }
private void OnSelectOrbUnlockCB(GameObject obj) { if (this.empire == null) { Diagnostics.LogError("Empire is null"); return; } DepartmentOfScience agency = this.empire.GetAgency <DepartmentOfScience>(); DepartmentOfScience.ConstructibleElement.State technologyState = agency.GetTechnologyState(this.TechnologyDefinition); ConstructionQueue constructionQueueForTech = agency.GetConstructionQueueForTech(this.TechnologyDefinition); if (technologyState == DepartmentOfScience.ConstructibleElement.State.Available && agency.OrbUnlockQueue.Length < 2) { this.AgeTransform.Enable = false; if (agency.OrbUnlockQueue.Length > 0) { Construction construction = constructionQueueForTech.Peek(); this.CancelResearch(construction); } this.QueueResearch(); this.selectionClient.SendMessage("OnSelectTechnology", this.AgeTransform, SendMessageOptions.RequireReceiver); } else if (technologyState == DepartmentOfScience.ConstructibleElement.State.InProgress || technologyState == DepartmentOfScience.ConstructibleElement.State.Queued) { this.AgeTransform.Enable = false; Construction construction2 = constructionQueueForTech.Get(this.TechnologyDefinition); this.CancelResearch(construction2); this.selectionClient.SendMessage("OnSelectTechnology", this.AgeTransform, SendMessageOptions.RequireReceiver); } }
private void Start() { Instance = this; isBuildCoroutineRunning = false; displayQueues = GetComponent <DisplayQueues>(); buildQueues = new List <ShopQueue>(); }
public ConstructionQueue GetConstructionQueueForEmpire(Empire empire) { ConstructionQueue result = null; if (!this.researchQueues.TryGetValue(empire.Index, out result)) { Diagnostics.LogError("The provided empire does not have a construction queue. Make sure one is created."); } return(result); }
public void EmptyConstructionQueueForEmpire(Empire empire) { IPlayerControllerRepositoryService service = base.Game.Services.GetService <IPlayerControllerRepositoryService>(); ConstructionQueue constructionQueueForEmpire = this.GetConstructionQueueForEmpire(empire); for (int i = constructionQueueForEmpire.Length - 1; i >= 0; i--) { Construction construction = constructionQueueForEmpire.PeekAt(i); OrderCancelKaijuResearch order = new OrderCancelKaijuResearch(empire.Index, construction.GUID); service.ActivePlayerController.PostOrder(order); } }
private bool CheckPointOfInterestImprovementPrerequisites(PointOfInterestImprovementDefinition pointOfInterestImprovementDefinition, ref List <StaticString> failureFlags) { if (this.lastFailureFlags.Contains(ConstructionFlags.Discard)) { return(false); } IWorldPositionningService service = base.Game.Services.GetService <IWorldPositionningService>(); if (service == null) { this.lastFailureFlags.Add(ConstructionFlags.Discard); return(false); } DepartmentOfIndustry agency = this.City.Empire.GetAgency <DepartmentOfIndustry>(); if (agency == null) { this.lastFailureFlags.Add(ConstructionFlags.Discard); return(false); } ConstructionQueue constructionQueue = agency.GetConstructionQueue(this.City); if (constructionQueue == null) { this.lastFailureFlags.Add(ConstructionFlags.Discard); return(false); } int num = constructionQueue.Count(pointOfInterestImprovementDefinition); int num2 = 0; for (int i = 0; i < this.city.Region.PointOfInterests.Length; i++) { PointOfInterest pointOfInterest = this.city.Region.PointOfInterests[i]; if (!(pointOfInterest.PointOfInterestDefinition.PointOfInterestTemplateName != pointOfInterestImprovementDefinition.PointOfInterestTemplateName)) { if (pointOfInterest.PointOfInterestImprovement == null) { int explorationBits = service.GetExplorationBits(pointOfInterest.WorldPosition); if ((explorationBits & this.city.Empire.Bits) != 0) { num2++; } } } } if (num2 <= num) { this.lastFailureFlags.Add(ConstructionFlags.Discard); return(false); } return(true); }
private void BindShipListView(IEnumerable <IDesign> designs) { lstShips.Initialize(32, 32); foreach (var design in designs.Where(d => ConstructionQueue.CanConstruct(d)).OrderBy(d => d.Role).ThenBy(d => d.Name).ThenBy(d => d.Iteration)) { var eta = design.Cost.Keys.Max(res => (double)(design.Cost[res]) / (double)ConstructionQueue.Rate[res]); var x = lstShips.AddItemWithImage(design.Role, design.Name, design, design.Icon, null, eta.CeilingString(1)); if (design.IsObsolete) { x.ForeColor = Color.Gray; } else if (design.IsObsolescent) { x.ForeColor = Color.Yellow; } } }
public DepartmentOfScience.ConstructibleElement.State GetTechnologyState(ConstructibleElement technology, Empire empire) { if (technology == null) { throw new ArgumentNullException("technology"); } ConstructionQueue constructionQueue = null; if (!this.researchQueues.TryGetValue(empire.Index, out constructionQueue)) { Diagnostics.LogError("The provided empire does not have a construction queue. Make sure one is created."); return(DepartmentOfScience.ConstructibleElement.State.NotAvailable); } if (this.researchedTechNames.Contains(technology.Name)) { if (empire is MajorEmpire && !DepartmentOfTheTreasury.CheckConstructiblePrerequisites(empire, technology, new string[] { ConstructionFlags.Prerequisite })) { return(DepartmentOfScience.ConstructibleElement.State.ResearchedButUnavailable); } return(DepartmentOfScience.ConstructibleElement.State.Researched); } else { Diagnostics.Assert(constructionQueue != null); Construction construction = constructionQueue.Get(technology); if (construction != null && construction.ConstructibleElement.Name == technology.Name) { return(DepartmentOfScience.ConstructibleElement.State.InProgress); } if (constructionQueue.Contains(technology)) { return(DepartmentOfScience.ConstructibleElement.State.Queued); } if (!DepartmentOfTheTreasury.CheckConstructiblePrerequisites(empire, technology, new string[] { ConstructionFlags.Prerequisite })) { return(DepartmentOfScience.ConstructibleElement.State.NotAvailable); } return(DepartmentOfScience.ConstructibleElement.State.Available); } }
void Start() { constrQueue = GetComponent <ConstructionQueue>(); string color = ""; if (PhotonNetwork.IsConnected) { Hashtable hashPlayer = PhotonNetwork.LocalPlayer.CustomProperties; color = (string)hashPlayer["Color"]; } else { color = "Blue"; } DrawAttackSpaceship(color); DrawDefenceSpaceship(color); DrawMiningSpaceship(color); }
public ConstructionQueueForm(ConstructionQueue queue) { InitializeComponent(); ConstructionQueue = queue; try { this.Icon = new Icon(FrEee.WinForms.Properties.Resources.FrEeeIcon); } catch { } // setup command list newCommands = new List <ICommand>(); removedCommands = new List <ICommand>(); wasOnHold = chkOnHold.Checked = queue.AreOrdersOnHold; wasRepeat = chkRepeat.Checked = queue.AreRepeatOrdersEnabled; lblSpaceportWarning.Visible = queue.IsColonyQueue && !queue.Colony.Container.StarSystem.HasAbility("Spaceport") && queue.Colony.MerchantsRatio < 1; }
private void OnApplyCB(GameObject obj) { ConstructionQueue constructionQueueForEmpire = this.kaijuTechsService.GetConstructionQueueForEmpire(base.Empire); if (constructionQueueForEmpire != null) { for (int i = constructionQueueForEmpire.Length - 1; i >= 0; i--) { this.buyoutButton.AgeTransform.Enable = false; Construction construction = constructionQueueForEmpire.PeekAt(i); if (construction == null) { return; } OrderBuyOutKaijuTechnology order = new OrderBuyOutKaijuTechnology(base.Empire.Index, construction.ConstructibleElement.Name); base.PlayerController.PostOrder(order); } } }
private void OnTechnologyBuyoutCB(GameObject obj) { ConstructionQueue constructionQueueForEmpire = this.KaijuTechsService.GetConstructionQueueForEmpire(base.Empire); if (constructionQueueForEmpire != null) { int length = constructionQueueForEmpire.Length; for (int i = length - 1; i >= 0; i--) { Construction construction = constructionQueueForEmpire.PeekAt(i); if (construction == null) { return; } OrderBuyOutKaijuTechnology order = new OrderBuyOutKaijuTechnology(base.Empire.Index, construction.ConstructibleElement.Name); base.PlayerController.PostOrder(order); } } }
private void ConstructionQueue_CollectionChanged(object sender, CollectionChangeEventArgs e) { ConstructionQueue constructionQueue = this.departmentOfIndustry.GetConstructionQueue(this.aiEntityCity.City); if (constructionQueue != null && constructionQueue.Length > 0) { UnitDesign unitDesign = constructionQueue.Peek().ConstructibleElement as UnitDesign; if (unitDesign != null && this.IsActive() && unitDesign.UnitBodyDefinition != null && unitDesign.UnitBodyDefinition.Tags.Contains(AILayer_Population.Settler) && this.resourceScore[0] > 0f) { this.resourceScore[1] += this.resourceScore[0]; this.resourceScore[0] = 0f; if (this.assignedPopulationThisTurn) { this.assignedPopulationThisTurn = false; AIScheduler.Services.GetService <ISynchronousJobRepositoryAIHelper>().RegisterSynchronousJob(new SynchronousJob(this.SynchronousJob_AssignPopulation)); } } } }
public virtual void ReadXml(XmlReader reader) { int num = reader.ReadVersionAttribute(); reader.ReadStartElement(); this.researchQueues.Clear(); int num2 = reader.ReadElementString <int>("QueuesCount"); reader.ReadStartElement("ResearchQueues"); for (int i = 0; i < num2; i++) { reader.ReadStartElement("Queue"); int key = reader.ReadElementString <int>("EmpireIndex"); ConstructionQueue constructionQueue = new ConstructionQueue(); Amplitude.Xml.Serialization.IXmlSerializable xmlSerializable = constructionQueue; reader.ReadElementSerializable <Amplitude.Xml.Serialization.IXmlSerializable>("Researches", ref xmlSerializable); for (int j = constructionQueue.Length - 1; j >= 0; j--) { Construction construction = constructionQueue.PeekAt(j); if (construction.ConstructibleElement == null) { Diagnostics.LogWarning("Compatibility issue, constructible element (name: '{0}') is null.", new object[] { construction.ConstructibleElementName }); constructionQueue.Remove(construction); } } this.researchQueues.Add(key, constructionQueue); reader.ReadEndElement("Queue"); } reader.ReadEndElement("ResearchQueues"); int num3 = reader.ReadElementString <int>("ResearchedTechsCount"); reader.ReadStartElement("ResearchedTechs"); for (int k = 0; k < num3; k++) { this.researchedTechNames.Add(reader.ReadElementString("TechName")); } reader.ReadEndElement("ResearchedTechs"); }
private void RefreshCosts() { ConstructionQueue constructionQueueForEmpire = this.kaijuTechsService.GetConstructionQueueForEmpire(base.Empire); ConstructibleElement constructibleElement = null; if (constructionQueueForEmpire.Peek() != null) { constructibleElement = constructionQueueForEmpire.Peek().ConstructibleElement; } int num = 0; string text; PanelFeatureCost.ComputeCostAndTurn(base.GuiService, constructionQueueForEmpire.PendingConstructions, this.departmentOfTheTreasury, base.Empire, out text, out num); if (constructibleElement != null) { if (this.CanAffordTechs()) { this.buyoutCostLabel.Text = text; this.buyoutButton.AgeTransform.Enable = true; this.buyoutButton.AgeTransform.Alpha = 1f; string text2 = AgeLocalizer.Instance.LocalizeString("%KaijuUnlockBuyoutAvailableFormat").Replace("$Cost", text); } else { this.buyoutCostLabel.Text = text; this.buyoutButton.AgeTransform.Enable = false; this.buyoutButton.AgeTransform.Alpha = 0.5f; string text2 = AgeLocalizer.Instance.LocalizeString("%KaijuUnlockBuyoutUnavailableFormat").Replace("$Cost", text); } } else { this.buyoutButton.AgeTransform.Enable = false; this.buyoutButton.AgeTransform.Alpha = 0.5f; this.buyoutCostLabel.Text = "%ResearchVoidSymbol"; string text2 = AgeLocalizer.Instance.LocalizeString("%KaijuUnlockBuyoutNoSelectionDescription"); } }
private void BindFacilityListView(IEnumerable <FacilityTemplate> templates) { int i = 0; var ilFacil = new ImageList(); ilFacil.ImageSize = new Size(32, 32); lstFacilities.LargeImageList = ilFacil; lstFacilities.SmallImageList = ilFacil; lstFacilities.Items.Clear(); foreach (var facil in templates.OrderBy(f => f.Group).ThenBy(f => f.Name)) // TODO - roman numeral sorting { if (ConstructionQueue.CanConstruct(facil)) { var group = lstFacilities.Groups.Cast <ListViewGroup>().SingleOrDefault(g => g.Header == facil.Group); if (group == null) { group = new ListViewGroup(facil.Group); lstFacilities.Groups.Add(group); } var item = new ListViewItem(facil.Name, i, group); item.ImageIndex = i; item.Tag = facil; var eta = facil.Cost.Keys.Max(res => (double)(facil.Cost[res]) / (double)ConstructionQueue.Rate[res]); item.SubItems.Add(new ListViewItem.ListViewSubItem(item, eta.CeilingString(1))); ilFacil.Images.Add(facil.Icon); lstFacilities.Items.Add(item); if (facil.IsObsolete) { item.ForeColor = Color.Gray; } else if (facil.IsObsolescent) { item.ForeColor = Color.Yellow; } i++; } } }
private void OnSelectTechnologyCB(GameObject obj) { if (this.empire == null) { Diagnostics.LogError("Empire is null"); return; } DepartmentOfScience agency = this.empire.GetAgency <DepartmentOfScience>(); DepartmentOfScience.ConstructibleElement.State technologyState = agency.GetTechnologyState(this.TechnologyDefinition); ConstructionQueue constructionQueueForTech = agency.GetConstructionQueueForTech(this.TechnologyDefinition); if (technologyState == DepartmentOfScience.ConstructibleElement.State.Available) { this.AgeTransform.Enable = false; if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools && Input.GetKey(KeyCode.G)) { this.ForceUnlockTechnology(); } else { this.QueueResearch(); } this.selectionClient.SendMessage("OnSelectTechnology", this.AgeTransform, SendMessageOptions.RequireReceiver); return; } if (technologyState == DepartmentOfScience.ConstructibleElement.State.InProgress || technologyState == DepartmentOfScience.ConstructibleElement.State.Queued) { this.AgeTransform.Enable = false; Construction construction = constructionQueueForTech.Get(this.TechnologyDefinition); this.CancelResearch(construction); if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools && Input.GetKey(KeyCode.G)) { this.ForceUnlockTechnology(); } this.selectionClient.SendMessage("OnSelectTechnology", this.AgeTransform, SendMessageOptions.RequireReceiver); } }
public void UnlockTechnology(ConstructibleElement technology, Empire empire) { if (technology == null) { throw new ArgumentNullException("technology"); } if (this.GetTechnologyState(technology, empire) == DepartmentOfScience.ConstructibleElement.State.Researched) { return; } ConstructionQueue constructionQueueForEmpire = this.GetConstructionQueueForEmpire(empire); if (constructionQueueForEmpire.Contains(technology)) { constructionQueueForEmpire.Remove(technology); } this.researchedTechNames.Add(technology.Name); this.researchedTechs.Add(technology); if (this.KaijuTechnologyUnlocked != null) { this.KaijuTechnologyUnlocked(this, new ConstructibleElementEventArgs(technology)); } }
private void OnSelectKaijuUnlockCB(GameObject obj) { if (this.empire == null) { Diagnostics.LogError("Empire is null"); return; } IGameService service = Services.GetService <IGameService>(); if (service == null || service.Game == null) { Diagnostics.LogError("GameService or GameService.Game is null"); return; } IKaijuTechsService service2 = service.Game.Services.GetService <IKaijuTechsService>(); DepartmentOfScience.ConstructibleElement.State technologyState = service2.GetTechnologyState(this.TechnologyDefinition, this.empire); ConstructionQueue constructionQueueForEmpire = service2.GetConstructionQueueForEmpire(this.empire); if (constructionQueueForEmpire == null) { return; } if (technologyState == DepartmentOfScience.ConstructibleElement.State.Available) { this.AgeTransform.Enable = false; this.QueueResearch(); this.selectionClient.SendMessage("OnSelectTechnology", this.AgeTransform, SendMessageOptions.RequireReceiver); } else if (technologyState == DepartmentOfScience.ConstructibleElement.State.InProgress || technologyState == DepartmentOfScience.ConstructibleElement.State.Queued) { this.AgeTransform.Enable = false; Construction construction = constructionQueueForEmpire.Get(this.TechnologyDefinition); this.CancelResearch(construction); this.selectionClient.SendMessage("OnSelectTechnology", this.AgeTransform, SendMessageOptions.RequireReceiver); } }
private void BindUpgradeListView(IEnumerable <FacilityTemplate> templates) { int i = 0; var ilFacil = new ImageList(); ilFacil.ImageSize = new Size(32, 32); lstUpgrades.LargeImageList = ilFacil; lstUpgrades.SmallImageList = ilFacil; lstUpgrades.Items.Clear(); if (ConstructionQueue.Colony != null) { foreach (var g in ConstructionQueue.Colony.Facilities.GroupBy(f => f.Template).OrderBy(g => g.Key.Group).ThenBy(g => g.Key.Name)) // TODO - roman numeral sorting { var oldf = g.Key; // facilites which are not yet upgraded var count = g.Count() - ConstructionQueue.Orders.OfType <UpgradeFacilityOrder>().Where(o => o.Upgrade.Old == oldf).Count(); if (count > 0) { foreach (var newf in templates) { if (ConstructionQueue.CanConstruct(newf)) { var group = lstFacilities.Groups.Cast <ListViewGroup>().SingleOrDefault(g2 => g2.Header == newf.Group); if (newf.Family.Value == oldf.Family.Value && newf.ModID != oldf.ModID) { if (group == null) { group = new ListViewGroup(newf.Group); lstUpgrades.Groups.Add(group); } string name; if (count == 1) { name = oldf.Name; } else { name = count + "x " + oldf.Name; } var item = new ListViewItem(name + " to " + newf.Name, i, group); item.ImageIndex = i; var fu = new FacilityUpgrade(oldf, newf); item.Tag = fu; var cost = newf.Cost * Mod.Current.Settings.UpgradeFacilityPercentCost / 100; var eta = cost.Keys.Max(res => (double)(cost[res]) / (double)ConstructionQueue.Rate[res]); item.SubItems.Add(new ListViewItem.ListViewSubItem(item, eta.CeilingString(1))); ilFacil.Images.Add(newf.Icon); lstUpgrades.Items.Add(item); if (fu.IsObsolete) { item.ForeColor = Color.Gray; } else if (fu.IsObsolescent) { item.ForeColor = Color.Yellow; } i++; } } } } } } }
protected override void CreateLocalNeeds(StaticString context, StaticString pass) { base.CreateLocalNeeds(context, pass); float propertyValue = this.Empire.GetPropertyValue(SimulationProperties.MinorFactionSlotCount); int count = this.departmentOfTheInterior.AssimilatedFactions.Count; bool flag = false; if (propertyValue <= (float)count) { flag = true; if (this.game.Turn - 14 <= this.lastAssimilationTurn) { return; } } List <MinorFaction> list = new List <MinorFaction>(); this.departmentOfTheInterior.GetAssimilableMinorFactions(ref list); if (list.Count == 0) { return; } this.UpdateUnitCategories(); this.FactionToDeassimilate = string.Empty; int num = -1; float num2 = 0f; UnitBodyDefinition[] values = this.unitBodyDefinitionDatabase.GetValues(); int index = -1; float num3 = float.MaxValue; for (int i = 0; i < list.Count; i++) { Faction faction = list[i]; bool flag2 = this.departmentOfTheInterior.IsAssimilated(faction); float num4; if (this.MinorfactionScores.TryGetValue(faction.Name, out num4)) { float num5 = (float)this.departmentOfTheInterior.GetNumberOfOwnedMinorFactionVillages(list[i], true); float num6 = (float)this.departmentOfTheInterior.GetNumberOfOwnedMinorFactionVillages(list[i], false) - num5; float num7 = num4 * (num5 + num6 * 0.5f); if (flag2) { num7 *= 1.7f; } float num8 = 0f; using (IEnumerator <UnitBodyDefinition> enumerator = (from match in values where match.Affinity != null && match.Affinity.Name == faction.Affinity.Name select match).GetEnumerator()) { while (enumerator.MoveNext()) { UnitBodyDefinition unitBodyDefinition = enumerator.Current; if (flag2) { int num9 = 0; Func <Construction, bool> < > 9__2; foreach (City gameEntity in this.departmentOfTheInterior.Cities) { ConstructionQueue constructionQueue = this.departmentOfIndustry.GetConstructionQueue(gameEntity); if (constructionQueue != null) { IEnumerable <Construction> pendingConstructions = constructionQueue.PendingConstructions; Func <Construction, bool> selector; if ((selector = < > 9__2) == null) { selector = (< > 9__2 = ((Construction c) => c.ConstructibleElement is UnitDesign && (c.ConstructibleElement as UnitDesign).UnitBodyDefinition == unitBodyDefinition && (c.GetSpecificConstructionStock(DepartmentOfTheTreasury.Resources.Production) > 0f || c.IsBuyout))); } int num10 = pendingConstructions.Count(selector); num9 += num10; } } if (this.departmentOfTheInterior.Cities.Count < num9 * 4) { goto IL_2E5; } } float num11 = this.intelligenceAIHelper.GetAIStrengthBelief(base.AIEntity.Empire.Index, unitBodyDefinition.Name); if (this.UnitTypes[unitBodyDefinition.SubCategory] == 0 || (flag2 && this.UnitTypes[unitBodyDefinition.SubCategory] == 1)) { num11 = AILayer.Boost(num11, 0.8f); } num8 = Mathf.Max(num8, num11); } } float num12 = num7 * num8; if (!flag2 && (num < 0 || num12 > num2)) { num = i; num2 = num12; } if (flag2 && num12 < num3) { index = i; num3 = num12; } } IL_2E5 :; } if (num < 0 || num2 < 0.7f) { return; } if (flag) { if (num2 <= num3) { return; } this.FactionToDeassimilate = list[index].Name; } Faction faction2 = list[num]; EvaluableMessage_Assimilation evaluableMessage_Assimilation = base.AIEntity.AIPlayer.Blackboard.FindFirst <EvaluableMessage_Assimilation>(BlackboardLayerID.Empire, (EvaluableMessage_Assimilation match) => match.EvaluationState == EvaluableMessage.EvaluableMessageState.Pending || match.EvaluationState == EvaluableMessage.EvaluableMessageState.Validate); if (evaluableMessage_Assimilation == null) { evaluableMessage_Assimilation = new EvaluableMessage_Assimilation(AILayer_AccountManager.AssimilationAccountName); base.AIEntity.AIPlayer.Blackboard.AddMessage(evaluableMessage_Assimilation); } evaluableMessage_Assimilation.Refresh(1f, 1f, faction2.Name); }
public override void RefreshContent() { base.RefreshContent(); this.validPointsOfInterest.Clear(); this.validImprovements.Clear(); if (this.City != null && this.City.BesiegingEmpire == null && base.Empire == this.City.Empire && !this.City.IsInfected) { DepartmentOfIndustry agency = this.City.Empire.GetAgency <DepartmentOfIndustry>(); DepartmentOfTheInterior agency2 = this.City.Empire.GetAgency <DepartmentOfTheInterior>(); DepartmentOfTheTreasury agency3 = this.City.Empire.GetAgency <DepartmentOfTheTreasury>(); ConstructibleElement[] availableConstructibleElements = agency.ConstructibleElementDatabase.GetAvailableConstructibleElements(new StaticString[0]); ConstructibleElement[] array = availableConstructibleElements; List <StaticString> list = new List <StaticString>(); for (int i = 0; i < this.City.Region.PointOfInterests.Length; i++) { PointOfInterest pointOfInterest = this.City.Region.PointOfInterests[i]; if (pointOfInterest.PointOfInterestImprovement == null && pointOfInterest.CreepingNodeImprovement == null && (base.WorldPositionningService.GetExplorationBits(pointOfInterest.WorldPosition) & this.City.Empire.Bits) > 0) { List <PointOfInterestImprovementDefinition> list2 = new List <PointOfInterestImprovementDefinition>(); List <ConstructibleDistrictDefinition> list3 = new List <ConstructibleDistrictDefinition>(); for (int j = 0; j < array.Length; j++) { if (array[j] is PointOfInterestImprovementDefinition) { PointOfInterestImprovementDefinition pointOfInterestImprovementDefinition = array[j] as PointOfInterestImprovementDefinition; if (pointOfInterestImprovementDefinition.PointOfInterestTemplateName == pointOfInterest.PointOfInterestDefinition.PointOfInterestTemplateName) { list.Clear(); DepartmentOfTheTreasury.CheckConstructiblePrerequisites(this.City, pointOfInterestImprovementDefinition, ref list, new string[] { ConstructionFlags.Prerequisite }); if (!list.Contains(ConstructionFlags.Discard) && agency3.CheckConstructibleInstantCosts(this.City, pointOfInterestImprovementDefinition)) { list2.Add(agency2.GetBestImprovementDefinition(this.City, pointOfInterest, pointOfInterestImprovementDefinition, list)); } } } else if (array[j] is ConstructibleDistrictDefinition) { ConstructibleDistrictDefinition constructibleDistrictDefinition = array[j] as ConstructibleDistrictDefinition; if (constructibleDistrictDefinition != null) { list3.Add(constructibleDistrictDefinition); } } } if (list2.Count > 0) { ConstructionQueue constructionQueue = agency.GetConstructionQueue(this.City); bool flag = false; for (int k = 0; k < list2.Count; k++) { for (int l = 0; l < constructionQueue.Length; l++) { Construction construction = constructionQueue.PeekAt(l); if (construction.ConstructibleElement == list2[k] && construction.WorldPosition == pointOfInterest.WorldPosition) { flag = true; break; } } } if (!flag) { for (int m = 0; m < list3.Count; m++) { for (int n = 0; n < constructionQueue.Length; n++) { Construction construction2 = constructionQueue.PeekAt(n); if (construction2.ConstructibleElement == list3[m] && construction2.WorldPosition == pointOfInterest.WorldPosition) { flag = true; break; } } } } if (!flag) { for (int num = 0; num < list2.Count; num++) { this.validPointsOfInterest.Add(pointOfInterest); this.validImprovements.Add(list2[num]); } } } } } } this.LabelsTable.ReserveChildren(this.validPointsOfInterest.Count, this.LabelPrefab, "ConstructibleLabel"); this.LabelsTable.RefreshChildrenIList <PointOfInterest>(this.validPointsOfInterest, new AgeTransform.RefreshTableItem <PointOfInterest>(this.RefreshPointOfInterest), true, false); this.LabelsTable.Enable = this.interactionsAllowed; this.UnbindAndHideLabels(this.validPointsOfInterest.Count); }
public void Refresh(global::Empire empire, DepartmentOfScience.ConstructibleElement.State state) { if (this.Button != null) { this.Button.AgeTransform.Enable = true; } TechnologyDefinitionVisibility visibility = this.TechnologyDefinition.Visibility; if (visibility != TechnologyDefinitionVisibility.VisibleWhenUnlocked) { if (visibility == TechnologyDefinitionVisibility.BasedOnPrerequisites) { bool flag = DepartmentOfTheTreasury.CheckConstructiblePrerequisites(empire, this.TechnologyDefinition, new string[] { "Visibility" }); if (flag) { this.AgeTransform.Visible = true; } else { this.AgeTransform.Visible = false; } } } else { if (state != DepartmentOfScience.ConstructibleElement.State.Researched) { this.AgeTransform.Visible = false; return; } if (!this.AgeTransform.Visible) { this.AgeTransform.Visible = true; this.SetSimpleMode(false); } } this.UnlockDisabled.Visible = false; this.InProgressSector.AgeTransform.Visible = false; this.OrderCaption.AgeTransform.Visible = false; DepartmentOfScience agency = empire.GetAgency <DepartmentOfScience>(); bool flag2 = false; int num = 0; ConstructionQueue constructionQueueForTech = agency.GetConstructionQueueForTech(this.TechnologyDefinition); if ((state == DepartmentOfScience.ConstructibleElement.State.Queued || state == DepartmentOfScience.ConstructibleElement.State.InProgress) && constructionQueueForTech.Length > 1) { flag2 = true; if (state == DepartmentOfScience.ConstructibleElement.State.Queued) { for (int i = 0; i < constructionQueueForTech.Length; i++) { DepartmentOfScience.ConstructibleElement constructibleElement = constructionQueueForTech.PeekAt(i).ConstructibleElement as DepartmentOfScience.ConstructibleElement; if (constructibleElement.Name == this.TechnologyDefinition.Name) { num = i; break; } } } } bool flag3 = this.TechnologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.Affinity) || this.TechnologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.Medal) || this.TechnologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.Quest); bool flag4 = this.TechnologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.OrbUnlock); Color tintColor; Color tintColor2; Color tintColor3; Color tintColor4; switch (state) { case DepartmentOfScience.ConstructibleElement.State.Available: tintColor = ((!flag4) ? this.AvailableColor : this.AvailableOrbUnlockColor); tintColor2 = ((!flag3) ? ((!flag4) ? this.AvailableBackdropColor : this.AvailableOrbUnlockBackdropColor) : this.AvailableBackdropColorAffinity); tintColor3 = this.AvailableSymbolColor; tintColor4 = this.GlowAvailableColor; break; case DepartmentOfScience.ConstructibleElement.State.Queued: tintColor = this.QueuedColor; tintColor2 = ((!flag3) ? this.QueuedBackdropColor : this.QueuedBackdropColorAffinity); tintColor3 = this.QueuedSymbolColor; tintColor4 = this.GlowAvailableColor; this.OrderCaption.AgeTransform.Visible = true; this.OrderCaption.TintColor = this.QueuedColor; this.OrderLabel.Text = (num + 1).ToString(); break; case DepartmentOfScience.ConstructibleElement.State.InProgress: tintColor = this.InProgressColor; tintColor2 = ((!flag3) ? this.InProgressBackdropColor : this.InProgressBackdropColorAffinity); tintColor3 = this.InProgressSymbolColor; tintColor4 = this.GlowAvailableColor; this.InProgressSector.AgeTransform.Visible = true; if (flag2) { this.OrderCaption.AgeTransform.Visible = true; this.OrderCaption.TintColor = this.InProgressColor; this.OrderLabel.Text = (num + 1).ToString(); } break; case DepartmentOfScience.ConstructibleElement.State.Researched: if (this.Button != null) { this.Button.AgeTransform.Enable = false; } tintColor = ((!flag4) ? this.ResearchedColor : this.ResearchedOrbUnlockColor); tintColor2 = ((!flag3) ? this.ResearchedBackdropColor : this.ResearchedBackdropColorAffinity); tintColor3 = this.ResearchedSymbolColor; tintColor4 = this.GlowAvailableColor; break; case DepartmentOfScience.ConstructibleElement.State.ResearchedButUnavailable: if (this.Button != null) { this.Button.AgeTransform.Enable = false; } tintColor = this.ResearchedButUnavailableColor; tintColor2 = ((!flag3) ? this.ResearchedBackdropColor : this.ResearchedBackdropColorAffinity); tintColor3 = this.ResearchedSymbolColor; tintColor4 = this.GlowNotAvailableColor; this.UnlockDisabled.Visible = true; break; default: tintColor = this.NotAvailableColor; tintColor2 = ((!flag3) ? this.NotAvailableBackdropColor : this.NotAvailableBackdropColorAffinity); tintColor3 = this.NotAvailableSymbolColor; tintColor4 = this.GlowNotAvailableColor; if (this.Button != null) { this.Button.AgeTransform.Enable = false; } this.UnlockDisabled.Visible = true; break; } this.CircularFrame.TintColor = tintColor; this.CaptionFullBackground.TintColor = tintColor2; this.CaptionTopBackground.TintColor = tintColor2; this.CaptionBottomBackground.TintColor = tintColor2; this.EraLabel.TintColor = tintColor3; this.CategoryIcon.TintColor = tintColor3; this.SubCategoryIcon.TintColor = tintColor3; this.CategoryFullIcon.TintColor = tintColor3; this.SubCategoryFullIcon.TintColor = tintColor3; this.GlowImage.TintColor = tintColor4; this.RefreshCostGroup(state); }
protected MajorSpaceVehicle() : base() { Cargo = new Cargo(); constructionQueue = new ConstructionQueue(this); }
private void Start() { constructionQueue = GetComponent<ConstructionQueue>(); }
// Stores references to required components for level generation private void Awake() { constructor = GetComponentInChildren <SegmentConstructor>(); queue = GetComponentInChildren <ConstructionQueue>(); deleter = GetComponentInChildren <SegmentDeleter>(); }
public bool IsPositionValidForDevice(Amplitude.Unity.Game.Empire empire, WorldPosition position) { if (!position.IsValid) { return(false); } if (this.WorldPositionningService.IsWaterTile(position)) { return(false); } if (this.GetDeviceAtPosition(position) != null) { return(false); } if (this.IsAreaVolcanoformed(position)) { return(false); } if (this.WorldPositionningService != null) { if (!this.WorldPositionningService.IsConstructible(position, WorldPositionning.PreventsDistrictTypeExtensionConstruction, 0) && !this.pillarService.IsPositionOccupiedByAPillar(position)) { return(false); } Region region = this.WorldPositionningService.GetRegion(position); if (region.KaijuEmpire != null && region.Kaiju != null) { KaijuGarrison kaijuGarrison = region.Kaiju.KaijuGarrison; if (kaijuGarrison.WorldPosition == position) { return(false); } } if (region != null && region.City != null && region.City.Empire.Index != empire.Index) { for (int i = 0; i < region.City.Districts.Count; i++) { if (region.City.Districts[i].Type != DistrictType.Exploitation && region.City.Districts[i].WorldPosition == position) { return(false); } } DepartmentOfIndustry agency = region.City.Empire.GetAgency <DepartmentOfIndustry>(); ConstructionQueue constructionQueue = agency.GetConstructionQueue(region.City); if (constructionQueue != null) { for (int j = 0; j < constructionQueue.PendingConstructions.Count; j++) { if (constructionQueue.PendingConstructions[j].WorldPosition == position) { if (constructionQueue.PendingConstructions[j].ConstructibleElement is DistrictImprovementDefinition) { return(false); } if (constructionQueue.PendingConstructions[j].ConstructibleElement is UnitDesign && (constructionQueue.PendingConstructions[j].ConstructibleElement as UnitDesign).Tags.Contains(DownloadableContent9.TagSolitary)) { return(false); } } } } } } return(true); }
private void GeneratePopulationBuyoutMessage() { if (!DepartmentOfTheInterior.CanBuyoutPopulation(this.aiEntityCity.City)) { return; } this.GeneratePopulationBuyoutMessage_ELCPGlobalPopulationInfo(); List <EvaluableMessage_PopulationBuyout> list = new List <EvaluableMessage_PopulationBuyout>(this.aiEntityCity.Blackboard.GetMessages <EvaluableMessage_PopulationBuyout>(BlackboardLayerID.City, (EvaluableMessage_PopulationBuyout message) => message.CityGuid == this.aiEntityCity.City.GUID && message.EvaluationState != EvaluableMessage.EvaluableMessageState.Obtained && message.EvaluationState != EvaluableMessage.EvaluableMessageState.Cancel)); EvaluableMessage_PopulationBuyout evaluableMessage_PopulationBuyout; if (list.Count == 0) { evaluableMessage_PopulationBuyout = new EvaluableMessage_PopulationBuyout(this.aiEntityCity.City.GUID, 1, AILayer_AccountManager.EconomyAccountName); this.aiEntityCity.Blackboard.AddMessage(evaluableMessage_PopulationBuyout); } else { evaluableMessage_PopulationBuyout = list[0]; } float num = 0f; for (int i = 0; i < AILayer_Population.GainPerPopulation.Length; i++) { num += this.aiEntityCity.City.GetPropertyValue(AILayer_Population.GainPerPopulation[i]); } float num2 = num / AILayer_Population.GlobalPopulationInfos[this.Empire.Index].bestGainPerPop * 0.5f; float propertyValue = this.aiEntityCity.City.GetPropertyValue(SimulationProperties.Population); if (propertyValue == AILayer_Population.GlobalPopulationInfos[this.Empire.Index].lowestPopulation) { num2 = AILayer.Boost(num2, 0.2f); } float populationBuyOutCost = DepartmentOfTheTreasury.GetPopulationBuyOutCost(this.aiEntityCity.City); float num3; if (!this.departmentOfTheTreasury.TryGetResourceStockValue(base.AIEntity.Empire.SimulationObject, DepartmentOfTheTreasury.Resources.EmpireMoney, out num3, false)) { num3 = 1f; } float num4 = (num3 - populationBuyOutCost) / num3 / 0.8f; if (this.departmentOfForeignAffairs.IsInWarWithSomeone()) { num4 -= 0.05f; } num2 = AILayer.Boost(num2, num4); ConstructionQueue constructionQueue = this.departmentOfIndustry.GetConstructionQueue(this.aiEntityCity.City); if (propertyValue > 1f) { for (int j = constructionQueue.Length - 1; j >= 0; j--) { if (constructionQueue.PeekAt(j).ConstructibleElementName.ToString().Contains("Settler")) { num2 = AILayer.Boost(num2, -1f); break; } } } Diagnostics.Log("ELCP {0}/{1} GeneratePopulationBuyoutMessage score: {2}, cost: {3}", new object[] { this.Empire, this.aiEntityCity.City.LocalizedName, num2, populationBuyOutCost }); evaluableMessage_PopulationBuyout.Refresh(1f, num2, populationBuyOutCost, int.MaxValue); }