Example #1
0
        /// <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 data.</param>
        private void onGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            if (_data != null)
            {
                return;
            }
            _data = new Loader(Helper);

            var harmony = HarmonyInstance.Create("Xirsoi.MayoMod");

            harmony.Patch(
                original: AccessTools.Method(typeof(SObject), nameof(SObject.performObjectDropInAction)),
                prefix: new HarmonyMethod(typeof(ObjectOverrides), nameof(ObjectOverrides.PerformObjectDropInAction))
                );
            harmony.Patch(
                original: AccessTools.Method(typeof(FarmAnimal), nameof(FarmAnimal.dayUpdate)),
                prefix: new HarmonyMethod(typeof(ObjectOverrides), nameof(ObjectOverrides.FarmAnimalDayUpdate))
                );
            harmony.Patch(
                original: AccessTools.Method(typeof(AnimalHouse), nameof(AnimalHouse.addNewHatchedAnimal)),
                prefix: new HarmonyMethod(typeof(ObjectOverrides), nameof(ObjectOverrides.AddHatchedAnimal))
                );

            _jsonAssets = Helper.ModRegistry.GetApi <IJsonAssetApi>("spacechase0.JsonAssets");
            _jsonAssets.LoadAssets(Helper.DirectoryPath);
            _jsonAssets.IdsAssigned += (object s, EventArgs ea) => {
                foreach (var item in _jsonAssets.GetAllObjectIds())
                {
                    Loader.DATA.Add(item.Key, item.Value);
                }
            };
        }
Example #2
0
        public static void HookIntoJsonAssets(IModHelper helper)
        {
            jsonAssetApi = helper.ModRegistry.GetApi <IJsonAssetApi>("spacechase0.JsonAssets");

            if (jsonAssetApi is null)
            {
                monitor.Log("Failed to hook into spacechase0.JsonAssets.", LogLevel.Error);
                return;
            }

            monitor.Log("Successfully hooked into spacechase0.JsonAssets.", LogLevel.Debug);
        }
Example #3
0
        public static void HookIntoApi(IModHelper helper)
        {
            // Get modID
            modID = helper.ModRegistry.ModID;

            // Attempt to hook into the IMobileApi interface
            jsonAssetApi = helper.ModRegistry.GetApi <IJsonAssetApi>("spacechase0.JsonAssets");

            if (jsonAssetApi is null)
            {
                monitor.Log("Failed to hook into spacechase0.JsonAssets. Joja Prime Membership will be unavailable for purchase.", LogLevel.Error);
                return;
            }

            monitor.Log("Successfully hooked into spacechase0.JsonAssets.", LogLevel.Debug);
        }
Example #4
0
 /// <summary>
 /// Loads the Json Assets API.
 /// </summary>
 private void LoadJsonAssetsApi()
 {
     JsonAssets = Entry.Helper.ModRegistry.GetApi <IJsonAssetApi>("spacechase0.JsonAssets");
 }