public static SquadWarStatusType GetWarStatus(SquadWarData data, uint serverTime) { if (data == null) { return(SquadWarStatusType.PhaseOpen); } if ((ulong)serverTime >= (ulong)((long)data.PrepGraceStartTimeStamp) && (ulong)serverTime <= (ulong)((long)data.PrepEndTimeStamp)) { return(SquadWarStatusType.PhasePrepGrace); } if ((ulong)serverTime < (ulong)((long)data.PrepEndTimeStamp)) { return(SquadWarStatusType.PhasePrep); } if ((ulong)serverTime >= (ulong)((long)data.ActionGraceStartTimeStamp) && (ulong)serverTime <= (ulong)((long)data.ActionEndTimeStamp)) { return(SquadWarStatusType.PhaseActionGrace); } if ((ulong)serverTime < (ulong)((long)data.ActionEndTimeStamp)) { return(SquadWarStatusType.PhaseAction); } if ((ulong)serverTime <= (ulong)((long)data.CooldownEndTimeStamp)) { return(SquadWarStatusType.PhaseCooldown); } return(SquadWarStatusType.PhaseOpen); }
public void InitSquadWarState(SquadWarData warData) { if (warData != null) { this.WarManager.UpdateSquadWar(warData); } }
public static bool FillOutWarPhaseTimeRange(SquadWarData data, SquadWarStatusType type, out int startTime, out int endTime) { bool result = false; startTime = 0; endTime = 0; if (data != null) { switch (type) { case SquadWarStatusType.PhasePrep: case SquadWarStatusType.PhasePrepGrace: result = true; startTime = data.StartTimeStamp; endTime = data.PrepEndTimeStamp; break; case SquadWarStatusType.PhaseAction: case SquadWarStatusType.PhaseActionGrace: result = true; startTime = data.PrepEndTimeStamp; endTime = data.ActionEndTimeStamp; break; case SquadWarStatusType.PhaseCooldown: result = true; startTime = data.ActionEndTimeStamp; endTime = data.CooldownEndTimeStamp; break; } } return(result); }
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 SquadWarParticipantState GetAdjacentParticipant(SquadWarParticipantState start, int direction) { SquadWarData currentSquadWar = Service.Get <SquadController>().WarManager.CurrentSquadWar; if (currentSquadWar == null) { return(start); } SquadWarSquadData squadWarSquadData = null; int num = -1; int i = 0; int num2 = currentSquadWar.Squads.Length; while (i < num2) { num = currentSquadWar.Squads[i].Participants.IndexOf(start); if (num != -1) { squadWarSquadData = currentSquadWar.Squads[i]; break; } i++; } if (num == -1) { return(start); } int count = squadWarSquadData.Participants.Count; int index = (count + num + direction) % count; return(squadWarSquadData.Participants[index]); }
public static bool CanStartMatchmakingPrep(SquadController squadController, BuildingLookupController blc) { SquadRole role = squadController.StateManager.Role; bool flag = role == SquadRole.Owner || role == SquadRole.Officer; int highestLevelHQ = blc.GetHighestLevelHQ(); bool flag2 = highestLevelHQ >= GameConstants.WAR_PARTICIPANT_MIN_LEVEL; SquadWarStatusType currentStatus = squadController.WarManager.GetCurrentStatus(); bool flag3 = currentStatus == SquadWarStatusType.PhaseCooldown || currentStatus == SquadWarStatusType.PhaseOpen; SquadWarData currentSquadWar = squadController.WarManager.CurrentSquadWar; bool flag4 = currentSquadWar == null || currentSquadWar.RewardsProcessed; return(flag2 & flag & flag3 & flag4); }
public void UpdateCurrentSquadWar() { if (this.IsValidUpdateGameState()) { SquadWarData currentSquadWar = this.controller.WarManager.CurrentSquadWar; if (currentSquadWar != null) { this.UpdateSquadWar(currentSquadWar.WarId, true); } } else { Service.EventManager.RegisterObserver(this, EventId.GameStateChanged); } }
public static bool IsTimeWithinSquadWarPhase(SquadWarData data, uint serverTime) { bool result = false; if (data != null && (ulong)serverTime >= (ulong)((long)data.StartTimeStamp) && (ulong)serverTime < (ulong)((long)data.CooldownEndTimeStamp)) { SquadWarStatusType warStatus = SquadUtils.GetWarStatus(data, Service.Get <ServerAPI>().ServerTime); int num = 0; int num2 = 0; if (SquadUtils.FillOutWarPhaseTimeRange(data, warStatus, out num, out num2)) { result = ((ulong)serverTime >= (ulong)((long)num) && (ulong)serverTime < (ulong)((long)num2)); } } return(result); }
private void OnCollectButtonClicked(UXButton button) { string text = button.Tag as string; this.HideCollectButton(text); SquadWarManager warManager = Service.Get <SquadController>().WarManager; SquadWarData currentSquadWar = warManager.CurrentSquadWar; if (currentSquadWar != null && currentSquadWar.WarId == text && warManager.GetCurrentStatus() == SquadWarStatusType.PhaseCooldown && !(Service.Get <GameStateMachine>().CurrentState is GalaxyState)) { Service.Get <UXController>().HUD.SlideSquadScreenClosedInstantly(); warManager.EnterWarBoardMode(); return; } warManager.ClaimSquadWarReward(text); }
public static SquadMsg GenerateMessageFromGetSquadWarStatusResponse(GetSquadWarStatusResponse response) { SquadWarSquadData squadWarSquadData = new SquadWarSquadData(); SquadWarSquadData squadWarSquadData2 = new SquadWarSquadData(); List <SquadWarBuffBaseData> list = new List <SquadWarBuffBaseData>(); squadWarSquadData.FromObject(response.Squad1Data); squadWarSquadData2.FromObject(response.Squad2Data); List <object> list2 = response.BuffBaseData as List <object>; int i = 0; int count = list2.Count; while (i < count) { SquadWarBuffBaseData squadWarBuffBaseData = new SquadWarBuffBaseData(); squadWarBuffBaseData.FromObject(list2[i]); list.Add(squadWarBuffBaseData); i++; } SquadWarData squadWarData = new SquadWarData(); squadWarData.WarId = response.Id; squadWarData.Squads[0] = squadWarSquadData; squadWarData.Squads[1] = squadWarSquadData2; squadWarData.BuffBases = list; squadWarData.PrepGraceStartTimeStamp = response.PrepGraceStartTimeStamp; squadWarData.PrepEndTimeStamp = response.PrepEndTimeStamp; squadWarData.ActionGraceStartTimeStamp = response.ActionGraceStartTimeStamp; squadWarData.ActionEndTimeStamp = response.ActionEndTimeStamp; squadWarData.StartTimeStamp = response.StartTimeStamp; squadWarData.CooldownEndTimeStamp = response.CooldownEndTimeStamp; squadWarData.RewardsProcessed = response.RewardsProcessed; return(new SquadMsg { CurrentSquadWarData = squadWarData }); }