private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            // Hook into the APIs we utilize
            if (Helper.ModRegistry.IsLoaded("Omegasis.SaveAnywhere") && ApiManager.HookIntoSaveAnywhere(Helper))
            {
                _saveAnywhereApi = ApiManager.GetSaveAnywhereApi();

                // Hook into save related events
                _saveAnywhereApi.BeforeSave += this.OnSaving;
                _saveAnywhereApi.AfterSave  += this.OnCustomLoad; // Save Anywhere's AfterSave event doesn't seem to be triggered, known issue
                _saveAnywhereApi.AfterLoad  += this.OnCustomLoad;
            }

            if (Helper.ModRegistry.IsLoaded("bcmpinc.WearMoreRings") && ApiManager.HookIntoIWMR(Helper))
            {
                RingManager.wearMoreRingsApi = ApiManager.GetIWMRApi();
            }

            if (Helper.ModRegistry.IsLoaded("spacechase0.JsonAssets") && ApiManager.HookIntoJsonAssets(Helper))
            {
                _jsonAssetsApi = ApiManager.GetJsonAssetsApi();

                // Hook into IdsAssigned
                _jsonAssetsApi.IdsAssigned += this.IdsAssigned;
            }

            if (Helper.ModRegistry.IsLoaded("Pathoschild.ContentPatcher") && ApiManager.HookIntoContentPatcher(Helper))
            {
                _contentPatcherApi = ApiManager.GetContentPatcherInterface();
                _contentPatcherApi.RegisterToken(ModManifest, "Companions", new CompanionToken());
            }

            // Load any owned content packs
            this.LoadContentPacks();
        }
Пример #2
0
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            // Hook into Pathoschild's Content Patcher API
            try
            {
                contentPatcherApi = this.Helper.ModRegistry.GetApi <IContentPatcherAPI>("Pathoschild.ContentPatcher");
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed to hook into ContentPatcher: {ex}", LogLevel.Error);
                return;
            }

            contentPatcherApi.RegisterToken(this.ModManifest, "GreenhouseStage", () =>
            {
                if (Game1.MasterPlayer.mailReceived.Contains("SG_Treehouse_Expansion_3"))
                {
                    return(new[] { "SereneGreenhouse_Expansion_3" });
                }
                if (Game1.MasterPlayer.mailReceived.Contains("SG_Treehouse_Expansion_2"))
                {
                    return(new[] { "SereneGreenhouse_Expansion_2" });
                }
                if (Game1.MasterPlayer.mailReceived.Contains("SG_Treehouse_Expansion_1"))
                {
                    return(new[] { "SereneGreenhouse_Expansion_1" });
                }
                return(new[] { "SereneGreenhouse" });
            });
        }
 public ChanceCalculator(
     IMonitor monitor,
     IContentPatcherAPI contentPatcherApi,
     IManifest fishingManifest,
     IManifest owner,
     AvailabilityInfo availabilityInfo
     )
     : base(monitor, contentPatcherApi, fishingManifest, owner, availabilityInfo)
 {
     this.availabilityInfo = availabilityInfo
                             ?? throw new ArgumentNullException(nameof(availabilityInfo));
 }
Пример #4
0
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            var jaMod = Helper.ModRegistry.Get("spacechase0.JsonAssets").Manifest;

            ja = Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");
            cp = Helper.ModRegistry.GetApi <IContentPatcherAPI>("Pathoschild.ContentPatcher");
            cp.RegisterToken(jaMod, "ObjectId", this.Token_ObjectId);
            cp.RegisterToken(jaMod, "BigCraftableId", this.Token_BigCraftableId);
            cp.RegisterToken(jaMod, "CropId", this.Token_CropId);
            cp.RegisterToken(jaMod, "FruitTreeId", this.Token_FruitTreeId);
            cp.RegisterToken(jaMod, "HatId", this.Token_HatId);
            cp.RegisterToken(jaMod, "WeaponId", this.Token_WeaponId);
        }
Пример #5
0
        public static bool HookIntoContentPatcher(IModHelper helper)
        {
            contentPatcherApi = helper.ModRegistry.GetApi <IContentPatcherAPI>("Pathoschild.ContentPatcher");

            if (contentPatcherApi is null)
            {
                monitor.Log("Failed to hook into Pathoschild.ContentPatcher.", LogLevel.Error);
                return(false);
            }

            monitor.Log("Successfully hooked into Pathoschild.ContentPatcher.", LogLevel.Debug);
            return(true);
        }
 public ContentPatcherSetup(
     IManifest manifest,
     IContentPatcherAPI contentPatcherApi,
     MissingSecretNotesToken missingSecretNotesToken,
     MissingJournalScrapsToken missingJournalScrapsToken
     )
 {
     this.manifest          = manifest ?? throw new ArgumentNullException(nameof(manifest));
     this.contentPatcherApi = contentPatcherApi
                              ?? throw new ArgumentNullException(nameof(contentPatcherApi));
     this.missingSecretNotesToken = missingSecretNotesToken
                                    ?? throw new ArgumentNullException(nameof(missingSecretNotesToken));
     this.missingJournalScrapsToken = missingJournalScrapsToken
                                      ?? throw new ArgumentNullException(nameof(missingJournalScrapsToken));
 }
Пример #7
0
        private void OnLaunched(object sender, GameLaunchedEventArgs e)
        {
            ContentPatcherAPI = Helper.ModRegistry.GetApi <IContentPatcherAPI>("Pathoschild.ContentPatcher");

            setupGMCM();

            // only register after the game is launched so we can query the object registry
            Util.Abilities.RegisterDefaultAbilities();

            // write the config file again to populate JunimoAbilities with registered abilities
            SaveConfig();

            // register GMCM token
            Util.Progression.SetupHutsToken();
        }
Пример #8
0
        public ConditionsCalculator(
            IMonitor monitor,
            IContentPatcherAPI contentPatcherApi,
            IManifest fishingManifest,
            IManifest owner,
            AvailabilityConditions conditions
            )
        {
            _ = monitor ?? throw new ArgumentNullException(nameof(monitor));
            _ = contentPatcherApi ?? throw new ArgumentNullException(nameof(contentPatcherApi));
            _ = owner ?? throw new ArgumentNullException(nameof(owner));
            this.conditions = conditions ?? throw new ArgumentNullException(nameof(conditions));

            // Check if any CP conditions exist
            if (!conditions.When.Any())
            {
                return;
            }

            // Get CP version
            var version =
                fishingManifest.Dependencies.FirstOrDefault(
                    dependency => dependency.UniqueID == "Pathoschild.ContentPatcher"
                    )
                ?.MinimumVersion
                ?? throw new ArgumentException(
                          "Fishing overhaul does not depend on Content Patcher",
                          nameof(fishingManifest)
                          );

            // Parse conditions
            this.managedConditions = contentPatcherApi.ParseConditions(
                owner,
                conditions.When,
                version,
                new[] { fishingManifest.UniqueID }
                );

            // Check if conditions are valid
            if (!this.managedConditions.IsValid)
            {
                // Log error
                monitor.Log(
                    $"Failed to parse conditions for one of {owner.UniqueID}'s entries: {this.managedConditions.ValidationError}",
                    LogLevel.Error
                    );
            }
        }
Пример #9
0
        public static bool TryLoadContentPatcherAPI()
        {
            try
            {
                // Check to see if Generic Mod Config Menu is installed
                if (!Globals.Helper.ModRegistry.IsLoaded("Pathoschild.ContentPatcher"))
                {
                    Globals.Monitor.Log("Content Patcher not present");
                    return(false);
                }

                api = Globals.Helper.ModRegistry.GetApi <IContentPatcherAPI>("Pathoschild.ContentPatcher");

                return(true);
            }
            catch (Exception e)
            {
                Globals.Monitor.Log($"Failed to register ContentPatcher API: {e.Message}", LogLevel.Error);
                return(false);
            }
        }
Пример #10
0
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            IContentPatcherAPI api = Helper.ModRegistry.GetApi <IContentPatcherAPI>("Pathoschild.ContentPatcher");

            if (api == null)
            {
                return;
            }

            ChildToken token = new ChildToken(1);

            api.RegisterToken(
                mod: ModManifest,
                name: "FirstChildName",
                updateContext: token.NameUpdateContext,
                isReady: token.IsReady,
                getValue: token.NameGetValue,
                allowsInput: false,
                requiresInput: false
                );
            api.RegisterToken(
                mod: ModManifest,
                name: "FirstChildIsToddler",
                updateContext: token.AgeUpdateContext,
                isReady: token.IsReady,
                getValue: token.AgeGetValue,
                allowsInput: false,
                requiresInput: false
                );

            token = new ChildToken(2);
            api.RegisterToken(
                mod: ModManifest,
                name: "SecondChildName",
                updateContext: token.NameUpdateContext,
                isReady: token.IsReady,
                getValue: token.NameGetValue,
                allowsInput: false,
                requiresInput: false
                );
            api.RegisterToken(
                mod: ModManifest,
                name: "SecondChildIsToddler",
                updateContext: token.AgeUpdateContext,
                isReady: token.IsReady,
                getValue: token.AgeGetValue,
                allowsInput: false,
                requiresInput: false
                );

            token = new ChildToken(3);
            api.RegisterToken(
                mod: ModManifest,
                name: "ThirdChildName",
                updateContext: token.NameUpdateContext,
                isReady: token.IsReady,
                getValue: token.NameGetValue,
                allowsInput: false,
                requiresInput: false
                );
            api.RegisterToken(
                mod: ModManifest,
                name: "ThirdChildIsToddler",
                updateContext: token.AgeUpdateContext,
                isReady: token.IsReady,
                getValue: token.AgeGetValue,
                allowsInput: false,
                requiresInput: false
                );

            token = new ChildToken(4);
            api.RegisterToken(
                mod: ModManifest,
                name: "FourthChildName",
                updateContext: token.NameUpdateContext,
                isReady: token.IsReady,
                getValue: token.NameGetValue,
                allowsInput: false,
                requiresInput: false
                );
            api.RegisterToken(
                mod: ModManifest,
                name: "FourthChildIsToddler",
                updateContext: token.AgeUpdateContext,
                isReady: token.IsReady,
                getValue: token.AgeGetValue,
                allowsInput: false,
                requiresInput: false
                );
        }
Пример #11
0
        /* OnGameLaunched
         * This is where I set up the IContentPatcherAPI tokens.
         * Tokens are in the format of (Child Order)Child(Field)
         * I.e. The first child's name is FirstChildName,
         *      the third child's birthday is ThirdChildBirthday
         */
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            IContentPatcherAPI api = Helper.ModRegistry.GetApi <IContentPatcherAPI>("Pathoschild.ContentPatcher");

            if (api == null)
            {
                return;
            }

            ChildToken token = new ChildToken(1);

            api.RegisterToken(
                mod: ModManifest,
                name: "NumberTotalChildren",
                updateContext: token.TotalChildrenUpdateContext,
                isReady: token.IsReady,
                getValue: token.TotalChildrenGetValue,
                allowsInput: false,
                requiresInput: false
                );

            api.RegisterToken(
                mod: ModManifest,
                name: "FirstChildName",
                updateContext: token.NameUpdateContext,
                isReady: token.IsReady,
                getValue: token.NameGetValue,
                allowsInput: false,
                requiresInput: false
                );
            api.RegisterToken(
                mod: ModManifest,
                name: "FirstChildBirthday",
                updateContext: token.BirthdayUpdateContext,
                isReady: token.IsReady,
                getValue: token.BirthdayGetValue,
                allowsInput: false,
                requiresInput: false
                );
            api.RegisterToken(
                mod: ModManifest,
                name: "FirstChildBed",
                updateContext: token.BedUpdateContext,
                isReady: token.IsReady,
                getValue: token.BedGetValue,
                allowsInput: true,
                requiresInput: false
                );
            api.RegisterToken(
                mod: ModManifest,
                name: "FirstChildGender",
                updateContext: token.GenderUpdateContext,
                isReady: token.IsReady,
                getValue: token.GenderGetValue,
                allowsInput: false,
                requiresInput: false
                );
            api.RegisterToken(
                mod: ModManifest,
                name: "FirstChildParent",
                updateContext: token.ParentUpdateContext,
                isReady: token.IsReady,
                getValue: token.ParentGetValue,
                allowsInput: false,
                requiresInput: false
                );

            token = new ChildToken(2);
            api.RegisterToken(
                mod: ModManifest,
                name: "SecondChildName",
                updateContext: token.NameUpdateContext,
                isReady: token.IsReady,
                getValue: token.NameGetValue,
                allowsInput: false,
                requiresInput: false
                );
            api.RegisterToken(
                mod: ModManifest,
                name: "SecondChildBirthday",
                updateContext: token.BirthdayUpdateContext,
                isReady: token.IsReady,
                getValue: token.BirthdayGetValue,
                allowsInput: false,
                requiresInput: false
                );
            api.RegisterToken(
                mod: ModManifest,
                name: "SecondChildBed",
                updateContext: token.BedUpdateContext,
                isReady: token.IsReady,
                getValue: token.BedGetValue,
                allowsInput: true,
                requiresInput: false
                );
            api.RegisterToken(
                mod: ModManifest,
                name: "SecondChildGender",
                updateContext: token.GenderUpdateContext,
                isReady: token.IsReady,
                getValue: token.GenderGetValue,
                allowsInput: false,
                requiresInput: false
                );
            api.RegisterToken(
                mod: ModManifest,
                name: "SecondChildParent",
                updateContext: token.ParentUpdateContext,
                isReady: token.IsReady,
                getValue: token.ParentGetValue,
                allowsInput: false,
                requiresInput: false
                );

            token = new ChildToken(3);
            api.RegisterToken(
                mod: ModManifest,
                name: "ThirdChildName",
                updateContext: token.NameUpdateContext,
                isReady: token.IsReady,
                getValue: token.NameGetValue,
                allowsInput: false,
                requiresInput: false
                );
            api.RegisterToken(
                mod: ModManifest,
                name: "ThirdChildBirthday",
                updateContext: token.BirthdayUpdateContext,
                isReady: token.IsReady,
                getValue: token.BirthdayGetValue,
                allowsInput: false,
                requiresInput: false
                );
            api.RegisterToken(
                mod: ModManifest,
                name: "ThirdChildBed",
                updateContext: token.BedUpdateContext,
                isReady: token.IsReady,
                getValue: token.BedGetValue,
                allowsInput: true,
                requiresInput: false
                );
            api.RegisterToken(
                mod: ModManifest,
                name: "ThirdChildGender",
                updateContext: token.GenderUpdateContext,
                isReady: token.IsReady,
                getValue: token.GenderGetValue,
                allowsInput: false,
                requiresInput: false
                );
            api.RegisterToken(
                mod: ModManifest,
                name: "ThirdChildParent",
                updateContext: token.ParentUpdateContext,
                isReady: token.IsReady,
                getValue: token.ParentGetValue,
                allowsInput: false,
                requiresInput: false
                );

            token = new ChildToken(4);
            api.RegisterToken(
                mod: ModManifest,
                name: "FourthChildName",
                updateContext: token.NameUpdateContext,
                isReady: token.IsReady,
                getValue: token.NameGetValue,
                allowsInput: false,
                requiresInput: false
                );
            api.RegisterToken(
                mod: ModManifest,
                name: "FourthChildBirthday",
                updateContext: token.BirthdayUpdateContext,
                isReady: token.IsReady,
                getValue: token.BirthdayGetValue,
                allowsInput: false,
                requiresInput: false
                );
            api.RegisterToken(
                mod: ModManifest,
                name: "FourthChildBed",
                updateContext: token.BedUpdateContext,
                isReady: token.IsReady,
                getValue: token.BedGetValue,
                allowsInput: true,
                requiresInput: false
                );
            api.RegisterToken(
                mod: ModManifest,
                name: "FourthChildGender",
                updateContext: token.GenderUpdateContext,
                isReady: token.IsReady,
                getValue: token.GenderGetValue,
                allowsInput: false,
                requiresInput: false
                );
            api.RegisterToken(
                mod: ModManifest,
                name: "FourthChildParent",
                updateContext: token.ParentUpdateContext,
                isReady: token.IsReady,
                getValue: token.ParentGetValue,
                allowsInput: false,
                requiresInput: false
                );

            //I'm stopping at four for now.
            //If FamilyPlanning expands past four, I'll need to come back to this.
        }
Пример #12
0
        private void registerCPTokens()
        {
            if (!Helper.ModRegistry.IsLoaded("Pathoschild.ContentPatcher"))
            {
                return;
            }

            IContentPatcherAPI api = Helper.ModRegistry.GetApi <IContentPatcherAPI>("Pathoschild.ContentPatcher");

            /*
             * api.RegisterToken(this.ModManifest, "LuaString", () =>
             * {
             *  foreach (string k in tokenStrings.Keys)
             *      if (tokenStrings[k] != PyUtils.getLuaString(k))
             *          return true;
             *
             *  return false;
             * }, () => Context.IsWorldReady, (s) =>
             * {
             *  tokenStrings.AddOrReplace(s, PyUtils.getLuaString(s));
             *  return new string[] { tokenStrings[s] };
             * }, true, true);*/

            api.RegisterToken(this.ModManifest, "Conditional", () =>
            {
                foreach (string k in tokenBoleans.Keys)
                {
                    if (tokenBoleans[k] != PyUtils.checkEventConditions(k.Split(new[] { " >: " }, StringSplitOptions.RemoveEmptyEntries)[0]))
                    {
                        return(true);
                    }
                }

                return(false);
            }, () => Context.IsWorldReady, (s) =>
            {
                string[] parts = s.Split(new [] { " >: " }, StringSplitOptions.RemoveEmptyEntries);

                if (parts.Length < 2)
                {
                    return(null);
                }

                tokenBoleans.AddOrReplace(s, PyUtils.checkEventConditions(parts[0]));
                return(new string[] { tokenBoleans[s] ? parts[1] : parts.Length < 3 ? null : parts[2] });
            }, true, true);

            api.RegisterToken(
                mod: this.ModManifest,
                name: "ObjectByName",
                updateContext: () =>
            {
                if (!PyTK.PyTKMod.UpdateCustomObjects)
                {
                    return(false);
                }

                UpdateCustomObjects = false;
                return(true);
            },
                isReady: () => Context.IsWorldReady,
                getValue: GetObjectByNameTokenValue,
                allowsInput: true,
                requiresInput: true
                );

            api.RegisterToken(
                mod: this.ModManifest,
                name: "LuaString",
                updateContext: () =>
            {
                if (!UpdateLuaTokens)
                {
                    return(false);
                }

                UpdateLuaTokens = false;
                return(true);
            },
                isReady: () => Context.IsWorldReady,
                getValue: GetLuaString,
                allowsInput: true,
                requiresInput: true
                );
        }