private IEnumerator UpdateDrag() { while (this.updateDrag) { WorkersDragPanel guiPanel = base.GuiService.GetGuiPanel <WorkersDragPanel>(); if (Input.GetMouseButtonDown(0)) { if (guiPanel.DragInProgress) { if (guiPanel.DragMoved) { this.CheckDragTarget(guiPanel); } else { guiPanel.CancelDrag(); base.NeedRefresh = true; } } else if (AgeManager.Instance.ActiveControl != null) { WorkerSymbol component = AgeManager.Instance.ActiveControl.GetComponent <WorkerSymbol>(); if (component != null) { guiPanel.InitDrag(this.City, component.WorkerType, component.DragQuantity); } } } else if (Input.GetMouseButtonUp(0)) { if (guiPanel.DragInProgress) { if (!guiPanel.DragMoved) { guiPanel.StartDrag(); base.NeedRefresh = true; } else { guiPanel.DragInProgress = false; this.CheckDragTarget(guiPanel); } } } else if (guiPanel.DragInProgress && !guiPanel.DragMoved && this.previousCursor != AgeManager.Instance.Cursor) { guiPanel.StartDrag(); base.NeedRefresh = true; } this.previousCursor = AgeManager.Instance.Cursor; yield return(null); } yield break; }
private void CheckDragTarget(WorkersDragPanel workersDragPanel) { if (AgeManager.Instance.ActiveControl != null) { WorkersGroup component = AgeManager.Instance.ActiveControl.GetComponent <WorkersGroup>(); if (component == null) { WorkerSymbol component2 = AgeManager.Instance.ActiveControl.GetComponent <WorkerSymbol>(); if (component2 != null) { component = component2.AgeTransform.GetParent().GetComponent <WorkersGroup>(); } } if (!(component != null)) { workersDragPanel.CancelDrag(); base.NeedRefresh = true; return; } if (!(workersDragPanel.StartingWorkerType != component.WorkerType)) { workersDragPanel.CancelDrag(); base.NeedRefresh = true; return; } workersDragPanel.ValidateDrag(this.WorkerGroupsTable, component.WorkerType, new EventHandler <TicketRaisedEventArgs>(this.OnOrderResponse)); if (TutorialManager.IsActivated) { IEventService service = Services.GetService <IEventService>(); Diagnostics.Assert(service != null); IGameService service2 = Services.GetService <IGameService>(); Diagnostics.Assert(service2 != null); Diagnostics.Assert(service2.Game as global::Game != null); service.Notify(new EventTutorialWorkerDragged(this.City.Empire, workersDragPanel.StartingWorkerType, component.WorkerType)); return; } } else { workersDragPanel.CancelDrag(); base.NeedRefresh = true; } }
private void EndTurnService_GameClientStateChange(object sender, GameClientStateChangeEventArgs e) { if (base.IsVisible && base.Game != null) { IPlayerControllerRepositoryService service = base.Game.Services.GetService <IPlayerControllerRepositoryService>(); if (service == null) { return; } bool flag = service.ActivePlayerController.CanSendOrders(); if (this.interactionsAllowed != flag) { this.interactionsAllowed = flag; WorkersDragPanel guiPanel = base.GuiService.GetGuiPanel <WorkersDragPanel>(); if (!this.interactionsAllowed && guiPanel.DragInProgress && guiPanel.DragMoved) { guiPanel.CancelDrag(); } base.NeedRefresh = true; } } }
public override void RefreshContent() { if (this.City == null) { return; } base.RefreshContent(); float num = 0f; WorkersDragPanel guiPanel = base.GuiService.GetGuiPanel <WorkersDragPanel>(); for (int i = 0; i < this.workerTypes.Count; i++) { int num2 = Mathf.FloorToInt(this.City.GetPropertyValue(this.workerTypes[i])); if (guiPanel.DragInProgress && guiPanel.DragMoved && this.workerTypes[i] == guiPanel.StartingWorkerType) { num2 -= guiPanel.NumberOfWorkers; } if (i < this.WorkersGroups.Length) { this.WorkersGroups[i].RefreshContent(this.City, num2, this.workerTypes[i], guiPanel); this.WorkersGroups[i].GetComponent <AgeTransform>().Enable = (this.interactionsAllowed && !this.IsOtherEmpire); } int num3 = num2 / this.workersPerLine; if (num3 * this.workersPerLine != num2) { num3++; } if (num3 < 1) { num3 = 1; } if (i < this.WorkersGroups.Length && this.WorkersGroups[i] != null) { AgeTransform workersTable = this.WorkersGroups[i].WorkersTable; float num4 = workersTable.VerticalMargin + (float)num3 * (this.childHeight + workersTable.VerticalSpacing); if (num4 > num) { num = num4; } } } for (int j = 0; j < this.prodPerPopFIDSTypes.Count; j++) { float num5 = 0f; if (j < this.ProdPerPopFIDSValues.Length) { float propertyValue = this.City.GetPropertyValue(this.prodPerPopFIDSTypes[j]); this.ProdPerPopFIDSValues[j].Text = GuiFormater.FormatGui(propertyValue, false, false, false, 0); } float propertyValue2 = this.City.GetPropertyValue(this.workedFIDSTypes[j]); if (j < this.CityTileFIDSValues.Length) { float propertyValue3 = this.City.GetPropertyValue(this.cityTileFIDSTypes[j]); this.CityTileFIDSValues[j].Text = GuiFormater.FormatGui(propertyValue3, false, false, false, 0); } if (j < this.TotalFIDSValues.Length) { num5 = this.City.GetPropertyValue(this.totalFIDSTypes[j]); if (this.City.SimulationObject.Tags.Contains(City.MimicsCity) && this.TotalFIDSValues[j].AgeTransform.AgeTooltip.ClientData != null && this.TotalFIDSValues[j].AgeTransform.AgeTooltip.ClientData is SimulationPropertyTooltipData) { SimulationPropertyTooltipData simulationPropertyTooltipData = this.TotalFIDSValues[j].AgeTransform.AgeTooltip.ClientData as SimulationPropertyTooltipData; if (simulationPropertyTooltipData.Title == SimulationProperties.NetCityProduction) { num5 = 0f; } else if (simulationPropertyTooltipData.Title == SimulationProperties.NetCityGrowth) { num5 = this.City.GetPropertyValue("AlmostNetCityGrowth"); } } this.TotalFIDSValues[j].Text = GuiFormater.FormatGui(num5, false, false, false, 0); } if (j < this.ModifierFIDSValues.Length) { float num6 = num5 - propertyValue2; if (Mathf.RoundToInt(num6) != 0) { this.ModifierFIDSValues[j].Text = GuiFormater.FormatGui(num6, false, false, true, 0); } else { this.ModifierFIDSValues[j].Text = string.Empty; } } } this.WorkerGroupsTable.Height = num; this.WorkersTitle.Height = num; for (int k = 0; k < this.WorkersGroups.Length; k++) { this.WorkersGroups[k].WorkersTable.Height = num; this.WorkersGroups[k].ActiveHighlight.Height = num; this.WorkersGroups[k].GetComponent <AgeTransform>().Height = num; } base.AgeTransform.Height = this.TopMargin * AgeUtils.CurrentUpscaleFactor() + num + this.WorkerGroupsTable.PixelMarginBottom; bool flag = DepartmentOfTheInterior.CanBuyoutPopulation(this.City); bool flag2 = this.City.Empire.SimulationObject.Tags.Contains(FactionTrait.FactionTraitReplicants1); bool flag3 = this.City.Empire.SimulationObject.Tags.Contains(FactionTrait.FactionTraitMimics2); int rowIndex; Func <WorkersGroup, bool> < > 9__0; int rowIndex2; for (rowIndex = 0; rowIndex < this.FoodColumnCells.Length; rowIndex = rowIndex2 + 1) { bool flag4 = false; if (this.IsOtherEmpire) { IEnumerable <WorkersGroup> workersGroups = this.WorkersGroups; Func <WorkersGroup, bool> predicate; if ((predicate = < > 9__0) == null) { predicate = (< > 9__0 = ((WorkersGroup cell) => cell.GetComponent <AgeTransform>() == this.FoodColumnCells[rowIndex])); } flag4 = workersGroups.Any(predicate); } this.FoodColumnCells[rowIndex].Enable = (!flag && this.interactionsAllowed && !flag4); this.ScienceColumnCells[rowIndex].Enable = (!flag2 && this.interactionsAllowed && !flag4); this.IndustryColumnCells[rowIndex].Enable = (!flag3 && this.interactionsAllowed && !flag4); rowIndex2 = rowIndex; } if (this.BoostersTable == null) { bool highDefinition = AgeUtils.HighDefinition; AgeUtils.HighDefinition = false; this.BoostersTable = base.AgeTransform.InstanciateChild(this.BoostersEnumerator.BoostersTable.transform, "WorkerPanelBoostersTable1"); this.BoostersTable.TableArrangement = false; this.BoostersTable2 = base.AgeTransform.InstanciateChild(this.BoostersEnumerator.BoostersTable.transform, "WorkerPanelBoostersTable2"); this.BoostersTable2.TableArrangement = false; AgeUtils.HighDefinition = highDefinition; } this.stackedBoosters.Clear(); this.stackedBoosters2.Clear(); float num7 = 0f; bool flag5 = false; bool flag6 = false; bool flag7 = false; bool flag8 = false; float num8 = AgeUtils.HighDefinition ? 3f : 2f; if (!this.IsOtherEmpire) { foreach (string text in new List <string> { "BoosterFood", "BoosterCadavers", "BoosterIndustry", "FlamesIndustryBooster", "BoosterScience" }) { BoosterDefinition boosterDefinition2; if (this.database.TryGetValue(text, out boosterDefinition2)) { GuiStackedBooster item = new GuiStackedBooster(boosterDefinition2); this.stackedBoosters.Add(item); if (!this.ParentIsCityListScreen && (text == "BoosterCadavers" || text == "FlamesIndustryBooster")) { this.stackedBoosters2.Add(item); } } } bool flag9 = false; this.vaultBoosters = this.departmentOfEducation.GetVaultItems <BoosterDefinition>(); for (int l = 0; l < this.vaultBoosters.Count; l++) { BoosterDefinition boosterDefinition = this.vaultBoosters[l].Constructible as BoosterDefinition; if (boosterDefinition != null) { flag9 = true; if (boosterDefinition.Name == "BoosterFood") { flag5 = true; } else if (boosterDefinition.Name == "BoosterIndustry") { flag6 = true; } else if (boosterDefinition.Name == "BoosterCadavers") { flag7 = true; } else if (boosterDefinition.Name == "FlamesIndustryBooster") { flag8 = true; } this.stackedBoosters.Find((GuiStackedBooster booster) => booster.BoosterDefinition.RewardType == boosterDefinition.RewardType).AddVaultBooster(this.vaultBoosters[l]); } } if (!flag9) { this.stackedBoosters.Clear(); this.stackedBoosters2.Clear(); } else { num7 = this.FidsGroups[0].Height; if (!this.ParentIsCityListScreen) { if (!flag6) { GuiStackedBooster item2 = this.stackedBoosters.Find((GuiStackedBooster booster) => booster.BoosterDefinition.Name == "BoosterIndustry"); this.stackedBoosters.Remove(item2); } else { GuiStackedBooster item3 = this.stackedBoosters.Find((GuiStackedBooster booster) => booster.BoosterDefinition.Name == "FlamesIndustryBooster"); this.stackedBoosters.Remove(item3); } if (!flag5) { GuiStackedBooster item4 = this.stackedBoosters.Find((GuiStackedBooster booster) => booster.BoosterDefinition.Name == "BoosterFood"); this.stackedBoosters.Remove(item4); } else { GuiStackedBooster item5 = this.stackedBoosters.Find((GuiStackedBooster booster) => booster.BoosterDefinition.Name == "BoosterCadavers"); this.stackedBoosters.Remove(item5); } if (!flag6 && !flag5) { this.stackedBoosters2.Clear(); } } else { if (flag8 && !flag6) { GuiStackedBooster item6 = this.stackedBoosters.Find((GuiStackedBooster booster) => booster.BoosterDefinition.Name == "BoosterIndustry"); this.stackedBoosters.Remove(item6); } else if (!flag8) { GuiStackedBooster item7 = this.stackedBoosters.Find((GuiStackedBooster booster) => booster.BoosterDefinition.Name == "FlamesIndustryBooster"); this.stackedBoosters.Remove(item7); } if (!flag5 && flag7) { GuiStackedBooster item8 = this.stackedBoosters.Find((GuiStackedBooster booster) => booster.BoosterDefinition.Name == "BoosterFood"); this.stackedBoosters.Remove(item8); } else if (!flag7) { GuiStackedBooster item9 = this.stackedBoosters.Find((GuiStackedBooster booster) => booster.BoosterDefinition.Name == "BoosterCadavers"); this.stackedBoosters.Remove(item9); } } } } this.BoostersTable2.ReserveChildren(this.stackedBoosters2.Count, this.BoostersEnumerator.BoosterStockPrefab, "Item2"); this.BoostersTable2.RefreshChildrenIList <GuiStackedBooster>(this.stackedBoosters2, this.refreshDelegate, true, true); this.BoostersTable.ReserveChildren(this.stackedBoosters.Count, this.BoostersEnumerator.BoosterStockPrefab, "Item"); this.BoostersTable.RefreshChildrenIList <GuiStackedBooster>(this.stackedBoosters, this.refreshDelegate, true, true); this.BoostersTable.PixelMarginTop = base.AgeTransform.Height; this.BoostersTable2.PixelMarginTop = base.AgeTransform.Height + this.FidsGroups[0].Height + num8; float num9 = 0f; foreach (BoosterStock boosterStock in this.BoostersTable.GetChildren <BoosterStock>(true)) { float num10 = num8; if (this.ParentIsCityListScreen && ((flag5 && flag7 && (boosterStock.GuiStackedBooster.BoosterDefinition.Name == "BoosterFood" || boosterStock.GuiStackedBooster.BoosterDefinition.Name == "BoosterCadavers")) || (flag6 && flag8 && (boosterStock.GuiStackedBooster.BoosterDefinition.Name == "BoosterIndustry" || boosterStock.GuiStackedBooster.BoosterDefinition.Name == "FlamesIndustryBooster")))) { boosterStock.AgeTransform.Width = this.FidsGroups[0].Width / 2f - 1f; if (boosterStock.GuiStackedBooster.BoosterDefinition.Name == "BoosterFood" || boosterStock.GuiStackedBooster.BoosterDefinition.Name == "BoosterIndustry") { num10 = 2f; } } else { boosterStock.AgeTransform.Width = this.FidsGroups[0].Width; } if (boosterStock.GuiStackedBooster.Quantity == 0 || (flag && (num9 == 0f || boosterStock.GuiStackedBooster.BoosterDefinition.Name == "BoosterCadavers")) || (flag2 && boosterStock.GuiStackedBooster.BoosterDefinition.Name == "BoosterScience")) { boosterStock.AgeTransform.Enable = false; boosterStock.AgeTransform.Visible = false; } else { num7 = boosterStock.AgeTransform.Height; boosterStock.AgeTransform.Enable = this.interactionsAllowed; boosterStock.AgeTransform.Visible = true; boosterStock.QuickActivation = true; boosterStock.Guid = this.City.GUID; boosterStock.QuantityLabel.AgeTransform.AttachTop = true; boosterStock.QuantityLabel.AgeTransform.AttachRight = true; boosterStock.QuantityLabel.AgeTransform.PixelMarginLeft = 0f; boosterStock.QuantityLabel.Alignement = AgeTextAnchor.AscendMiddleRight; if (!this.ParentIsCityListScreen) { boosterStock.IconImage.AgeTransform.PixelMarginLeft = num8 * 2.5f; boosterStock.QuantityLabel.AgeTransform.PixelMarginRight = num8 * 2f; } else { boosterStock.IconImage.AgeTransform.PixelMarginLeft = ((boosterStock.AgeTransform.Width == this.FidsGroups[0].Width) ? (boosterStock.AgeTransform.Width / 3f) : (boosterStock.AgeTransform.Width / 5f)); boosterStock.QuantityLabel.AgeTransform.PixelMarginRight = ((boosterStock.AgeTransform.Width == this.FidsGroups[0].Width) ? (boosterStock.AgeTransform.Width / 3f) : (boosterStock.AgeTransform.Width / 5f)); } } boosterStock.AgeTransform.X = num9; boosterStock.AgeTransform.AttachRight = false; boosterStock.AgeTransform.AttachLeft = true; num9 += boosterStock.AgeTransform.Width + num10; } if (this.BoostersTable2.GetChildren <BoosterStock>(true).Count > 0) { bool flag10 = false; num9 = 0f; foreach (BoosterStock boosterStock2 in this.BoostersTable2.GetChildren <BoosterStock>(true)) { boosterStock2.AgeTransform.Width = this.FidsGroups[0].Width; if (boosterStock2.GuiStackedBooster.Quantity == 0 || (num9 == 0f && !flag5) || (num9 > 0f && !flag6) || (flag && num9 == 0f)) { boosterStock2.AgeTransform.Enable = false; boosterStock2.AgeTransform.Visible = false; } else { flag10 = true; boosterStock2.AgeTransform.Enable = this.interactionsAllowed; boosterStock2.AgeTransform.Visible = true; boosterStock2.QuickActivation = true; boosterStock2.Guid = this.City.GUID; boosterStock2.IconImage.AgeTransform.PixelMarginLeft = num8 * 2.5f; boosterStock2.QuantityLabel.AgeTransform.AttachTop = true; boosterStock2.QuantityLabel.AgeTransform.AttachRight = true; boosterStock2.QuantityLabel.AgeTransform.PixelMarginLeft = 0f; boosterStock2.QuantityLabel.AgeTransform.PixelMarginRight = num8 * 2f; boosterStock2.QuantityLabel.Alignement = AgeTextAnchor.AscendMiddleRight; } boosterStock2.AgeTransform.X = num9; boosterStock2.AgeTransform.AttachRight = false; boosterStock2.AgeTransform.AttachLeft = true; num9 += this.FidsGroups[0].Width + this.BoostersTable2.HorizontalSpacing; } num7 += (flag10 ? (this.FidsGroups[0].Height + num8) : 0f); } base.AgeTransform.Height += num7; this.AgeModifierPosition.EndHeight = base.AgeTransform.Height; foreach (AgeTransform ageTransform in base.AgeTransform.GetChildren()) { if (ageTransform.name.Contains("CityTile") || ageTransform.name.Contains("Total") || ageTransform.name.Contains("Modifiers")) { ageTransform.PixelMarginBottom = this.OriginalMargins[ageTransform.name] * (AgeUtils.HighDefinition ? 1.5f : 1f) + num7; } } }