Exemplo n.º 1
0
        private static void LoadSpaceCoreAPI()
        {
            ISpaceCoreAPI spaceCore = Helper.ModRegistry
                                      .GetApi <ISpaceCoreAPI>
                                          ("spacechase0.SpaceCore");

            spaceCore.RegisterSerializerType(type: typeof(CustomBush));
        }
Exemplo n.º 2
0
        private void GameLoop_GameLaunched(object sender, StardewModdingAPI.Events.GameLaunchedEventArgs e)
        {
            JsonAssets = Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");
            JsonAssets.LoadAssets(Path.Combine(Helper.DirectoryPath, "data"));

            SpaceCore = Helper.ModRegistry.GetApi <ISpaceCoreAPI>("spacechase0.SpaceCore");
            SpaceCore.AddEventCommand("GiveAquariumTrophy1", typeof(ModEntry).GetMethod(nameof(GiveAquariumTrophy1)));
            SpaceCore.AddEventCommand("GiveAquariumTrophy2", typeof(ModEntry).GetMethod(nameof(GiveAquariumTrophy2)));
        }
Exemplo n.º 3
0
        private bool LoadAPIs()
        {
            Log.T("Loading mod-provided APIs.");
            ISpaceCoreAPI spacecoreAPI = this.Helper.ModRegistry.GetApi <ISpaceCoreAPI>("spacechase0.SpaceCore");

            if (spacecoreAPI == null)
            {
                // Skip all mod behaviours if we fail to load the objects
                Log.E($"Couldn't access mod-provided API for SpaceCore.{Environment.NewLine}Garden beds will not be available, and no changes will be made.");
                return(false);
            }

            spacecoreAPI.RegisterSerializerType(typeof(OutdoorPot));

            return(true);
        }
Exemplo n.º 4
0
        /// <summary>Load other mod APIs.</summary>
        private void LoadAPIs()
        {
            log.T("Loading mod-provided APIs.");

            // setup GMCM
            ModConfig.SetUpModConfigMenu(Config, this);

            // setup spacecore
            ISpaceCoreAPI spacecoreAPI = Helper.ModRegistry.GetApi <ISpaceCoreAPI>("spacechase0.SpaceCore");

            if (spacecoreAPI is null)
            {
                // Skip patcher mod behaviours if we fail to load the objects
                log.E($"Couldn't access mod-provided API for SpaceCore. " + UID + " will not be available, and no changes will be made.");
            }
            spacecoreAPI.RegisterSerializerType(typeof(Tapper));
        }
Exemplo n.º 5
0
        private static bool LoadSpaceCoreAPI()
        {
            ISpaceCoreAPI spaceCore = Helper.ModRegistry
                                      .GetApi <ISpaceCoreAPI>
                                          ("spacechase0.SpaceCore");

            if (spaceCore is null)
            {
                Log.E("Can't access the SpaceCore API. Is the mod installed correctly?");
                return(false);
            }

            spaceCore.RegisterSerializerType(type: typeof(Objects.CookingTool));
            spaceCore.RegisterSerializerType(type: typeof(CustomBush));

            return(true);
        }
Exemplo n.º 6
0
        public override void Entry(IModHelper helper)
        {
            ModInstance = this;

            if (Helper.ModRegistry.IsLoaded(EntoaroxFrameworkUniqueId) && Helper.ModRegistry.Get(EntoaroxFrameworkUniqueId).Manifest.Version.IsOlderThan("2.5.5"))
            {
                Monitor.Log("WARNING - Your game may fail to save with ItemBags and Entoarox Framework installed, " +
                            "since both of these mods attempt to override the game's save serializer to handle saving/loading of custom items. " +
                            "Consider updating to a newer version of Entoarox Framework to resolve this compatibility issue.", LogLevel.Warn);
            }

            LoadUserConfig();
            LoadGlobalConfig();
            LoadModdedItems();
            LoadModdedBags();
            BagConfig.AfterLoaded();

            helper.Events.Display.MenuChanged   += Display_MenuChanged;
            helper.Events.Display.WindowResized += Display_WindowResized;

            helper.Events.GameLoop.UpdateTicked += GameLoop_UpdateTicked;

            helper.Events.GameLoop.Saving     += (sender, e) => { SaveLoadHelpers.OnSaving(); };
            helper.Events.GameLoop.Saved      += (sender, e) => { SaveLoadHelpers.OnSaved(); };
            helper.Events.GameLoop.SaveLoaded += (sender, e) => { SaveLoadHelpers.OnLoaded(); };

            helper.Events.GameLoop.GameLaunched += (sender, e) =>
            {
                //  Add compatibility with the Save Anywhere mod
                bool IsSaveAnywhereInstalled = Helper.ModRegistry.IsLoaded(SaveAnywhereUniqueId) ||
                                               Helper.ModRegistry.GetAll().Any(x => x.Manifest.Name.Equals("Save Anywhere", StringComparison.CurrentCultureIgnoreCase));
                if (IsSaveAnywhereInstalled)
                {
                    try
                    {
                        ISaveAnywhereAPI API = Helper.ModRegistry.GetApi <ISaveAnywhereAPI>(SaveAnywhereUniqueId);
                        if (API != null)
                        {
                            API.addBeforeSaveEvent(ModUniqueId, () => { SaveLoadHelpers.OnSaving(); });
                            API.addAfterSaveEvent(ModUniqueId, () => { SaveLoadHelpers.OnSaved(); });
                            API.addAfterLoadEvent(ModUniqueId, () => { SaveLoadHelpers.OnLoaded(); });
                        }
                    }
                    catch (Exception ex)
                    {
                        Monitor.Log(string.Format("Failed to bind to Save Anywhere's Mod API. Your game may crash while saving with Save Anywhere! Error: {0}", ex.Message), LogLevel.Warn);
                    }
                }

                //  Add compatibility with Entoarox Framework mod
                //  (By default, Entoarox Framework overrides the game's save serializer. SpaceCore also overrides the serializer, causing a conflicts since this mod relies on SpaceCore to handle saving/loading items)
                if (Helper.ModRegistry.IsLoaded(EntoaroxFrameworkUniqueId) && !Helper.ModRegistry.Get(EntoaroxFrameworkUniqueId).Manifest.Version.IsOlderThan("2.5.5"))
                {
                    try
                    {
                        IEntoaroxFrameworkAPI API = Helper.ModRegistry.GetApi <IEntoaroxFrameworkAPI>(EntoaroxFrameworkUniqueId);
                        if (API != null)
                        {
                            //  Disable Entoarox Frameworks logic for overriding the save serializer
                            API.HoistSerializerOwnership();
                        }
                    }
                    catch (Exception ex)
                    {
                        Monitor.Log(string.Format("Failed to bind to Entoarox Framework's Mod API. Your game may crash while saving with Entoarox Framework! Error: {0}", ex.Message), LogLevel.Warn);
                    }
                }


                //  Register custom types for serialization
#if !ANDROID
                if (Helper.ModRegistry.IsLoaded(SpaceCoreUniqueId))
                {
                    IModInfo      SpaceCoreInfo = Helper.ModRegistry.Get(SpaceCoreUniqueId);
                    ISpaceCoreAPI API           = Helper.ModRegistry.GetApi <ISpaceCoreAPI>(SpaceCoreUniqueId);
                    API.RegisterSerializerType(typeof(BoundedBag));
                    API.RegisterSerializerType(typeof(BundleBag));
                    API.RegisterSerializerType(typeof(OmniBag));
                    API.RegisterSerializerType(typeof(Rucksack));
                }
#endif

                ModdedBag.OnGameLaunched();
            };

            InputHandler.OnModEntry(helper);
            CraftingHandler.OnModEntry(helper);
            CommandHandler.OnModEntry(helper);
            AutofillHandler.OnModEntry(helper);
            MultiplayerHandler.OnModEntry(helper);
            MonsterLootHandler.OnModEntry(helper);
            LegacyDataMigrator.OnModEntry(helper);
        }