using SimpleSoundManager.Framework; using SimpleSoundManager.Framework.Music; using StardewModdingAPI; namespace SimpleSoundManager { /// /// Mod core. /// /// Needs testing. /// /// Seems like the current structure will require both content packs and a programmed mod to request when to play specific sounds. Interesting. /// public class ModCore : Mod { internal static IModHelper ModHelper; internal static IMonitor ModMonitor; internal static Config Config; public static MusicManager MusicManager; /// The mod entry point, called after the mod is first loaded. /// Provides simplified APIs for writing mods. public override void Entry(IModHelper helper) { ModHelper = helper; ModMonitor = this.Monitor; Config = helper.ReadConfig(); this.loadContentPacks(); this.Helper.Events.GameLoop.OneSecondUpdateTicked += this.GameLoop_OneSecondUpdateTicked; this.Helper.Events.GameLoop.SaveLoaded += this.GameLoop_SaveLoaded; } private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) { //MusicManager.MusicPacks["Your Project Name"].PlaySound("toby fox - UNDERTALE Soundtrack - 01 Once Upon a Time"); //DebugLog("PLAY SOME SOUNDS"); } /// /// Update all music packs every second. /// /// /// private void GameLoop_OneSecondUpdateTicked(object sender, StardewModdingAPI.Events.OneSecondUpdateTickedEventArgs e) { foreach(MusicPack pack in MusicManager.MusicPacks.Values) { pack.update(); } } /// /// Loads all content packs for SimpleSoundManager /// private void loadContentPacks() { MusicManager = new MusicManager(); foreach (IContentPack contentPack in this.Helper.ContentPacks.GetOwned()) { this.Monitor.Log($"Reading content pack: {contentPack.Manifest.Name} {contentPack.Manifest.Version} from {contentPack.DirectoryPath}"); MusicPack musicPack = new MusicPack(contentPack); MusicManager.addMusicPack(musicPack, true, true); } } /// /// Easy way to display debug logs when allowing for a check to see if they are enabled. /// /// The message to display. public static void DebugLog(string s) { if (Config.EnableDebugLog) ModMonitor.Log(s); } } }