public bool TimerRunningOut() { StoryManager manager = StoryManager.StoryHandler; float threshold = manager.timerAlertMinHours; if (manager.Missions.Any(m => m.LatestState == MOState.Active && m.HasTimer && m.GetTimer < GenDate.TicksPerHour * threshold) || manager.GetObjectives.Any(m => m.CurrentState == MOState.Active && m.HasTimer && m.GetTimer < GenDate.TicksPerHour * threshold)) { return(true); } return(false); }
public override void PostMapGenerate(Map map) { base.PostMapGenerate(map); StoryManager manager = StoryManager.StoryHandler; manager.LockedMissions = LockedMissions; manager.Missions?.RemoveAll(m => LockedMissions.Any(d => m.def == d)); foreach (MissionDef def in UnlockedMissions) { manager.ActivateMission(def); } foreach (MissionDef def in FinishedMissions) { Mission mission = manager.ActivateMission(def); if (mission != null) { mission.LatestState = MOState.Finished; } } }
public override string GetExplanation() { StringBuilder sb = new StringBuilder(); StoryManager manager = StoryManager.StoryHandler; foreach (Mission mission in manager.Missions) { if (mission.HasTimer && mission.LatestState == MOState.Active && mission.GetTimer < GenDate.TicksPerHour * manager.timerAlertMinHours) { sb.AppendLine(" - " + mission.def.LabelCap + ": " + StoryUtils.GetTimerText(mission.GetTimer, MOState.Active)); } } foreach (Objective objective in manager.GetObjectives) { if (objective.def.type != ObjectiveType.Wait && objective.HasTimer && objective.CurrentState == MOState.Active && objective.GetTimer < GenDate.TicksPerHour * manager.timerAlertMinHours) { sb.AppendLine(" - " + objective.def.LabelCap + ": " + StoryUtils.GetTimerText(objective.GetTimer, MOState.Active)); } } return("TimerAlertDesc_SMO".Translate(sb.ToString())); }