using KitchenLib; using KitchenLib.Logging; using KitchenLib.Logging.Exceptions; using KitchenMods; using System.Linq; using System.Reflection; using Kitchen; using Kitchen.Modules; using KitchenLib.Event; using KitchenLib.Interfaces; using KitchenLib.Preferences; using KitchenLib.Utils; using Pets.Components; using Pets.Customs; using Pets.Menus; using Pets.Views; using UnityEngine; using KitchenLogger = KitchenLib.Logging.KitchenLogger; namespace Pets { public class Mod : BaseMod, IAutoRegisterAll { public const string MOD_GUID = "com.starfluxgames.pets"; public const string MOD_NAME = "Pets"; public const string MOD_VERSION = "0.1.5"; public const string MOD_AUTHOR = "StarFluxGames"; public const string MOD_GAMEVERSION = ">=1.1.8"; public static AssetBundle Bundle; public static KitchenLogger Logger; public static PreferenceManager manager; public static float MinimumSpeedThreshold = 0.1f; 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!"); foreach (GridMenuNavigationConfig grid in Resources.FindObjectsOfTypeAll()) { if (grid.name == "Root") { GridMenuPetConfig config = new GridMenuPetConfig(); config.Pets.Add(0); config.Pets.Add(GDOUtils.GetCustomGameDataObject().ID); config.Pets.Add(GDOUtils.GetCustomGameDataObject().ID); config.Pets.Add(GDOUtils.GetCustomGameDataObject().ID); config.Pets.Add(GDOUtils.GetCustomGameDataObject().ID); config.Pets.Add(GDOUtils.GetCustomGameDataObject().ID); config.Pets.Add(GDOUtils.GetCustomGameDataObject().ID); config.Pets.Add(GDOUtils.GetCustomGameDataObject().ID); config.Pets.Add(GDOUtils.GetCustomGameDataObject().ID); config.Pets.Add(GDOUtils.GetCustomGameDataObject().ID); config.Pets.Add(GDOUtils.GetCustomGameDataObject().ID); config.Icon = Bundle.LoadAsset("PawPrint"); grid.Links.Add(config); } } } protected override void OnPostActivate(KitchenMods.Mod mod) { Bundle = mod.GetPacks().SelectMany(e => e.AssetBundles).FirstOrDefault() ?? throw new MissingAssetBundleException(MOD_GUID); Logger = InitLogger(); manager = new PreferenceManager(MOD_GUID); manager.RegisterPreference(new PreferenceBool("petsHaveColliders", true)); manager.RegisterPreference(new PreferenceInt("petInteractionMode", 0)); // 0 = Always, 1 = Night Only, 2 = Day Only manager.Load(); manager.Save(); ModsPreferencesMenu.RegisterMenu(MOD_NAME, typeof(PreferenceMenu), typeof(MenuAction)); ModsPreferencesMenu.RegisterMenu(MOD_NAME, typeof(PreferenceMenu), typeof(MenuAction)); Events.MainMenuView_SetupMenusEvent += (s, args) => { args.addMenu.Invoke(args.instance, new object[] { typeof(PreferenceMenu), new PreferenceMenu(args.instance.ButtonContainer, args.module_list) }); }; Events.PlayerPauseView_SetupMenusEvent += (s, args) => { args.addMenu.Invoke(args.instance, new object[] { typeof(PreferenceMenu), new PreferenceMenu(args.instance.ButtonContainer, args.module_list) }); }; ViewUtils.RegisterView("Pets.Views.PetRequestView", typeof(SPetRequestView), typeof(PetRequestView)); } } }