Files
MMOKitchen/Mod.cs
T

63 lines
2.7 KiB
C#
Raw Normal View History

2024-04-01 08:12:01 +11:00
using KitchenLib;
using KitchenMods;
using System.Reflection;
using Kitchen;
using KitchenLib.Event;
using KitchenLib.Preferences;
using MMOKitchen.Menus;
2024-08-10 05:00:57 +10:00
using KitchenLogger = KitchenLib.Logging.KitchenLogger;
2024-04-01 08:12:01 +11:00
namespace MMOKitchen
{
public class Mod : BaseMod, IModSystem
{
public const string MOD_GUID = "com.starfluxgames.mmokitchen";
public const string MOD_NAME = "MMO Kitchen";
2025-09-25 22:28:35 +10:00
public const string MOD_VERSION = "0.3.3";
2024-04-01 08:12:01 +11:00
public const string MOD_AUTHOR = "StarFluxGames";
2024-08-10 05:00:57 +10:00
public const string MOD_GAMEVERSION = ">=1.2.0";
2026-03-05 17:09:17 +11:00
public const string PREFERENCE_REQUIRED_CONSENT_PERCENTAGE = "requiredConsentPercentage";
public const string PREFERENCE_SCALE_ABOVE_4_PLAYERS = "scaleAbove4Players";
public const string PREFERENCE_SCALE_ABOVE_4_PLAYERS_MULTIPLIER = "scaleAbove4PlayersMultiplier";
2024-04-01 08:12:01 +11:00
public static KitchenLogger Logger;
public static PreferenceManager manager;
public static int MaxPlayers = 100;
public Mod() : base(MOD_GUID, MOD_NAME, MOD_AUTHOR, MOD_VERSION, MOD_GAMEVERSION, Assembly.GetExecutingAssembly()) { }
protected override void OnInitialise()
{
Logger.LogWarning($"{MOD_GUID} v{MOD_VERSION} in use!");
}
protected override void OnUpdate()
{
}
protected override void OnPostActivate(KitchenMods.Mod mod)
{
Logger = InitLogger();
manager = new PreferenceManager("mmokitchen"); // Keeping the old GUID so we don't have to reset the preferences
2026-03-05 17:09:17 +11:00
manager.RegisterPreference(new PreferenceInt(PREFERENCE_REQUIRED_CONSENT_PERCENTAGE, 100));
2024-04-01 08:12:01 +11:00
manager.RegisterPreference(new PreferenceBool("scaleAbove4Players", false));
2026-03-05 17:09:17 +11:00
manager.RegisterPreference(new PreferenceFloat("scaleAbove4PlayersMultiplier", 0.235f));
2024-04-01 08:12:01 +11:00
manager.Load();
2024-08-10 05:00:57 +10:00
ModsPreferencesMenu<MenuAction>.RegisterMenu("MMO Kitchen", typeof(PreferenceMenu<MenuAction>), typeof(MenuAction));
ModsPreferencesMenu<MenuAction>.RegisterMenu("MMO Kitchen", typeof(PreferenceMenu<MenuAction>), typeof(MenuAction));
Events.MainMenuView_SetupMenusEvent += (s, args) =>
2024-04-01 08:12:01 +11:00
{
2024-08-10 05:00:57 +10:00
args.addMenu.Invoke(args.instance, new object[] { typeof(PreferenceMenu<MenuAction>), new PreferenceMenu<MenuAction>(args.instance.ButtonContainer, args.module_list) });
2024-04-01 08:12:01 +11:00
};
2024-08-10 05:00:57 +10:00
Events.PlayerPauseView_SetupMenusEvent += (s, args) =>
2024-04-01 08:12:01 +11:00
{
2024-08-10 05:00:57 +10:00
args.addMenu.Invoke(args.instance, new object[] { typeof(PreferenceMenu<MenuAction>), new PreferenceMenu<MenuAction>(args.instance.ButtonContainer, args.module_list) });
2024-04-01 08:12:01 +11:00
};
}
}
}