update for SMAPI 3.0

This commit is contained in:
Jesse Plamondon-Willard 2019-01-06 02:21:06 -05:00
parent f4735a5883
commit 001cab1aba
No known key found for this signature in database
GPG Key ID: 7D7C8097B62033CE
53 changed files with 411 additions and 419 deletions

View File

@ -41,17 +41,17 @@ namespace Omegasis.SaveBackup
this.BackupSaves(SaveBackup.PrePlayBackupsPath);
SaveEvents.BeforeSave += this.SaveEvents_BeforeSave;
helper.Events.GameLoop.Saving += this.OnSaving;
}
/*********
** Private methods
*********/
/// <summary>The method invoked before the save is updated.</summary>
/// <summary>Raised before the game begins writes data to the save file (except the initial save creation).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void SaveEvents_BeforeSave(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
private void OnSaving(object sender, SavingEventArgs e)
{
this.BackupSaves(SaveBackup.NightlyBackupsPath);
}

View File

@ -5,6 +5,6 @@
"Description": "Backs up your save files when loading SMAPI and every in game night when saving.",
"UniqueID": "Omegasis.AdvancedSaveBackup",
"EntryDll": "AdvancedSaveBackup.dll",
"MinimumApiVersion": "2.0",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": [ "Nexus:435" ]
}

View File

@ -1,4 +1,3 @@
using System;
using Omegasis.AutoSpeed.Framework;
using StardewModdingAPI;
using StardewModdingAPI.Events;
@ -23,7 +22,7 @@ namespace Omegasis.AutoSpeed
/// <param name="helper">Provides simplified APIs for writing mods.</param>
public override void Entry(IModHelper helper)
{
GameEvents.UpdateTick += this.GameEvents_UpdateTick;
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
this.Config = helper.ReadConfig<ModConfig>();
}
@ -31,10 +30,10 @@ namespace Omegasis.AutoSpeed
/*********
** Private methods
*********/
/// <summary>The method invoked when the game updates (roughly 60 times per second).</summary>
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void GameEvents_UpdateTick(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
{
if (Context.IsPlayerFree)
Game1.player.addedSpeed = this.Config.Speed;

View File

@ -5,6 +5,6 @@
"Description": "Got to go fast!",
"UniqueID": "Omegasis.AutoSpeed",
"EntryDll": "AutoSpeed.dll",
"MinimumApiVersion": "2.0",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": [ "Nexus:443" ]
}

View File

@ -25,20 +25,20 @@ namespace Omegasis.BillboardAnywhere
{
this.Config = helper.ReadConfig<ModConfig>();
ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
helper.Events.Input.ButtonPressed += this.OnButtonPressed;
}
/*********
** Private methods
*********/
/// <summary>The method invoked when the presses a keyboard button.</summary>
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
public void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e)
/// <param name="e">The event arguments.</param>
public void OnButtonPressed(object sender, ButtonPressedEventArgs e)
{
// load menu if key pressed
if (Context.IsPlayerFree && e.KeyPressed.ToString() == this.Config.KeyBinding)
if (Context.IsPlayerFree && e.Button == this.Config.KeyBinding)
Game1.activeClickableMenu = new Billboard();
}
}

View File

@ -1,9 +1,11 @@
using StardewModdingAPI;
namespace Omegasis.BillboardAnywhere.Framework
{
/// <summary>The mod configuration.</summary>
internal class ModConfig
{
/// <summary>The key which shows the billboard menu.</summary>
public string KeyBinding { get; set; } = "B";
public SButton KeyBinding { get; set; } = SButton.B;
}
}

View File

@ -5,6 +5,6 @@
"Description": "Lets you view the billboard from anywhere.",
"UniqueID": "Omegasis.BillboardAnywhere",
"EntryDll": "BillboardAnywhere.dll",
"MinimumApiVersion": "2.0",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": [ "Nexus:492" ]
}

View File

@ -1,4 +1,3 @@
using System;
using System.IO;
using Omegasis.BuildEndurance.Framework;
using StardewModdingAPI;
@ -47,10 +46,9 @@ namespace Omegasis.BuildEndurance
{
this.Config = helper.ReadConfig<ModConfig>();
GameEvents.UpdateTick += this.GameEvents_UpdateTick;
GameEvents.OneSecondTick += this.GameEvents_OneSecondTick;
SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
SaveEvents.BeforeSave += this.SaveEvents_BeforeSave;
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
helper.Events.GameLoop.Saving += this.OnSaving;
this.ModHelper = this.Helper;
this.ModMonitor = this.Monitor;
@ -60,24 +58,18 @@ namespace Omegasis.BuildEndurance
/*********
** Private methods
*********/
/// <summary>The method invoked once per second during a game update.</summary>
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void GameEvents_OneSecondTick(object sender, EventArgs e)
{
// nerf how quickly tool xp is gained (I hope)
if (this.HasRecentToolExp)
this.HasRecentToolExp = false;
}
/// <summary>The method invoked when the game updates (roughly 60 times per second).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void GameEvents_UpdateTick(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
{
if (!Context.IsWorldReady)
return;
// nerf how quickly tool xp is gained (I hope)
if (e.IsOneSecond && this.HasRecentToolExp)
this.HasRecentToolExp = false;
// give XP when player finishes eating
if (Game1.player.isEating)
this.WasEating = true;
@ -112,10 +104,10 @@ namespace Omegasis.BuildEndurance
}
}
/// <summary>The method invoked after the player loads a save.</summary>
/// <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 data.</param>
private void SaveEvents_AfterLoad(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
{
// reset state
this.WasExhausted = false;
@ -150,10 +142,10 @@ namespace Omegasis.BuildEndurance
}
}
/// <summary>The method invoked just before the game is saved.</summary>
/// <summary>Raised before the game begins writes data to the save file (except the initial save creation).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void SaveEvents_BeforeSave(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
private void OnSaving(object sender, SavingEventArgs e)
{
// reset data
this.WasExhausted = false;

View File

@ -5,6 +5,6 @@
"Description": "Increase your health as you play.",
"UniqueID": "Omegasis.BuildEndurance",
"EntryDll": "BuildEndurance.dll",
"MinimumApiVersion": "2.0",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": [ "Nexus:445" ]
}

View File

@ -1,4 +1,3 @@
using System;
using System.IO;
using Omegasis.BuildHealth.Framework;
using StardewModdingAPI;
@ -42,10 +41,9 @@ namespace Omegasis.BuildHealth
/// <param name="helper">Provides simplified APIs for writing mods.</param>
public override void Entry(IModHelper helper)
{
GameEvents.UpdateTick += this.GameEvents_UpdateTick;
GameEvents.OneSecondTick += this.GameEvents_OneSecondTick;
TimeEvents.AfterDayStarted += this.SaveEvents_BeforeSave;
SaveEvents.AfterLoad += this.SaveEvents_AfterLoaded;
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
helper.Events.GameLoop.DayStarted += this.OnDayStarted;
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
this.Config = helper.ReadConfig<ModConfig>();
}
@ -54,24 +52,18 @@ namespace Omegasis.BuildHealth
/*********
** Private methods
*********/
/// <summary>The method invoked once per second during a game update.</summary>
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void GameEvents_OneSecondTick(object sender, EventArgs e)
{
// nerf how quickly tool xp is gained (I hope)
if (this.HasRecentToolExp)
this.HasRecentToolExp = false;
}
/// <summary>The method invoked when the game updates (roughly 60 times per second).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void GameEvents_UpdateTick(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
{
if (!Context.IsWorldReady)
return;
// nerf how quickly tool xp is gained (I hope)
if (e.IsOneSecond && this.HasRecentToolExp)
this.HasRecentToolExp = false;
// give XP when player finishes eating
if (Game1.player.isEating)
this.WasEating = true;
@ -106,10 +98,10 @@ namespace Omegasis.BuildHealth
}
}
/// <summary>The method invoked after the player loads a save.</summary>
/// <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 data.</param>
private void SaveEvents_AfterLoaded(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
{
// reset state
this.HasRecentToolExp = false;
@ -140,10 +132,10 @@ namespace Omegasis.BuildHealth
Game1.player.maxHealth = this.PlayerData.BaseHealthBonus + this.PlayerData.CurrentLevelHealthBonus + this.PlayerData.OriginalMaxHealth;
}
/// <summary>The method invoked just before the game saves.</summary>
/// <summary>Raised after the game begins a new day (including when the player loads a save).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void SaveEvents_BeforeSave(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
private void OnDayStarted(object sender, DayStartedEventArgs e)
{
// reset data
this.LastHealth = Game1.player.maxHealth;

View File

@ -5,6 +5,6 @@
"Description": "Increase your health as you play.",
"UniqueID": "Omegasis.BuildHealth",
"EntryDll": "BuildHealth.dll",
"MinimumApiVersion": "2.0",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": [ "Nexus:446" ]
}

View File

@ -24,19 +24,19 @@ namespace Omegasis.BuyBackCollectables
{
this.Config = helper.ReadConfig<ModConfig>();
ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
helper.Events.Input.ButtonPressed += this.OnButtonPressed;
}
/*********
** Private methods
*********/
/// <summary>The method invoked when the presses a keyboard button.</summary>
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
public void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e)
/// <param name="e">The event arguments.</param>
private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
{
if (Context.IsPlayerFree && e.KeyPressed.ToString() == this.Config.KeyBinding)
if (Context.IsPlayerFree && e.Button == this.Config.KeyBinding)
Game1.activeClickableMenu = new BuyBackMenu(this.Config.CostMultiplier);
}
}

View File

@ -1,10 +1,12 @@
using StardewModdingAPI;
namespace Omegasis.BuyBackCollectables.Framework
{
/// <summary>The mod configuration.</summary>
internal class ModConfig
{
/// <summary>The key which shows the menu.</summary>
public string KeyBinding { get; set; } = "B";
public SButton KeyBinding { get; set; } = SButton.B;
/// <summary>The multiplier applied to the cost of buying back a collectable.</summary>
public double CostMultiplier { get; set; } = 3.0;

View File

@ -5,6 +5,6 @@
"Description": "Lets you buy back any obtained collectable.",
"UniqueID": "Omegasis.BuyBackCollectables",
"EntryDll": "BuyBackCollectables.dll",
"MinimumApiVersion": "2.0",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": [ "Nexus:507" ]
}

View File

@ -9,6 +9,7 @@ using CustomNPCFramework.Framework.NPCS;
using CustomNPCFramework.Framework.Utilities;
using Microsoft.Xna.Framework;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley;
namespace CustomNPCFramework
@ -64,13 +65,10 @@ namespace CustomNPCFramework
ModMonitor = this.Monitor;
Manifest = this.ModManifest;
StardewModdingAPI.Events.SaveEvents.AfterLoad += this.SaveEvents_LoadChar;
StardewModdingAPI.Events.SaveEvents.BeforeSave += this.SaveEvents_BeforeSave;
StardewModdingAPI.Events.SaveEvents.AfterSave += this.SaveEvents_AfterSave;
StardewModdingAPI.Events.PlayerEvents.Warped += this.LocationEvents_CurrentLocationChanged;
StardewModdingAPI.Events.GameEvents.UpdateTick += this.GameEvents_UpdateTick;
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
helper.Events.GameLoop.Saving += this.OnSaving;
helper.Events.GameLoop.Saved += this.OnSaved;
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
npcTracker = new NpcTracker();
assetPool = new AssetPool();
var assetManager = new AssetManager();
@ -87,27 +85,30 @@ namespace CustomNPCFramework
assetPool.getAssetManager("testNPC").addPathCreateDirectory(new KeyValuePair<string, string>("characters", relativePath));
}
/// <summary>A function that is called when the game finishes saving.</summary>
/// <summary>Raised after the game finishes writing data to the save file (except the initial save creation).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event arguments.</param>
private void SaveEvents_AfterSave(object sender, EventArgs e)
private void OnSaved(object sender, SavedEventArgs e)
{
npcTracker.afterSave();
}
/// <summary>A function that is called when the game is about to load. Used to clean up all the npcs from the game world to prevent it from crashing.</summary>
/// <summary>Raised before the game begins writes data to the save file (except the initial save creation).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event arguments.</param>
private void SaveEvents_BeforeSave(object sender, EventArgs e)
private void OnSaving(object sender, SavingEventArgs e)
{
// clean up all the npcs from the game world to prevent it from crashing
npcTracker.cleanUpBeforeSave();
}
/// <summary>Called upon 60 times a second. For testing purposes only. Will remove in future release.</summary>
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event arguments.</param>
private void GameEvents_UpdateTick(object sender, EventArgs e)
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
{
// TODO For testing purposes only. Will remove in future release.
/*
if (Game1.player.currentLocation == null) return;
if (Game1.activeClickableMenu != null) return;
@ -124,16 +125,13 @@ namespace CustomNPCFramework
*/
}
/// <summary>Called when the player's location changes.</summary>
/// <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 LocationEvents_CurrentLocationChanged(object sender, StardewModdingAPI.Events.EventArgsPlayerWarped e) { }
/// <summary>Used to spawn a custom npc just as an example. Don't keep this code. GENERATE NPC AND CALL THE CODE</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event arguments.</param>
private void SaveEvents_LoadChar(object sender, EventArgs e)
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
{
// TODO Used to spawn a custom npc just as an example. Don't keep this code. GENERATE NPC AND CALL THE CODE
ExtendedNpc myNpc3 = assetPool.generateNPC(Genders.female, 0, 1, new StandardColorCollection(null, null, Color.Blue, null, Color.Yellow, null));
MerchantNpc merch = new MerchantNpc(new List<Item>()
{

View File

@ -1,11 +1,11 @@
{
"Name": "CustomNPCFramework",
"Name": "Custom NPC Framework",
"Author": "Alpha_Omegasis",
"Version": "0.1.0",
"Description": "A system to add custom npcs to Stardew.",
"Description": "A system to add custom NPCs to Stardew.",
"UniqueID": "Omegasis.CustomNPCFramework",
"EntryDll": "CustomNPCFramework.dll",
"MinimumApiVersion": "2.0",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": [],
"Dependencies": [
{ "UniqueID": "Omegasis.StardustCore" }

View File

@ -32,43 +32,43 @@ namespace Omegasis.DailyQuestAnywhere
{
this.Config = helper.ReadConfig<ModConfig>();
ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
SaveEvents.AfterSave += this.SaveEvents_AfterSave;
helper.Events.Input.ButtonPressed += this.OnButtonPressed;
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
}
/*********
** Private methods
*********/
/// <summary>The method invoked when the presses a keyboard button.</summary>
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e)
/// <param name="e">The event arguments.</param>
private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
{
if (Context.IsPlayerFree && e.Button == this.Config.KeyBinding)
{
if (Context.IsPlayerFree && e.KeyPressed.ToString() == this.Config.KeyBinding)
if (!Game1.player.hasDailyQuest())
{
if (this.dailyQuest == null)
{
this.dailyQuest = this.generateDailyQuest();
}
Game1.questOfTheDay = this.dailyQuest;
Game1.activeClickableMenu = new Billboard(true);
}
}
}
/// <summary>Makes my daily quest referene null so we can't just keep getting a new reference.</summary>
/// <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 data.</param>
private void SaveEvents_AfterSave(object sender, System.EventArgs e)
/// <param name="e">The event arguments.</param>
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
{
this.dailyQuest = null; //Nullify my quest reference.
// makes daily quest null so we can't just keep getting a new reference
this.dailyQuest = null;
}
/// <summary>Generate a daily quest for sure.</summary>
public Quest generateDailyQuest()
{
Random chanceRandom = new Random((int)Game1.uniqueIDForThisGame + (int)Game1.stats.DaysPlayed);
int chance = chanceRandom.Next(0, 101);
float actualChance = chance / 100;
@ -85,15 +85,15 @@ namespace Omegasis.DailyQuestAnywhere
case 1:
return new FishingQuest();
case 2:
return new StardewValley.Quests.CraftingQuest();
return new CraftingQuest();
case 3:
return new StardewValley.Quests.ItemDeliveryQuest();
return new ItemDeliveryQuest();
case 4:
return new StardewValley.Quests.ItemHarvestQuest();
return new ItemHarvestQuest();
case 5:
return new StardewValley.Quests.ResourceCollectionQuest();
return new ResourceCollectionQuest();
case 6:
return new StardewValley.Quests.SlayMonsterQuest();
return new SlayMonsterQuest();
}
}
return null; //This should never happen.

View File

@ -1,10 +1,12 @@
using StardewModdingAPI;
namespace Omegasis.DailyQuestAnywhere.Framework
{
/// <summary>The mod configuration.</summary>
internal class ModConfig
{
/// <summary>The key which shows the menu.</summary>
public string KeyBinding { get; set; } = "H";
public SButton KeyBinding { get; set; } = SButton.H;
/// <summary>The chance for a daily quest to actually happen.</summary>
public float chanceForDailyQuest { get; set; } = .75f;

View File

@ -5,6 +5,6 @@
"Description": "Open the daily quest board from anywhere in the game.",
"UniqueID": "Omegasis.DailyQuestAnywhere",
"EntryDll": "DailyQuestAnywhere.dll",
"MinimumApiVersion": "2.0",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": [ "Nexus:513" ]
}

View File

@ -1,4 +1,3 @@
using System;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley;
@ -15,17 +14,17 @@ namespace Omegasis.Fall28SnowDay
/// <param name="helper">Provides simplified APIs for writing mods.</param>
public override void Entry(IModHelper helper)
{
SaveEvents.BeforeSave += this.SaveEvents_BeforeSave;
helper.Events.GameLoop.Saving += this.OnSaving;
}
/*********
** Private methods
*********/
/// <summary>The method invoked just before the game saves.</summary>
/// <summary>Raised before the game begins writes data to the save file (except the initial save creation).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
public void SaveEvents_BeforeSave(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
public void OnSaving(object sender, SavingEventArgs e)
{
if (Game1.IsFall && Game1.dayOfMonth == 27)
Game1.weatherForTomorrow = Game1.weather_snow;

View File

@ -5,6 +5,6 @@
"Description": "Makes it snow on Fall 28, which makes a good explanation for all the snow on the next day.",
"UniqueID": "Omegasis.Fall28SnowDay",
"EntryDll": "Fall28SnowDay.dll",
"MinimumApiVersion": "2.0",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": [ "Nexus:486" ]
}

View File

@ -3,6 +3,7 @@ using EventSystem.Framework.FunctionEvents;
using FarmersMarketStall.Framework.MapEvents;
using Microsoft.Xna.Framework;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley;
namespace FarmersMarketStall
@ -29,17 +30,23 @@ namespace FarmersMarketStall
ModHelper = this.Helper;
ModMonitor = this.Monitor;
StardewModdingAPI.Events.SaveEvents.BeforeSave += this.SaveEvents_BeforeSave;
StardewModdingAPI.Events.SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
helper.Events.GameLoop.Saving += this.OnSaving;
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
marketStall = new Framework.MarketStall();
}
private void SaveEvents_AfterLoad(object sender, EventArgs e)
/// <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, EventArgs e)
{
EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new ShopInteractionEvent("FarmersMarketStall", Game1.getLocationFromName("BusStop"), new Vector2(6, 11), new MouseButtonEvents(null, true), new MouseEntryLeaveEvent(null, null)));
}
private void SaveEvents_BeforeSave(object sender, EventArgs e)
/// <summary>Raised before the game begins writes data to the save file (except the initial save creation).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event arguments.</param>
private void OnSaving(object sender, SavingEventArgs e)
{
if (marketStall.stock.Count > 0)
{

View File

@ -1,11 +1,11 @@
{
"Name": "FarmersMarketStall",
"Name": "Farmers Market Stall",
"Author": "Alpha_Omegasis",
"Version": "0.1.0",
"Description": "A system to add a farmers market stall to Sundrop.",
"UniqueID": "SunDrop.SunDropMapEvents.FarmersMarketStall",
"EntryDll": "FarmersMarketStall.dll",
"MinimumApiVersion": "2.0",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": [],
"Dependencies": [
{ "UniqueID": "Omegasis.EventSystem" }

View File

@ -1,10 +1,12 @@
using StardewModdingAPI;
namespace Omegasis.HappyBirthday.Framework
{
/// <summary>The mod configuration.</summary>
public class ModConfig
{
/// <summary>The key which shows the menu.</summary>
public string KeyBinding { get; set; } = "O";
public SButton KeyBinding { get; set; } = SButton.O;
/// <summary>The minimum amount of friendship needed to get a birthday gift.</summary>
public int minNeutralFriendshipGiftLevel = 3;

View File

@ -76,16 +76,15 @@ namespace Omegasis.HappyBirthday
//helper.Content.AssetLoaders.Add(new PossibleGifts());
Config = helper.ReadConfig<ModConfig>();
TimeEvents.AfterDayStarted += this.TimeEvents_AfterDayStarted;
GameEvents.UpdateTick += this.GameEvents_UpdateTick;
SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
SaveEvents.BeforeSave += this.SaveEvents_BeforeSave;
ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
MenuEvents.MenuChanged += this.MenuEvents_MenuChanged;
MenuEvents.MenuClosed += this.MenuEvents_MenuClosed;
helper.Events.GameLoop.DayStarted += this.OnDayStarted;
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
helper.Events.GameLoop.Saving += this.OnSaving;
helper.Events.Input.ButtonPressed += this.OnButtonPressed;
helper.Events.Display.MenuChanged += this.OnMenuChanged;
GraphicsEvents.OnPostRenderGuiEvent += this.GraphicsEvents_OnPostRenderGuiEvent;
StardewModdingAPI.Events.GraphicsEvents.OnPostRenderHudEvent += this.GraphicsEvents_OnPostRenderHudEvent;
helper.Events.Display.RenderedActiveMenu += this.OnRenderedActiveMenu;
helper.Events.Display.RenderedHud += this.OnRenderedHud;
//MultiplayerSupport.initializeMultiplayerSupport();
ModHelper = this.Helper;
ModMonitor = this.Monitor;
@ -113,13 +112,9 @@ namespace Omegasis.HappyBirthday
/// <param name="asset">A helper which encapsulates metadata about an asset and enables changes to it.</param>
public void Edit<T>(IAssetData asset)
{
asset
.AsDictionary<string, string>()
.Set("birthdayMom", "Dear @,^ Happy birthday sweetheart. It's been amazing watching you grow into the kind, hard working person that I've always dreamed that you would become. I hope you continue to make many more fond memories with the ones you love. ^ Love, Mom ^ P.S. Here's a little something that I made for you. %item object 221 1 %%");
asset
.AsDictionary<string, string>()
.Set("birthdayDad", "Dear @,^ Happy birthday kiddo. It's been a little quiet around here on your birthday since you aren't around, but your mother and I know that you are making both your grandpa and us proud. We both know that living on your own can be tough but we believe in you one hundred percent, just keep following your dreams.^ Love, Dad ^ P.S. Here's some spending money to help you out on the farm. Good luck! %item money 5000 5001 %%");
IDictionary<string, string> data = asset.AsDictionary<string, string>().Data;
data["birthdayMom"] = "Dear @,^ Happy birthday sweetheart. It's been amazing watching you grow into the kind, hard working person that I've always dreamed that you would become. I hope you continue to make many more fond memories with the ones you love. ^ Love, Mom ^ P.S. Here's a little something that I made for you. %item object 221 1 %%";
data["birthdayDad"] = "Dear @,^ Happy birthday kiddo. It's been a little quiet around here on your birthday since you aren't around, but your mother and I know that you are making both your grandpa and us proud. We both know that living on your own can be tough but we believe in you one hundred percent, just keep following your dreams.^ Love, Dad ^ P.S. Here's some spending money to help you out on the farm. Good luck! %item money 5000 5001 %%";
}
@ -161,33 +156,25 @@ namespace Omegasis.HappyBirthday
}
}
/// <summary>Used to check when a menu is closed.</summary>
/// <summary>Raised after drawing the HUD (item toolbar, clock, etc) to the sprite batch, but before it's rendered to the screen.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event arguments.</param>
private void MenuEvents_MenuClosed(object sender, EventArgsClickableMenuClosed e)
private void OnRenderedHud(object sender, RenderedHudEventArgs e)
{
this.isDailyQuestBoard = false;
}
if (Game1.activeClickableMenu == null || this.PlayerData?.BirthdaySeason?.ToLower() != Game1.currentSeason.ToLower())
return;
/// <summary>Used to properly display hovertext for all events happening on a calendar day.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event arguments.</param>
private void GraphicsEvents_OnPostRenderHudEvent(object sender, EventArgs e)
if (Game1.activeClickableMenu is Billboard billboard)
{
if (Game1.activeClickableMenu == null) return;
if (this.PlayerData?.BirthdaySeason == null) return;
if (this.PlayerData.BirthdaySeason.ToLower() != Game1.currentSeason.ToLower()) return;
if (Game1.activeClickableMenu is Billboard)
{
if (this.isDailyQuestBoard) return;
if ((Game1.activeClickableMenu as Billboard).calendarDays == null) return;
if (this.isDailyQuestBoard || billboard.calendarDays == null)
return;
//Game1.player.FarmerRenderer.drawMiniPortrat(Game1.spriteBatch, new Vector2(Game1.activeClickableMenu.xPositionOnScreen + 152 + (index - 1) % 7 * 32 * 4, Game1.activeClickableMenu.yPositionOnScreen + 230 + (index - 1) / 7 * 32 * 4), 1f, 4f, 2, Game1.player);
string hoverText = "";
List<string> texts = new List<string>();
foreach (var clicky in ((Billboard)Game1.activeClickableMenu).calendarDays)
foreach (var clicky in billboard.calendarDays)
{
if (clicky.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
{
@ -213,10 +200,10 @@ namespace Omegasis.HappyBirthday
}
}
/// <summary>Used to show the farmer's portrait on the billboard menu.</summary>
/// <summary>When a menu is open (<see cref="Game1.activeClickableMenu"/> isn't null), raised after that menu is drawn to the sprite batch but before it's rendered to the screen.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event arguments.</param>
private void GraphicsEvents_OnPostRenderGuiEvent(object sender, EventArgs e)
private void OnRenderedActiveMenu(object sender, RenderedActiveMenuEventArgs e)
{
if (Game1.activeClickableMenu == null || this.isDailyQuestBoard)
return;
@ -246,20 +233,22 @@ namespace Omegasis.HappyBirthday
}
}
/// <summary>Functionality to display the player's birthday on the billboard.</summary>
/// <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 MenuEvents_MenuChanged(object sender, EventArgsClickableMenuChanged e)
private void OnMenuChanged(object sender, MenuChangedEventArgs e)
{
if (Game1.activeClickableMenu == null)
switch (e.NewMenu)
{
case null:
this.isDailyQuestBoard = false;
return;
}
if (Game1.activeClickableMenu is Billboard)
case Billboard billboard:
{
this.isDailyQuestBoard = ModHelper.Reflection.GetField<bool>((Game1.activeClickableMenu as Billboard), "dailyQuestBoard", true).GetValue();
if (this.isDailyQuestBoard) return;
if (this.isDailyQuestBoard)
return;
Texture2D text = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1);
Color[] col = new Color[1];
@ -273,7 +262,7 @@ namespace Omegasis.HappyBirthday
{
int index = this.PlayerData.BirthdayDay;
Rectangle birthdayRect = new Rectangle(Game1.activeClickableMenu.xPositionOnScreen + 152 + (index - 1) % 7 * 32 * 4, Game1.activeClickableMenu.yPositionOnScreen + 200 + (index - 1) / 7 * 32 * 4, 124, 124);
(Game1.activeClickableMenu as Billboard).calendarDays.Add(new ClickableTextureComponent("", birthdayRect, "", Game1.player.name + "'s Birthday", text, new Rectangle(0, 0, 124, 124), 1f, false));
billboard.calendarDays.Add(new ClickableTextureComponent("", birthdayRect, "", $"{Game1.player.Name}'s Birthday", text, new Rectangle(0, 0, 124, 124), 1f, false));
}
}
@ -282,36 +271,39 @@ namespace Omegasis.HappyBirthday
if (pair.Value.BirthdaySeason != Game1.currentSeason.ToLower()) continue;
int index = pair.Value.BirthdayDay;
Rectangle otherBirthdayRect = new Rectangle(Game1.activeClickableMenu.xPositionOnScreen + 152 + (index - 1) % 7 * 32 * 4, Game1.activeClickableMenu.yPositionOnScreen + 200 + (index - 1) / 7 * 32 * 4, 124, 124);
(Game1.activeClickableMenu as Billboard).calendarDays.Add(new ClickableTextureComponent("", otherBirthdayRect, "", Game1.getFarmer(pair.Key).name + "'s Birthday", text, new Rectangle(0, 0, 124, 124), 1f, false));
billboard.calendarDays.Add(new ClickableTextureComponent("", otherBirthdayRect, "", $"{Game1.getFarmer(pair.Key).Name}'s Birthday", text, new Rectangle(0, 0, 124, 124), 1f, false));
}
break;
}
}
}
/// <summary>The method invoked after a new day starts.</summary>
/// <summary>Raised after the game begins a new day (including when the player loads a save).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void TimeEvents_AfterDayStarted(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
private void OnDayStarted(object sender, DayStartedEventArgs e)
{
this.CheckedForBirthday = false;
}
/// <summary>The method invoked when the presses a keyboard button.</summary>
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e)
/// <param name="e">The event arguments.</param>
private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
{
// show birthday selection menu
if (Game1.activeClickableMenu != null) return;
if (Context.IsPlayerFree && !this.HasChosenBirthday && e.KeyPressed.ToString() == Config.KeyBinding)
if (Context.IsPlayerFree && !this.HasChosenBirthday && e.Button == Config.KeyBinding)
Game1.activeClickableMenu = new BirthdayMenu(this.PlayerData.BirthdaySeason, this.PlayerData.BirthdayDay, this.SetBirthday);
}
/// <summary>The method invoked after the player loads a save.</summary>
/// <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 data.</param>
private void SaveEvents_AfterLoad(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
{
this.DataFilePath = Path.Combine("data", Game1.player.Name + "_" + Game1.player.UniqueMultiplayerID + ".json");
this.DataFilePath = Path.Combine("data", $"{Game1.player.Name}_{Game1.player.UniqueMultiplayerID}.json");
// reset state
this.VillagerQueue = new List<string>();
@ -332,19 +324,19 @@ namespace Omegasis.HappyBirthday
//this.Dialogue = new Dictionary<string, Dialogue>();
}
/// <summary>The method invoked just before the game updates the saves.</summary>
/// <summary>Raised before the game begins writes data to the save file (except the initial save creation).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void SaveEvents_BeforeSave(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
private void OnSaving(object sender, SavingEventArgs e)
{
if (this.HasChosenBirthday)
this.Helper.Data.WriteJsonFile(this.DataFilePath, this.PlayerData);
}
/// <summary>The method invoked when the game updates (roughly 60 times per second).</summary>
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void GameEvents_UpdateTick(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
{
if (!Context.IsWorldReady || Game1.eventUp || Game1.isFestival())
return;

View File

@ -5,6 +5,6 @@
"Description": "Adds the farmer's birthday to the game.",
"UniqueID": "Omegasis.HappyBirthday",
"EntryDll": "HappyBirthday.dll",
"MinimumApiVersion": "2.9",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": [ "Nexus:520" ]
}

View File

@ -1,6 +1,6 @@
using System;
using EventSystem.Framework;
using StardewModdingAPI;
using StardewModdingAPI.Events;
namespace EventSystem
{
@ -18,16 +18,22 @@ namespace EventSystem
{
ModHelper = this.Helper;
ModMonitor = this.Monitor;
StardewModdingAPI.Events.GameEvents.UpdateTick += this.GameEvents_UpdateTick;
StardewModdingAPI.Events.SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
}
private void SaveEvents_AfterLoad(object sender, EventArgs e)
/// <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)
{
eventManager = new EventManager();
}
private void GameEvents_UpdateTick(object sender, EventArgs e)
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event arguments.</param>
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
{
eventManager?.update();
}

View File

@ -1,10 +1,10 @@
{
"Name": "EventSystem",
"Name": "Event System",
"Author": "Alpha_Omegasis",
"Version": "0.1.0",
"Description": "A system to manage different events that can happen on the map.",
"UniqueID": "Omegasis.EventSystem",
"EntryDll": "EventSystem.dll",
"MinimumApiVersion": "2.0",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": []
}

View File

@ -29,26 +29,26 @@ namespace Omegasis.MoreRain
{
this.Config = helper.ReadConfig<ModConfig>();
SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
SaveEvents.BeforeSave += this.SaveEvents_BeforeSave;
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
helper.Events.GameLoop.Saving += this.OnSaving;
}
/*********
** Private methods
*********/
/// <summary>The method invoked after the player loads a save.</summary>
/// <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 data.</param>
private void SaveEvents_AfterLoad(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
{
this.HandleNewDay();
}
/// <summary>The method invoked before the game is saved.</summary>
/// <summary>Raised before the game begins writes data to the save file (except the initial save creation).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void SaveEvents_BeforeSave(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
private void OnSaving(object sender, SavingEventArgs e)
{
this.HandleNewDay();
}

View File

@ -5,6 +5,6 @@
"Description": "Change how much it rains in the game.",
"UniqueID": "Omegasis.MoreRain",
"EntryDll": "MoreRain.dll",
"MinimumApiVersion": "2.0",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": [ "Nexus:441" ]
}

View File

@ -1,12 +1,14 @@
using StardewModdingAPI;
namespace Omegasis.MuseumRearranger.Framework
{
/// <summary>The mod configuration.</summary>
internal class ModConfig
{
/// <summary>The key which shows the museum rearranging menu.</summary>
public string ShowMenuKey { get; set; } = "R";
public SButton ShowMenuKey { get; set; } = SButton.R;
/// <summary>The key which toggles the inventory box when the menu is open.</summary>
public string ToggleInventoryKey { get; set; } = "T";
public SButton ToggleInventoryKey { get; set; } = SButton.T;
}
}

View File

@ -28,23 +28,23 @@ namespace Omegasis.MuseumRearranger
{
this.Config = helper.ReadConfig<ModConfig>();
ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
helper.Events.Input.ButtonPressed += this.OnButtonPressed;
}
/*********
** Private methods
*********/
/// <summary>The method invoked when the presses a keyboard button.</summary>
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e)
/// <param name="e">The event arguments.</param>
private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
{
if (!Context.IsWorldReady)
return;
// open menu
if (e.KeyPressed.ToString() == this.Config.ShowMenuKey)
if (e.Button == this.Config.ShowMenuKey)
{
if (Game1.activeClickableMenu != null)
return;
@ -55,7 +55,7 @@ namespace Omegasis.MuseumRearranger
}
// toggle inventory box
if (e.KeyPressed.ToString() == this.Config.ToggleInventoryKey)
if (e.Button == this.Config.ToggleInventoryKey)
this.OpenMenu?.ToggleInventory();
}
}

View File

@ -5,6 +5,6 @@
"Description": "Lets you rearrange the museum without needing to donate something.",
"UniqueID": "Omegasis.MuseumRearranger",
"EntryDll": "MuseumRearranger.dll",
"MinimumApiVersion": "2.3",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": [ "Nexus:428" ]
}

View File

@ -5,14 +5,18 @@ namespace Omegasis.NightOwl.Framework
{
class NightFishing : IAssetEditor
{
/// <summary>Get whether this instance can edit the given asset.</summary>
/// <param name="asset">Basic metadata about the asset being loaded.</param>
public bool CanEdit<T>(IAssetInfo asset)
{
return asset.AssetNameEquals(@"Data\Fish");
}
/// <summary>Edit a matched asset.</summary>
/// <param name="asset">A helper which encapsulates metadata about an asset and enables changes to it.</param>
public void Edit<T>(IAssetData asset)
{
Dictionary<int, string> nightFish = new Dictionary<int, string> // (T)(object) is a trick to cast anything to T if we know it's compatible
Dictionary<int, string> nightFish = new Dictionary<int, string>
{
[128] = "Pufferfish/80/floater/1/36/1200 1600/summer/sunny/690 .4 685 .1/4/.3/.5/0",
[129] = "Anchovy/30/dart/1/16/600 3000/spring fall/both/682 .2/1/.25/.3/0",
@ -78,10 +82,10 @@ namespace Omegasis.NightOwl.Framework
[799] = "Spook Fish/60/dart/8/25/600 3000/spring summer fall winter/both/685 .35/3/.4/.1/0",
[800] = "Blobfish/75/floater/8/25/600 3000/spring summer fall winter/both/685 .35/3/.4/.1/0",
};
IDictionary<int, string> data = asset.AsDictionary<int, string>().Data;
foreach (KeyValuePair<int, string> pair in nightFish)
{
asset.AsDictionary<int, string>().Set(pair.Key, pair.Value);
}
data[pair.Key] = pair.Value;
}
}
}

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Xna.Framework;
using Netcode;
@ -91,12 +90,11 @@ namespace Omegasis.NightOwl
if (this.Config.UseInternalNightFishAssetEditor)
this.Helper.Content.AssetEditors.Add(new NightFishing());
TimeEvents.TimeOfDayChanged += this.TimeEvents_TimeOfDayChanged;
TimeEvents.AfterDayStarted += this.TimeEvents_AfterDayStarted;
SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
SaveEvents.BeforeSave += this.SaveEvents_BeforeSave;
GameEvents.FourthUpdateTick += this.GameEvents_FourthUpdateTick;
GameEvents.UpdateTick += this.GameEvents_UpdateTick;
helper.Events.GameLoop.TimeChanged += this.OnTimeChanged;
helper.Events.GameLoop.DayStarted += this.OnDayStarted;
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
helper.Events.GameLoop.Saving += this.OnSaving;
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
this.shouldWarpHorse = false;
}
@ -104,18 +102,14 @@ namespace Omegasis.NightOwl
/*********
** Private methods
*********/
/// <summary>Updates the earthquake event.</summary>
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void GameEvents_UpdateTick(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
{
this.eve?.tickUpdate(Game1.currentGameTime);
}
/// <summary>The method invoked every fourth game update (roughly 15 times per second).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
public void GameEvents_FourthUpdateTick(object sender, EventArgs e)
if (e.IsMultipleOf(4)) // ≈15 times per second
{
try
{
@ -136,11 +130,12 @@ namespace Omegasis.NightOwl
this.WriteErrorLog();
}
}
}
/// <summary>The method invoked before the game saves.</summary>
/// <summary>Raised before the game begins writes data to the save file (except the initial save creation).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
public void SaveEvents_BeforeSave(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
public void OnSaving(object sender, SavingEventArgs e)
{
int collapseFee = 0;
string[] passOutFees = Game1.player.mailbox
@ -156,20 +151,20 @@ namespace Omegasis.NightOwl
Game1.player.money += collapseFee;
}
/// <summary>The method invoked after the player loads a save.</summary>
/// <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 data.</param>
public void SaveEvents_AfterLoad(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
public void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
{
this.IsUpLate = false;
this.JustStartedNewDay = false;
this.JustCollapsed = false;
}
/// <summary>The method invoked when a new day starts.</summary>
/// <summary>Raised after the game begins a new day (including when the player loads a save).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
public void TimeEvents_AfterDayStarted(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
public void OnDayStarted(object sender, DayStartedEventArgs e)
{
try
{
@ -252,10 +247,10 @@ namespace Omegasis.NightOwl
this.Helper.Reflection.GetField<Rectangle>(mountain, "railroadBlockRect").SetValue(Rectangle.Empty);
}
/// <summary>The method invoked when <see cref="Game1.timeOfDay"/> changes.</summary>
/// <summary>Raised after the in-game clock time changes.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged e)
/// <param name="e">The event arguments.</param>
private void OnTimeChanged(object sender, TimeChangedEventArgs e)
{
if (!Context.IsWorldReady)
return;

View File

@ -5,6 +5,6 @@
"Description": "Lets you stay up all night.",
"UniqueID": "Omegasis.NightOwl",
"EntryDll": "NightOwl.dll",
"MinimumApiVersion": "2.0",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": [ "Nexus:433" ]
}

View File

@ -1,4 +1,3 @@
using System;
using System.Linq;
using StardewModdingAPI;
using StardewModdingAPI.Events;
@ -17,17 +16,17 @@ namespace Omegasis.NoMorePets
/// <param name="helper">Provides simplified APIs for writing mods.</param>
public override void Entry(IModHelper helper)
{
SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
}
/*********
** Private methods
*********/
/// <summary>The method invoked after the player loads a save.</summary>
/// <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 data.</param>
public void SaveEvents_AfterLoad(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
public void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
{
foreach (Pet pet in Game1.player.currentLocation.getCharacters().OfType<Pet>().ToArray())
pet.currentLocation.characters.Remove(pet);

View File

@ -5,6 +5,6 @@
"Description": "Removes all pets from the game.",
"UniqueID": "Omegasis.NoMorePets",
"EntryDll": "NoMorePets.dll",
"MinimumApiVersion": "2.0",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": [ "Nexus:506" ]
}

View File

@ -5,6 +5,6 @@
"Description": "A mod that attempts to add in a variety of new things to Stardew.",
"UniqueID": "Omegasis.Revitalize",
"EntryDll": "Revitalize.dll",
"MinimumApiVersion": "2.3",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": []
}

View File

@ -1,9 +1,11 @@
using StardewModdingAPI;
namespace Omegasis.SaveAnywhere.Framework
{
/// <summary>The mod configuration.</summary>
internal class ModConfig
{
/// <summary>The key which initiates a save.</summary>
public string SaveKey { get; set; } = "K";
public SButton SaveKey { get; set; } = SButton.K;
}
}

View File

@ -53,11 +53,11 @@ namespace Omegasis.SaveAnywhere
this.SaveManager = new SaveManager(this.Helper, this.Helper.Reflection, onLoaded: () => this.ShouldResetSchedules = true);
SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
SaveEvents.AfterSave += this.SaveEvents_AfterSave;
ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
GameEvents.UpdateTick += this.GameEvents_UpdateTick;
TimeEvents.AfterDayStarted += this.TimeEvents_AfterDayStarted;
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
helper.Events.GameLoop.Saved += this.OnSaved;
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
helper.Events.GameLoop.DayStarted += this.OnDayStarted;
helper.Events.Input.ButtonPressed += this.OnButtonPressed;
ModHelper = helper;
ModMonitor = this.Monitor;
@ -68,10 +68,10 @@ namespace Omegasis.SaveAnywhere
/*********
** Private methods
*********/
/// <summary>The method invoked after the player loads a save.</summary>
/// <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 data.</param>
private void SaveEvents_AfterLoad(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
{
// reset state
this.IsCustomSaving = false;
@ -81,10 +81,10 @@ namespace Omegasis.SaveAnywhere
this.SaveManager.LoadData();
}
/// <summary>The method invoked after the player finishes saving.</summary>
/// <summary>Raised after the game finishes writing data to the save file (except the initial save creation).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void SaveEvents_AfterSave(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
private void OnSaved(object sender, SavedEventArgs e)
{
// clear custom data after a normal save (to avoid restoring old state)
if (!this.IsCustomSaving)
@ -95,10 +95,10 @@ namespace Omegasis.SaveAnywhere
}
}
/// <summary>The method invoked when the game updates (roughly 60 times per second).</summary>
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void GameEvents_UpdateTick(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
{
// let save manager run background logic
if (Context.IsWorldReady)
@ -156,10 +156,10 @@ namespace Omegasis.SaveAnywhere
Game1.player.currentLocation.characters.Add(monster);
}
/// <summary>The method invoked after a new day starts.</summary>
/// <summary>Raised after the game begins a new day (including when the player loads a save).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void TimeEvents_AfterDayStarted(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
private void OnDayStarted(object sender, DayStartedEventArgs e)
{
// reload NPC schedules
this.ShouldResetSchedules = true;
@ -173,16 +173,16 @@ namespace Omegasis.SaveAnywhere
}
}
/// <summary>The method invoked when the presses a keyboard button.</summary>
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e)
/// <param name="e">The event arguments.</param>
private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
{
if (!Context.IsPlayerFree)
return;
// initiate save (if valid context)
if (e.KeyPressed.ToString() == this.Config.SaveKey)
if (e.Button == this.Config.SaveKey)
{
if (Game1.client == null)
{

View File

@ -5,7 +5,7 @@
"Description": "Lets you save almost anywhere.",
"UniqueID": "Omegasis.SaveAnywhere",
"EntryDll": "SaveAnywhere.dll",
"MinimumApiVersion": "2.4",
"MinimumApiVersion": "2.10.1",
"Dependencies": [
]
}

View File

@ -5,6 +5,6 @@
"Description": "A simple framework to play sounds from wave banks and wav files.",
"UniqueID": "Omegasis.SimpleSoundManager",
"EntryDll": "SimpleSoundManager.dll",
"MinimumApiVersion": "2.0",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": [ "Nexus:1410" ]
}

View File

@ -1,3 +1,5 @@
using StardewModdingAPI;
namespace StardewSymphonyRemastered
{
/// <summary>A class that handles all of the config files for this mod.</summary>
@ -13,7 +15,7 @@ namespace StardewSymphonyRemastered
public int MaximumDelayBetweenSongsInMilliseconds { get; set; } = 60000;
/// <summary>The key binding to open the menu music.</summary>
public string KeyBinding { get; set; } = "L";
public SButton KeyBinding { get; set; } = SButton.L;
/// <summary>Whether to write a JSON file for every possible option for a music pack. Use at your own risk!</summary>
public bool WriteAllConfigMusicOptions { get; set; } = false;

View File

@ -1,5 +1,3 @@
using System;
using System.IO;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Graphics;
using StardewModdingAPI;
@ -47,19 +45,16 @@ namespace StardewSymphonyRemastered
ModHelper = helper;
ModMonitor = this.Monitor;
Config = helper.ReadConfig<Config>();
SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
// EventArgsLocationsChanged += LocationEvents_CurrentLocationChanged;
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
PlayerEvents.Warped += this.PlayerEvents_Warped;
GameEvents.UpdateTick += this.GameEvents_UpdateTick;
ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
SaveEvents.BeforeSave += this.SaveEvents_BeforeSave;
helper.Events.Player.Warped += this.OnPlayerWarped;
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
helper.Events.Input.ButtonPressed += this.OnButtonPressed;
helper.Events.GameLoop.Saving += this.OnSaving;
MenuEvents.MenuChanged += this.MenuEvents_MenuChanged;
MenuEvents.MenuClosed += this.MenuEvents_MenuClosed;
helper.Events.Display.MenuChanged += this.OnMenuChanged;
GameEvents.FirstUpdateTick += this.GameEvents_FirstUpdateTick;
GameEvents.OneSecondTick += this.GameEvents_OneSecondTick;
helper.Events.GameLoop.GameLaunched += this.OnGameLaunched;
musicManager = new MusicManager();
@ -76,34 +71,31 @@ namespace StardewSymphonyRemastered
this.LoadMusicPacks();
}
private void GameEvents_OneSecondTick(object sender, EventArgs e)
{
musicManager?.UpdateTimer();
}
/// <summary>Raised when the player changes locations. This should determine the next song to play.</summary>
/// <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 PlayerEvents_Warped(object sender, EventArgsPlayerWarped e)
private void OnPlayerWarped(object sender, WarpedEventArgs e)
{
if (e.IsLocalPlayer)
musicManager.selectMusic(SongSpecifics.getCurrentConditionalString());
}
/// <summary>Ran once all of teh entry methods are ran. This will ensure that all custom music from other mods has been properly loaded in.</summary>
/// <summary>Raised after the game is launched, right before the first update tick. This happens once per game session (unrelated to loading saves). All mods are loaded and initialised at this point, so this is a good time to set up mod integrations.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event arguments.</param>
private void GameEvents_FirstUpdateTick(object sender, EventArgs e)
private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
{
// Ran once all of the entry methods are ran. This will ensure that all custom music from other mods has been properly loaded in.
musicManager.initializeMenuMusic(); //Initialize menu music that has been added to SongSpecifics.menus from all other mods during their Entry function.
musicManager.initializeFestivalMusic(); //Initialize festival music that has been added to SongSpecifics.menus from all other mods during their Entry function.
musicManager.initializeEventMusic(); //Initialize event music that has been added to SongSpecifics.menus from all other mods during their Entry function.
}
/// <summary>Events to occur after the game has loaded in.</summary>
/// <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 SaveEvents_AfterLoad(object sender, EventArgs e)
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
{
//Locaion initialization MUST occur after load. Anything else can occur before.
SongSpecifics.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.
@ -123,49 +115,55 @@ namespace StardewSymphonyRemastered
musicManager.selectMusic(SongSpecifics.getCurrentConditionalString());
}
/// <summary>Choose new music when a menu is closed.</summary>
/// <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 MenuEvents_MenuClosed(object sender, EventArgsClickableMenuClosed e)
private void OnMenuChanged(object sender, MenuChangedEventArgs e)
{
// menu closed
if (e.NewMenu == null)
{
if (menuChangedMusic)
musicManager.selectMusic(SongSpecifics.getCurrentConditionalString());
}
/// <summary>Choose new music when a menu is opened.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event arguments.</param>
private void MenuEvents_MenuChanged(object sender, EventArgsClickableMenuChanged e)
{
//var ok = musicManager.currentMusicPack.getNameOfCurrentSong();
// menu changed
else
musicManager.SelectMenuMusic(SongSpecifics.getCurrentConditionalString());
}
private void SaveEvents_BeforeSave(object sender, EventArgs e)
/// <summary>Raised before the game begins writes data to the save file (except the initial save creation).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event arguments.</param>
private void OnSaving(object sender, SavingEventArgs e)
{
// THIS IS WAY TO LONG to run. Better make it save individual lists when I am editing songs.
foreach (var musicPack in musicManager.MusicPacks)
musicPack.Value.SaveSettings();
}
/// <summary>Fires when a key is pressed to open the music selection menu.</summary>
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event arguments.</param>
private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e)
private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
{
if (e.KeyPressed.ToString() == Config.KeyBinding && Game1.activeClickableMenu == null)
if (e.Button == Config.KeyBinding && Game1.activeClickableMenu == null)
Game1.activeClickableMenu = new Framework.Menus.MusicManagerMenu(Game1.viewport.Width, Game1.viewport.Height);
}
/// <summary>Raised every frame. Mainly used just to initiate the music packs. Probably not needed.</summary>
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event arguments.</param>
private void GameEvents_UpdateTick(object sender, EventArgs e)
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
{
if (musicManager == null) return;
// update delay timer
if (e.IsOneSecond)
musicManager?.UpdateTimer();
// initiate music packs
if (musicManager != null)
{
if (Config.DisableStardewMusic)
{
if (Game1.currentSong != null)
@ -187,6 +185,7 @@ namespace StardewSymphonyRemastered
}
}
}
}
/// <summary>Load the textures needed by the mod.</summary>
public void LoadTextures()

View File

@ -5,7 +5,7 @@
"Description": "Adding more music to the game one beep at a time. Now with streaming!",
"UniqueID": "Omegasis.StardewSymphonyRemastered",
"EntryDll": "StardewSymphonyRemastered.dll",
"MinimumApiVersion": "2.0",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": [ "Nexus:425" ],
"Dependencies": [
{ "UniqueID": "Omegasis.StardustCore" }

View File

@ -5,6 +5,6 @@
"Description": "A core mod that allows for other mods of mine to be run.",
"UniqueID": "Omegasis.StardustCore",
"EntryDll": "StardustCore.dll",
"MinimumApiVersion": "2.3",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": []
}

View File

@ -1,9 +1,9 @@
using System;
using EventSystem.Framework.Events;
using EventSystem.Framework.FunctionEvents;
using EventSystem.Framework.Information;
using Microsoft.Xna.Framework;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley;
namespace SundropMapEvents
{
@ -18,10 +18,13 @@ namespace SundropMapEvents
{
ModHelper = this.Helper;
ModMonitor = this.Monitor;
StardewModdingAPI.Events.SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
}
private void SaveEvents_AfterLoad(object sender, EventArgs e)
/// <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)
{
EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new WarpEvent("toRR", Game1.getLocationFromName("BusStop"), new Vector2(6, 11), new PlayerEvents(null, null), new WarpInformation("BusStop", 10, 12, 2, false)));
EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new DialogueDisplayEvent("Hello.", Game1.getLocationFromName("BusStop"), new Vector2(10, 13), new MouseButtonEvents(null, null), new MouseEntryLeaveEvent(null, null), "Hello there!"));

View File

@ -1,11 +1,11 @@
{
"Name": "SunDropMapEvents",
"Name": "SunDrop Map Events",
"Author": "Alpha_Omegasis",
"Version": "0.1.0",
"Description": "A system to add events to the SunDropMod",
"UniqueID": "SunDrop.MapEvents",
"EntryDll": "SunDropMapEvents.dll",
"MinimumApiVersion": "2.0",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": [],
"Dependencies": [
{ "UniqueID": "Omegasis.EventSystem" }

View File

@ -1,4 +1,3 @@
using System;
using Omegasis.TimeFreeze.Framework;
using StardewModdingAPI;
using StardewModdingAPI.Events;
@ -16,8 +15,6 @@ namespace Omegasis.TimeFreeze
/// <summary>The mod configuration.</summary>
private ModConfig Config;
public int oldInterval;
/*********
** Public methods
@ -28,18 +25,17 @@ namespace Omegasis.TimeFreeze
{
this.Config = helper.ReadConfig<ModConfig>();
GameEvents.UpdateTick += this.GameEvents_UpdateTick;
//oldInterval = 7;
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
}
/*********
** Private methods
*********/
/// <summary>The method invoked when the game updates (roughly 60 times per second).</summary>
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void GameEvents_UpdateTick(object sender, EventArgs e)
/// <param name="e">The event arguments.</param>
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
{
if (!Context.IsWorldReady)
return;

View File

@ -5,6 +5,6 @@
"Description": "Emulates old Harvest Moon-style games where time is frozen inside.",
"UniqueID": "Omegasis.TimeFreeze",
"EntryDll": "TimeFreeze.dll",
"MinimumApiVersion": "2.0",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": [ "Nexus:973" ]
}

View File

@ -213,10 +213,9 @@ namespace Vocalization
/// <param name="helper">Provides simplified APIs for writing mods.</param>
public override void Entry(IModHelper helper)
{
SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
GameEvents.UpdateTick += this.GameEvents_UpdateTick;
MenuEvents.MenuClosed += this.MenuEvents_MenuClosed;
MenuEvents.MenuChanged += this.MenuEvents_MenuChanged;
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
helper.Events.Display.MenuChanged += this.MenuEvents_MenuChanged;
ModMonitor = this.Monitor;
ModHelper = this.Helper;
Manifest = this.ModManifest;
@ -238,33 +237,30 @@ namespace Vocalization
}
private void MenuEvents_MenuChanged(object sender, EventArgsClickableMenuChanged e)
{
if (Game1.activeClickableMenu is ModularGameMenu)
this.npcPortraitHack();
}
/// <summary>Runs whenever any onscreen menu is closed.</summary>
/// <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 MenuEvents_MenuClosed(object sender, EventArgsClickableMenuClosed e)
private void MenuEvents_MenuChanged(object sender, MenuChangedEventArgs e)
{
//Clean out my previous dialogue when I close any sort of menu.
if (e.NewMenu == null)
{
try
{
soundManager.stopAllSounds();
previousDialogue = "";
}
catch
{
catch { }
previousDialogue = "";
}
}
/// <summary>Runs after the game is loaded to initialize all of the mod's files.</summary>
else if (Game1.activeClickableMenu is ModularGameMenu)
this.npcPortraitHack();
}
/// <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 SaveEvents_AfterLoad(object sender, EventArgs e)
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
{
this.initialzeModualGameMenuHack();
this.initialzeDirectories();
@ -366,10 +362,11 @@ namespace Vocalization
*/
return field.GetValue(instance);
}
/// <summary>Runs every game tick to check if the player is talking to an npc.</summary>
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event arguments.</param>
private void GameEvents_UpdateTick(object sender, EventArgs e)
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
{
soundManager.update();
if (Game1.player != null)

View File

@ -5,7 +5,7 @@
"Description": "A mod that brings voice acting to Stardew Valley.",
"UniqueID": "Omegasis.Vocalization",
"EntryDll": "Vocalization.dll",
"MinimumApiVersion": "2.0",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": [],
"Dependencies": [
{ "UniqueID": "Omegasis.SimpleSoundManager" },