private bool AppropriateNow(SongDef song) { if (!song.playOnMap) { return(false); } if (DangerMusicMode) { if (!song.tense) { return(false); } } else if (song.tense) { return(false); } Map map = Find.AnyPlayerHomeMap ?? Find.CurrentMap; if (!song.allowedSeasons.NullOrEmpty()) { if (map == null) { return(false); } if (!song.allowedSeasons.Contains(GenLocalDate.Season(map))) { return(false); } } if (song.minRoyalTitle != null && !PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_Colonists.Any((Pawn p) => p.royalty.AllTitlesForReading.Any() && p.royalty.MostSeniorTitle.def.seniority >= song.minRoyalTitle.seniority && !p.IsQuestLodger())) { return(false); } if (recentSongs.Contains(song)) { return(false); } if (song.allowedTimeOfDay != TimeOfDay.Any) { if (map == null) { return(true); } if (song.allowedTimeOfDay == TimeOfDay.Night) { if (!(GenLocalDate.DayPercent(map) < 0.2f)) { return(GenLocalDate.DayPercent(map) > 0.7f); } return(true); } if (GenLocalDate.DayPercent(map) > 0.2f) { return(GenLocalDate.DayPercent(map) < 0.7f); } return(false); } return(true); }
private SongDef ChooseNextSong() { this.songWasForced = false; if (this.forcedNextSong != null) { SongDef result = this.forcedNextSong; this.forcedNextSong = null; this.songWasForced = true; return(result); } IEnumerable <SongDef> source = from song in DefDatabase <SongDef> .AllDefs where this.AppropriateNow(song) select song; while (this.recentSongs.Count > 7) { this.recentSongs.Dequeue(); } while (!source.Any <SongDef>() && this.recentSongs.Count > 0) { this.recentSongs.Dequeue(); } if (!source.Any <SongDef>()) { Log.Error("Could not get any appropriate song. Getting random and logging song selection data.", false); this.SongSelectionData(); return(DefDatabase <SongDef> .GetRandom()); } return(source.RandomElementByWeight((SongDef s) => s.commonality)); }
private SongDef ChooseNextSong() { songWasForced = false; if (forcedNextSong != null) { SongDef result = forcedNextSong; forcedNextSong = null; songWasForced = true; return(result); } IEnumerable <SongDef> source = DefDatabase <SongDef> .AllDefs.Where((SongDef song) => AppropriateNow(song)); while (recentSongs.Count > 7) { recentSongs.Dequeue(); } while (!source.Any() && recentSongs.Count > 0) { recentSongs.Dequeue(); } if (!source.Any()) { Log.Error("Could not get any appropriate song. Getting random and logging song selection data."); SongSelectionData(); return(DefDatabase <SongDef> .GetRandom()); } return(source.RandomElementByWeight((SongDef s) => s.commonality)); }
private bool AppropriateNow(SongDef song) { bool result; if (!song.playOnMap) { result = false; } else { if (this.DangerMusicMode) { if (!song.tense) { return(false); } } else if (song.tense) { return(false); } Map map = Find.AnyPlayerHomeMap ?? Find.CurrentMap; if (!song.allowedSeasons.NullOrEmpty <Season>()) { if (map == null) { return(false); } if (!song.allowedSeasons.Contains(GenLocalDate.Season(map))) { return(false); } } if (this.recentSongs.Contains(song)) { result = false; } else if (song.allowedTimeOfDay != TimeOfDay.Any) { if (map == null) { result = true; } else if (song.allowedTimeOfDay == TimeOfDay.Night) { result = (GenLocalDate.DayPercent(map) < 0.2f || GenLocalDate.DayPercent(map) > 0.7f); } else { result = (GenLocalDate.DayPercent(map) > 0.2f && GenLocalDate.DayPercent(map) < 0.7f); } } else { result = true; } } return(result); }
public override void ResolveReferences(ThingDef parentDef) { foreach (SongDef s in from song in DefDatabase <SongDef> .AllDefs where song.defName == "Stop" select song) { stopSong = s; break; } }
private void StartNewSong() { this.lastStartedSong = this.ChooseNextSong(); this.audioSource.clip = this.lastStartedSong.clip; this.audioSource.volume = this.CurSanitizedVolume; this.audioSource.spatialBlend = 0f; this.audioSource.Play(); this.recentSongs.Enqueue(this.lastStartedSong); }
private void StartNewSong() { lastStartedSong = ChooseNextSong(); audioSource.clip = lastStartedSong.clip; audioSource.volume = CurSanitizedVolume; audioSource.spatialBlend = 0f; audioSource.Play(); recentSongs.Enqueue(lastStartedSong); }
public static void Postfix(ref bool __result, SongDef song) { Map map = Find.CurrentMap; Song_MapRestrictions ext = song.GetModExtension <Song_MapRestrictions>(); if (__result && map != null && ext != null && ext.BiomeDefRestrictions().Count() > 0) { __result = ext.BiomeDefRestrictions().Any(r => r.defName == map.Biome.defName); } }
private bool AppropriateNow(SongDef song) { if (!song.playOnMap) { return(false); } if (this.DangerMusicMode) { if (!song.tense) { return(false); } } else if (song.tense) { return(false); } Map map = Find.AnyPlayerHomeMap ?? Find.VisibleMap; if (!song.allowedSeasons.NullOrEmpty()) { if (map == null) { return(false); } if (!song.allowedSeasons.Contains(GenLocalDate.Season(map))) { return(false); } } if (this.recentSongs.Contains(song)) { return(false); } if (song.allowedTimeOfDay != TimeOfDay.Any) { if (map == null) { return(true); } if (song.allowedTimeOfDay == TimeOfDay.Night) { return(GenLocalDate.DayPercent(map) < 0.20000000298023224 || GenLocalDate.DayPercent(map) > 0.699999988079071); } return(GenLocalDate.DayPercent(map) > 0.20000000298023224 && GenLocalDate.DayPercent(map) < 0.699999988079071); } return(true); }
private bool <SongSelectionData> m__3(SongDef s) { return(this.AppropriateNow(s)); }
private static string <DebugString> m__2(SongDef s) { return(s.defName); }
private static float <ChooseNextSong> m__1(SongDef s) { return(s.commonality); }
private bool <ChooseNextSong> m__0(SongDef song) { return(this.AppropriateNow(song)); }
public void ForceStartSong(SongDef song, bool ignorePrefsVolume) { this.forcedNextSong = song; this.ignorePrefsVolumeThisSong = ignorePrefsVolume; this.StartNewSong(); }