private List <NotificationObject> GetLongReengagementNotifs() { string text = "notif5"; NotificationTypeVO notificationTypeVO = Service.Get <IDataController>().Get <NotificationTypeVO>(text); if (notificationTypeVO.RepeatTime < 1) { Service.Get <StaRTSLogger>().Error("LongTermNotification has 0 repeat time"); return(null); } List <NotificationObject> list = new List <NotificationObject>(); string id = (this.notifMessageKeySuffix != null) ? ("notif_" + text + this.notifMessageKeySuffix) : ("notif_" + text); string message = this.lang.Get(id, new object[0]); string inProgressMessage = this.lang.Get("notif_" + text + "_progress", new object[0]); DateTime time = DateTime.get_Now().AddHours((double)notificationTypeVO.RepeatTime); this.EnsureValidNotificationTime(notificationTypeVO, time); int i = 0; while (i <= 4383) { NotificationObject item = new NotificationObject(text, inProgressMessage, message, notificationTypeVO.SoundName, time, text, text); list.Add(item); i += notificationTypeVO.RepeatTime; time = time.AddHours((double)notificationTypeVO.RepeatTime); } return(list); }
private List <NotificationObject> GetSquadWarNotifications() { SquadController squadController = Service.SquadController; if (squadController.StateManager.GetCurrentSquad() == null) { return(null); } SquadWarData currentSquadWar = squadController.WarManager.CurrentSquadWar; if (currentSquadWar == null) { return(null); } if (squadController.WarManager.GetCurrentParticipantState() == null) { return(null); } List <NotificationObject> list = new List <NotificationObject>(); uint serverTime = Service.ServerAPI.ServerTime; if ((long)currentSquadWar.PrepEndTimeStamp > (long)((ulong)serverTime)) { DateTime time = DateUtils.DateFromSeconds(currentSquadWar.PrepEndTimeStamp); NotificationObject item = this.CreateReengagementNotification("squadwars_action_phase_start", time, false); list.Add(item); } if ((long)currentSquadWar.ActionEndTimeStamp > (long)((ulong)serverTime)) { DateTime time2 = DateUtils.DateFromSeconds(currentSquadWar.ActionEndTimeStamp); NotificationObject item2 = this.CreateReengagementNotification("squadwars_reward_unknown", time2, false); list.Add(item2); } return(list); }
private List <NotificationObject> GetShortReengagementNotifs() { string text = "notif4"; string uid = "notif5"; NotificationTypeVO notificationTypeVO = Service.StaticDataController.Get <NotificationTypeVO>(text); NotificationTypeVO notificationTypeVO2 = Service.StaticDataController.Get <NotificationTypeVO>(uid); if (notificationTypeVO.RepeatTime < 1) { return(null); } if (notificationTypeVO2.RepeatTime < 1) { return(null); } List <NotificationObject> list = new List <NotificationObject>(); DateTime time = DateTime.Now.AddHours((double)notificationTypeVO.RepeatTime); this.EnsureValidNotificationTime(notificationTypeVO, time); string id = (this.notifMessageKeySuffix == null) ? ("notif_" + text) : ("notif_" + text + this.notifMessageKeySuffix); string message = this.lang.Get(id, new object[0]); string inProgressMessage = this.lang.Get("notif_" + text + "_progress", new object[0]); int i = 0; while (i < notificationTypeVO2.RepeatTime) { NotificationObject item = new NotificationObject(text, inProgressMessage, message, notificationTypeVO.SoundName, time, text, text); list.Add(item); i += notificationTypeVO.RepeatTime; time = time.AddHours((double)notificationTypeVO.RepeatTime); } return(list); }
public void BatchScheduleLocalNotifications(List <NotificationObject> list) { if (list == null) { return; } for (int i = 0; i < list.Count; i++) { NotificationObject notificationObject = list[i]; this.ScheduleLocalNotification(notificationObject.NotificationUid, notificationObject.InProgressMessage, notificationObject.Message, notificationObject.SoundName, notificationObject.Time, notificationObject.Key, notificationObject.ObjectId); } }
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); }
private void RescheduleAllLocalNotifications() { IState currentState = Service.Get <GameStateMachine>().CurrentState; if (!(currentState is HomeState)) { return; } List <NotificationObject> list = new List <NotificationObject>(); List <NotificationObject> buildingNotifications = this.GetBuildingNotifications(); if (buildingNotifications != null) { list.AddRange(buildingNotifications); } NotificationObject generatorNotification = this.GetGeneratorNotification(); if (generatorNotification != null) { list.Add(generatorNotification); } NotificationObject nextRaidNotification = this.GetNextRaidNotification(); if (nextRaidNotification != null) { list.Add(nextRaidNotification); } NotificationObject inventoryCrateExpirationNotification = this.GetInventoryCrateExpirationNotification(); if (inventoryCrateExpirationNotification != null) { list.Add(inventoryCrateExpirationNotification); } NotificationObject nextDailyCrateNotification = this.GetNextDailyCrateNotification(); if (nextDailyCrateNotification != null) { list.Add(nextDailyCrateNotification); } NotificationObject squadWarUseTurnNotification = this.GetSquadWarUseTurnNotification(); if (squadWarUseTurnNotification != null) { list.Add(squadWarUseTurnNotification); } NotificationObject unitsCompleteNotification = this.GetUnitsCompleteNotification(); if (unitsCompleteNotification != null) { list.Add(unitsCompleteNotification); } NotificationObject lastPerkExpiredNotification = this.GetLastPerkExpiredNotification(); if (lastPerkExpiredNotification != null) { list.Add(lastPerkExpiredNotification); } List <NotificationObject> shortReengagementNotifs = this.GetShortReengagementNotifs(); if (shortReengagementNotifs != null) { list.AddRange(shortReengagementNotifs); } List <NotificationObject> longReengagementNotifs = this.GetLongReengagementNotifs(); if (longReengagementNotifs != null) { list.AddRange(longReengagementNotifs); } this.notificationController.BatchScheduleLocalNotifications(list); }