private void InitializeDroids() { CurrentPlayer currentPlayer = Service.CurrentPlayer; int num = currentPlayer.CurrentDroidsAmount; NodeList <SupportViewNode> nodeList = Service.EntityController.GetNodeList <SupportViewNode>(); ISupportController iSupportController = Service.ISupportController; for (SupportViewNode supportViewNode = nodeList.Head; supportViewNode != null; supportViewNode = supportViewNode.Next) { Contract contract = iSupportController.FindCurrentContract(supportViewNode.Entity.Get <BuildingComponent>().BuildingTO.Key); if (contract != null) { DeliveryType deliveryType = contract.DeliveryType; if (deliveryType == DeliveryType.SwapBuilding || deliveryType == DeliveryType.UpgradeBuilding || deliveryType == DeliveryType.Building) { this.AssignWorkToDroid(supportViewNode.Entity, true, true, false); num--; } else if (deliveryType == DeliveryType.ClearClearable || deliveryType == DeliveryType.Champion) { this.AssignWorkToDroid(supportViewNode.Entity, false, true, false); num--; } } } }
private void OnPvpTargetFound(PvpTarget target, object cookie) { this.KillSearchTimer(); this.CurrentPvpTarget = target; int pvpMatchCost = this.GetPvpMatchCost(); if (pvpMatchCost != target.CreditsCharged) { Service.Get <StaRTSLogger>().ErrorFormat("Pvp target credit cost mismatch. Client: {0}, Server: {1}", new object[] { pvpMatchCost, target.CreditsCharged }); } else { GameUtils.SpendCurrency(target.CreditsCharged, 0, 0, false); } ISupportController supportController = Service.Get <ISupportController>(); supportController.SimulateCheckAllContractsWithCurrentTime(); supportController.SyncCurrentPlayerInventoryWithServer(target.AttackerDeployableServerData); this.OnTargetReady(target, false); Service.Get <UserInputInhibitor>().AllowAll(); }
public override void Perform() { Service.BotRunner.Log("Training Troops!", new object[0]); int num; int num2; GameUtils.GetStarportTroopCounts(out num, out num2); int num3 = 4; if (num + num3 > num2) { base.Perform(); return; } CurrentPlayer currentPlayer = Service.CurrentPlayer; string text = (currentPlayer.Faction != FactionType.Empire) ? "Soldier" : "Storm"; int level = currentPlayer.UnlockedLevels.Troops.GetLevel(text); TroopTypeVO byLevel = Service.TroopUpgradeCatalog.GetByLevel(text, level); this.building = (SmartEntity)Service.BuildingLookupController.BarracksNodeList.Head.Entity; ISupportController iSupportController = Service.ISupportController; for (int i = 0; i < num3; i++) { iSupportController.StartTroopTrainContract(byLevel, this.building); } iSupportController.BuyoutAllTroopTrainContracts(this.building); base.Perform(); }
public static void ProcessResouceGenPerkEffectsIntoStorage(List <ActivatedPerkData> allPerks) { ISupportController supportController = Service.Get <ISupportController>(); NodeList <GeneratorViewNode> nodeList = Service.Get <EntityController>().GetNodeList <GeneratorViewNode>(); for (GeneratorViewNode generatorViewNode = nodeList.Head; generatorViewNode != null; generatorViewNode = generatorViewNode.Next) { BuildingComponent buildingComp = generatorViewNode.BuildingComp; Building buildingTO = buildingComp.BuildingTO; BuildingTypeVO buildingType = buildingComp.BuildingType; Contract contract = supportController.FindCurrentContract(buildingComp.BuildingTO.Key); if (buildingType.Type == BuildingType.Resource && contract == null) { uint time = ServerTime.Time; uint lastCollectTime = buildingTO.LastCollectTime; buildingTO.LastCollectTime = time; int perkAdjustedAccruedCurrency = ResourceGenerationPerkUtils.GetPerkAdjustedAccruedCurrency(buildingType, lastCollectTime, time, allPerks); buildingTO.CurrentStorage += perkAdjustedAccruedCurrency; if (buildingTO.CurrentStorage > buildingType.Storage) { buildingTO.CurrentStorage = buildingType.Storage; } buildingTO.AccruedCurrency = buildingTO.CurrentStorage; } } }
public override void AddToGame(Game game) { this.entityController = Service.EntityController; this.supportController = Service.ISupportController; this.accumulatedDt = 0f; this.requireViewRefresh = true; this.nodeList = this.entityController.GetNodeList <SupportViewNode>(); }
public static void GrantInstantBuildingUpgrade(RewardVO reward, CurrentPlayer cp) { for (int i = 0; i < reward.BuildingInstantUpgrades.Length; i++) { string[] array = reward.BuildingInstantUpgrades[i].Split(new char[] { ':' }); int num = Convert.ToInt32(array[1], CultureInfo.InvariantCulture); string text = array[0]; BuildingTypeVO buildingTypeVO = Service.Get <IDataController>().Get <BuildingTypeVO>(text); if (buildingTypeVO == null) { Service.Get <StaRTSLogger>().WarnFormat("buildingUiD {0} does not exist", new object[] { text }); } else { BuildingUpgradeCatalog buildingUpgradeCatalog = Service.Get <BuildingUpgradeCatalog>(); ISupportController supportController = Service.Get <ISupportController>(); NodeList <BuildingNode> nodeList = Service.Get <EntityController>().GetNodeList <BuildingNode>(); for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next) { BuildingTypeVO buildingType = buildingNode.BuildingComp.BuildingType; if (buildingType.Lvl < num && buildingType.Type == buildingTypeVO.Type && buildingType.Type != BuildingType.Clearable) { BuildingTypeVO byLevel = buildingUpgradeCatalog.GetByLevel(buildingType.UpgradeGroup, num); if (byLevel != null && byLevel.PlayerFacing) { if (!string.IsNullOrEmpty(buildingTypeVO.LinkedUnit)) { if (ContractUtils.IsChampionRepairing(buildingNode.Entity)) { supportController.FinishCurrentContract(buildingNode.Entity, true); } if (cp.Inventory.Champion.GetItemAmount(buildingTypeVO.LinkedUnit) == 0) { cp.OnChampionRepaired(buildingTypeVO.LinkedUnit); } } supportController.StartBuildingUpgrade(byLevel, buildingNode.Entity, true); int boardX = buildingNode.Entity.Get <BoardItemComponent>().BoardItem.BoardX; int boardZ = buildingNode.Entity.Get <BoardItemComponent>().BoardItem.BoardZ; float x; float z; EditBaseController.BuildingBoardToWorld(buildingNode.Entity, boardX, boardZ, out x, out z); Vector3 worldLocation = new Vector3(x, 0f, z); worldLocation.x = Units.BoardToWorldX(boardX); worldLocation.z = Units.BoardToWorldX(boardZ); Service.Get <WorldInitializer>().View.PanToLocation(worldLocation); } } } } } }
private void ConfirmUpgradeAllWalls(object result, object cookie) { string context = "UI_money_flow"; string action = (result == null) ? "close" : "buy"; string message = "upgrade_all_walls"; Service.Get <BILoggingController>().TrackGameAction(context, action, message, null); if (result == null) { return; } EventManager eventManager = Service.Get <EventManager>(); eventManager.SendEvent(EventId.MuteEvent, EventId.InventoryResourceUpdated); eventManager.SendEvent(EventId.MuteEvent, EventId.ContractAdded); int num = GameUtils.CrystalCostToUpgradeAllWalls(this.nextBuildingInfo.UpgradeMaterials, this.allWallSameLevelCount); if (!GameUtils.SpendCrystals(num)) { eventManager.SendEvent(EventId.UnmuteEvent, EventId.InventoryResourceUpdated); eventManager.SendEvent(EventId.UnmuteEvent, EventId.ContractAdded); return; } int currencyAmount = -num; string itemType = "soft_currency_flow"; string itemId = "materials"; int itemCount = 1; string type = "currency_purchase"; string subType = "durable"; Service.Get <DMOAnalyticsController>().LogInAppCurrencyAction(currencyAmount, itemType, itemId, itemCount, type, subType); string uid = this.buildingInfo.Uid; ISupportController supportController = Service.Get <ISupportController>(); supportController.StartAllWallPartBuildingUpgrade(this.nextBuildingInfo, this.selectedBuilding, false, false); int count = this.wallsOfSameLevel.Count; for (int i = 0; i < count; i++) { supportController.StartAllWallPartBuildingUpgrade(this.nextBuildingInfo, this.wallsOfSameLevel[i], false, false); } BuildingUpgradeAllWallsCommand command = new BuildingUpgradeAllWallsCommand(new BuildingUpgradeAllWallsRequest { BuildingUid = uid, PlayerId = Service.Get <CurrentPlayer>().PlayerId }); Service.Get <ServerAPI>().Enqueue(command); for (int j = 0; j < count; j++) { supportController.FinishCurrentContract(this.wallsOfSameLevel[j], j != 0, false); } supportController.FinishCurrentContract(this.selectedBuilding, true, false); eventManager.SendEvent(EventId.UnmuteEvent, EventId.InventoryResourceUpdated); eventManager.SendEvent(EventId.UnmuteEvent, EventId.ContractAdded); eventManager.SendEvent(EventId.SimulateAudioEvent, new AudioEventData(EventId.InventoryResourceUpdated, "crystals")); }
private List <NotificationObject> GetBuildingNotifications() { if (!Service.IsSet <CurrentPlayer>() || Service.Get <CurrentPlayer>().CampaignProgress == null) { return(null); } if (Service.Get <CurrentPlayer>().CampaignProgress.FueInProgress) { return(null); } IState currentState = Service.Get <GameStateMachine>().CurrentState; if (!(currentState is HomeState) && !(currentState is ApplicationLoadState)) { return(null); } List <NotificationObject> list = new List <NotificationObject>(); NodeList <SupportNode> nodeList = Service.Get <EntityController>().GetNodeList <SupportNode>(); ISupportController supportController = Service.Get <ISupportController>(); for (SupportNode supportNode = nodeList.Head; supportNode != null; supportNode = supportNode.Next) { BuildingComponent buildingComp = supportNode.BuildingComp; string key = buildingComp.BuildingTO.Key; Contract contract = supportController.FindCurrentContract(key); if (contract != null) { NotificationObject notificationObject = null; DeliveryType deliveryType = contract.DeliveryType; int remainingTimeForSim = contract.GetRemainingTimeForSim(); switch (deliveryType) { case DeliveryType.Building: case DeliveryType.UpgradeBuilding: notificationObject = this.CreateBuildingNotification(contract.ProductUid, remainingTimeForSim, key); break; case DeliveryType.UpgradeTroop: case DeliveryType.UpgradeStarship: case DeliveryType.UpgradeEquipment: notificationObject = this.CreateResearchNotification(contract.ProductUid, deliveryType, remainingTimeForSim, key); break; } if (notificationObject != null) { list.Add(notificationObject); } } } return(list); }
public override void RemoveFromGame(Game game) { this.nodeList = this.entityController.GetNodeList <SupportViewNode>(); for (SupportViewNode supportViewNode = this.nodeList.Head; supportViewNode != null; supportViewNode = supportViewNode.Next) { if (supportViewNode.SupportView != null) { supportViewNode.SupportView.TeardownElements(); } } this.entityController = null; this.supportController = null; this.nodeList = null; this.accumulatedDt = 0f; }
private void DoOfflineSimulationForGenerators() { Map map = Service.CurrentPlayer.Map; StaticDataController staticDataController = Service.StaticDataController; ICurrencyController iCurrencyController = Service.ICurrencyController; ISupportController iSupportController = Service.ISupportController; foreach (Building current in map.Buildings) { BuildingTypeVO buildingTypeVO = staticDataController.Get <BuildingTypeVO>(current.Uid); if (buildingTypeVO.Type == BuildingType.Resource && iSupportController.FindCurrentContract(current.Key) == null) { current.AccruedCurrency = iCurrencyController.CalculateAccruedCurrency(current, buildingTypeVO); } } }
private void DoOfflineSimulationForGenerators() { Map map = Service.Get <CurrentPlayer>().Map; IDataController dataController = Service.Get <IDataController>(); ICurrencyController currencyController = Service.Get <ICurrencyController>(); ISupportController supportController = Service.Get <ISupportController>(); foreach (Building current in map.Buildings) { BuildingTypeVO buildingTypeVO = dataController.Get <BuildingTypeVO>(current.Uid); if (buildingTypeVO.Type == BuildingType.Resource && supportController.FindCurrentContract(current.Key) == null) { current.AccruedCurrency = currencyController.CalculateAccruedCurrency(current, buildingTypeVO); } } }
protected void ConfirmInstantUpgrade(object result, object cookie) { if (result == null) { return; } int num = GameUtils.CrystalCostToInstantUpgrade(this.nextBuildingInfo); if (!GameUtils.SpendCrystals(num)) { return; } this.buttonPrimaryAction.Enabled = false; this.buttonInstantBuy.Enabled = false; this.buttonSwap.Enabled = false; this.upgradeButton.Enabled = false; this.allowClose = false; ProcessingScreen.Show(); int currencyAmount = -num; string itemType = this.buildingInfo.Type.ToString(); string uid = this.buildingInfo.Uid; int itemCount = 1; string type = "instant_building"; string subType = "consumable"; Service.DMOAnalyticsController.LogInAppCurrencyAction(currencyAmount, itemType, uid, itemCount, type, subType); EventManager eventManager = Service.EventManager; eventManager.RegisterObserver(this, EventId.MissionCollecting, EventPriority.Default); this.instantUpgradeBuildingKey = this.selectedBuilding.BuildingComp.BuildingTO.Key; this.instantUpgradeBuildingUid = this.nextBuildingInfo.Uid; try { ISupportController iSupportController = Service.ISupportController; iSupportController.StartBuildingUpgrade(this.nextBuildingInfo, this.selectedBuilding, true); iSupportController.BuyOutCurrentBuildingContract(this.selectedBuilding, false); } finally { eventManager.UnregisterObserver(this, EventId.MissionCollecting); this.HandleInstantUpgradeRequest(); } }
public void UpdateGeneratorAccruedCurrency(SmartEntity entity) { Building buildingTO = entity.BuildingComp.BuildingTO; BuildingTypeVO buildingType = entity.BuildingComp.BuildingType; bool flag = Service.BuildingController.SelectedBuilding == entity; ISupportController iSupportController = Service.ISupportController; if (iSupportController.FindCurrentContract(entity.BuildingComp.BuildingTO.Key) == null) { int accruedCurrency = buildingTO.AccruedCurrency; buildingTO.AccruedCurrency = this.UpdateAccruedCurrencyForView(buildingTO, buildingType); entity.GeneratorViewComp.ShowCollectButton(buildingTO.AccruedCurrency >= buildingType.CollectNotify); if (buildingTO.AccruedCurrency >= buildingType.Storage && accruedCurrency < buildingType.Storage) { Service.EventManager.SendEvent(EventId.GeneratorJustFilled, entity); } } if (flag) { string contextId = null; CurrencyType currency = buildingType.Currency; if (currency != CurrencyType.Credits) { if (currency != CurrencyType.Materials) { if (currency == CurrencyType.Contraband) { contextId = "Contraband"; } } else { contextId = "Materials"; } } else { contextId = "Credits"; } Service.UXController.HUD.ToggleContextButton(contextId, this.IsGeneratorCollectable(entity)); } }
private NotificationObject GetUnitsCompleteNotification() { if (Service.CurrentPlayer == null || Service.CurrentPlayer.CampaignProgress == null) { return(null); } if (Service.CurrentPlayer.CampaignProgress.FueInProgress || !(Service.GameStateMachine.CurrentState is HomeState)) { return(null); } NotificationTypeVO notificationTypeVO = Service.StaticDataController.Get <NotificationTypeVO>("notif2"); int num = 0; NodeList <SupportNode> nodeList = Service.EntityController.GetNodeList <SupportNode>(); ISupportController iSupportController = Service.ISupportController; for (SupportNode supportNode = nodeList.Head; supportNode != null; supportNode = supportNode.Next) { SmartEntity smartEntity = (SmartEntity)supportNode.Entity; BuildingComponent buildingComp = supportNode.BuildingComp; string key = buildingComp.BuildingTO.Key; if (!ContractUtils.IsBuildingUpgrading(smartEntity) && !ContractUtils.IsBuildingConstructing(smartEntity) && !iSupportController.IsBuildingFrozen(key)) { Contract contract = iSupportController.FindCurrentContract(key); if (contract != null && iSupportController.IsContractValidForStorage(contract)) { int num2 = ContractUtils.CalculateRemainingTimeOfAllTroopContracts(smartEntity); if (num2 > num) { num = num2; } } } } if (num >= notificationTypeVO.MinCompletionTime) { DateTime time = DateTime.Now.AddSeconds((double)num + 2.0); return(this.CreateReengagementNotification("notif2", time, true)); } return(null); }
public int CalculateTimeUntilAllGeneratorsFull() { NodeList <GeneratorViewNode> generatorViewNodeList = Service.Get <BuildingLookupController>().GeneratorViewNodeList; ISupportController supportController = Service.Get <ISupportController>(); int num = 0; if (generatorViewNodeList != null) { for (GeneratorViewNode generatorViewNode = generatorViewNodeList.Head; generatorViewNode != null; generatorViewNode = generatorViewNode.Next) { if (generatorViewNode.BuildingComp != null && supportController.FindCurrentContract(generatorViewNode.BuildingComp.BuildingTO.Key) == null) { int num2 = this.CalculateGeneratorFillTimeRemaining(generatorViewNode.Entity); if (num2 > num) { num = num2; } } } } return(num); }
public static bool HasExistingHeroContract(string heroUpgradeGroup) { bool result = false; IDataController dataController = Service.Get <IDataController>(); ISupportController supportController = Service.Get <ISupportController>(); BuildingLookupController buildingLookupController = Service.Get <BuildingLookupController>(); BuildingComponent buildingComp = buildingLookupController.TacticalCommandNodeList.Head.BuildingComp; string key = buildingComp.BuildingTO.Key; List <Contract> list = supportController.FindAllTroopContractsForBuilding(key); int i = 0; int count = list.Count; while (i < count) { TroopTypeVO troopTypeVO = dataController.Get <TroopTypeVO>(list[i].ProductUid); if (troopTypeVO.UpgradeGroup == heroUpgradeGroup) { result = true; break; } i++; } return(result); }