-
-
Save handsomematt/a2e8260440fa74e6344d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Reflection; | |
using System.Text; | |
using System.Threading.Tasks; | |
using StardewModdingAPI; | |
using StardewModdingAPI.Inheritance; | |
using StardewModdingAPI.Inheritance.Menus; | |
using StardewValley.Menus; | |
using System.Reflection; | |
namespace JunimoDepositEverywhere | |
{ | |
public class JunimoDepositEverywhere : Mod | |
{ | |
public override string Name | |
{ | |
get { return "Junimo Deposit Everywhere"; } | |
} | |
public override string Authour | |
{ | |
get { return "Handsome Matt"; } | |
} | |
public override string Version | |
{ | |
get { return "1.0"; } | |
} | |
public override string Description | |
{ | |
get { return "Allows you to deposit to the community centre from everywhere."; } | |
} | |
public override void Entry() | |
{ | |
Events.UpdateTick += Events_UpdateTick; | |
Events.Initialize += Events_Initialize; | |
} | |
private FieldInfo cmg; | |
JunimoNoteMenu menu; | |
private bool gotGame; | |
void Events_Initialize() | |
{ | |
cmg = SGame.StaticFields.First(x => x.Name == "activeClickableMenu"); | |
} | |
void Events_UpdateTick() | |
{ | |
if (cmg != null && cmg.GetValue(null) != null) | |
{ | |
if (cmg.GetValue(null).GetType() == typeof(JunimoNoteMenu)) | |
{ | |
var newMenu = (JunimoNoteMenu)cmg.GetValue(null); | |
if (newMenu != menu) | |
gotGame = false; | |
menu = (JunimoNoteMenu)newMenu; | |
if (!gotGame) | |
{ | |
gotGame = true; | |
FieldInfo bundlesInfo = typeof(JunimoNoteMenu).GetField("bundles", BindingFlags.Instance | BindingFlags.NonPublic); | |
List<Bundle> bundles = (List < Bundle > )bundlesInfo.GetValue(menu); | |
foreach (Bundle bundle in bundles) | |
bundle.depositsAllowed = true; | |
} | |
} | |
else | |
{ | |
gotGame = false; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment