/********* ** Public methods *********/ /// <summary>The mod entry point, called after the mod is first loaded.</summary> /// <param name="helper">Provides simplified APIs for writing mods.</param> public override void Entry(IModHelper helper) { ModHelper = helper; ModMonitor = this.Monitor; Config = helper.ReadConfig <Config>(); helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded; helper.Events.Player.Warped += this.OnPlayerWarped; helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked; helper.Events.Input.ButtonPressed += this.OnButtonPressed; helper.Events.GameLoop.Saving += this.OnSaving; helper.Events.GameLoop.TimeChanged += this.GameLoop_TimeChanged; helper.Events.Display.MenuChanged += this.OnMenuChanged; musicManager = new MusicManagerV2(); textureManager = new TextureManager("StardewSymphony"); this.LoadTextures(); menuChangedMusic = false; //Initialize all of the lists upon creation during entry. SongSpecificsV2.initializeMenuList(); SongSpecificsV2.initializeFestivalsList(); this.LoadMusicPacks(); }
/// <summary>Raised after a player warps to a new location.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnPlayerWarped(object sender, WarpedEventArgs e) { if (e.IsLocalPlayer) { musicManager.selectMusic(SongSpecificsV2.getCurrentConditionalString(), true); } }
/// <summary>Raised after the player loads a save slot and the world is initialised.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnSaveLoaded(object sender, SaveLoadedEventArgs e) { //Locaion initialization MUST occur after load. Anything else can occur before. SongSpecificsV2.initializeLocationsList(); //Gets all Game locations once the player has loaded the game, and all buildings on the player's farm and adds them to a location list. foreach (var musicPack in musicManager.MusicPacks) { musicPack.Value.LoadSettings(); } SongSpecificsV2.menus.Sort(); SongSpecificsV2.locations.Sort(); SongSpecificsV2.festivals.Sort(); SongSpecificsV2.events.Sort(); musicManager.selectMusic(SongSpecificsV2.getCurrentConditionalString()); }
/// <summary>Raised after a game menu is opened, closed, or replaced.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnMenuChanged(object sender, MenuChangedEventArgs e) { // menu closed if (e.NewMenu == null) { if (menuChangedMusic) { musicManager.selectMusic(SongSpecificsV2.getCurrentConditionalString()); menuChangedMusic = false; } } // menu changed else { musicManager.SelectMenuMusic(SongSpecificsV2.getCurrentConditionalString()); } }
private void GameLoop_TimeChanged(object sender, TimeChangedEventArgs e) { if (Game1.timeOfDay % 100 != 0) { return; //Only check on the hour. } if (musicManager.CurrentMusicPack != null) { //If there isn't another song already playing. Meaning a new song will play only if a different conditional is hit or this currently playing song finishes. if (musicManager.CurrentMusicPack.IsPlaying() == false) { musicManager.selectMusic(SongSpecificsV2.getCurrentConditionalString()); } } else { musicManager.selectMusic(SongSpecificsV2.getCurrentConditionalString()); } }