Exemple #1
0
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            var configMenu = this.Helper.ModRegistry.GetGenericModConfigMenuApi(this.Monitor);

            if (configMenu != null)
            {
                configMenu.Register(
                    mod: this.ModManifest,
                    reset: () => this.Config = new Configuration(),
                    save: () => this.Helper.WriteConfig(this.Config),
                    titleScreenOnly: true
                    );
                configMenu.AddBoolOption(
                    mod: this.ModManifest,
                    name: I18n.Config_FlashingUfo_Name,
                    tooltip: I18n.Config_FlashingUfo_Description,
                    getValue: () => this.Config.FlashingUfo,
                    setValue: value => this.Config.FlashingUfo = value
                    );
            }

            var sc = Helper.ModRegistry.GetApi <ISpaceCoreApi>("spacechase0.SpaceCore");

            sc.RegisterSerializerType(typeof(MountainTop));
            sc.RegisterSerializerType(typeof(LunarLocation));
            sc.RegisterSerializerType(typeof(MoonLandingArea));
            sc.RegisterSerializerType(typeof(AsteroidsEntrance));
            sc.RegisterSerializerType(typeof(AsteroidsDungeon));
            sc.RegisterSerializerType(typeof(BoomEye));
            sc.RegisterSerializerType(typeof(BoomProjectile));
            sc.RegisterSerializerType(typeof(AsteroidProjectile));
            sc.RegisterSerializerType(typeof(LunarFarm));
            sc.RegisterSerializerType(typeof(LunarFarmCave));
            sc.RegisterSerializerType(typeof(LunarAnimal));
            sc.RegisterSerializerType(typeof(AnimalGauntlets));
            sc.RegisterSerializerType(typeof(Necklace));
            sc.RegisterSerializerType(typeof(MoonPlanetOverlook));
            sc.RegisterSerializerType(typeof(UfoInterior));
            sc.RegisterSerializerType(typeof(LunarFarmHouse));
            sc.RegisterSerializerType(typeof(MoonInfuserRoom));
            sc.RegisterSerializerType(typeof(LunarSlime));
            sc.RegisterCustomLocationContext("Moon",
                                             getLocationWeatherForTomorrowFunc: (r) =>
            {
                LocationWeather lw          = new();
                lw.weatherForTomorrow.Value = 0;
                lw.isRaining.Value          = false;
                return(lw);
            }    /*,
                  * passoutWakeupLocationFunc: ( who ) => "Custom_MM_MoonLandingArea",
                  * passoutWakeupPointFunc: ( who ) => new Point( 9, 30 ) // TODO: Inside farm house if unlocked
                  */
                                             );
            sc.RegisterCustomProperty(typeof(FarmerTeam), "hasLunarKey", typeof(NetBool), AccessTools.Method(typeof(FarmerTeam_LunarKey), nameof(FarmerTeam_LunarKey.get_hasLunarKey)), AccessTools.Method(typeof(FarmerTeam_LunarKey), nameof(FarmerTeam_LunarKey.set_hasLunarKey)));
            sc.RegisterCustomProperty(typeof(Farmer), "necklaceItem", typeof(NetRef <Item>), AccessTools.Method(typeof(Farmer_Necklace), nameof(Farmer_Necklace.get_necklaceItem)), AccessTools.Method(typeof(Farmer_Necklace), nameof(Farmer_Necklace.set_necklaceItem)));

            dga = Helper.ModRegistry.GetApi <IDynamicGameAssetsApi>("spacechase0.DynamicGameAssets");
            dga.AddEmbeddedPack(this.ModManifest, Path.Combine(Helper.DirectoryPath, "assets", "dga"));
            dgaPack = DynamicGameAssets.Mod.GetPacks().First(cp => cp.GetManifest().UniqueID == ModManifest.UniqueID);
        }
 public DataLoader(IModHelper helper)
 {
     Helper = helper;
     DgaApi = MailFrameworkModEntry.ModHelper.ModRegistry.GetApi <IDynamicGameAssetsApi>("spacechase0.DynamicGameAssets");
     ConditionsCheckerApi = Helper.ModRegistry.GetApi <IConditionsChecker>("Cherry.ExpandedPreconditionsUtility");
     ConditionsCheckerApi?.Initialize(false, MailFrameworkModEntry.Manifest.UniqueID);
 }
Exemple #3
0
        private void GameLoop_GameLaunched(object sender, StardewModdingAPI.Events.GameLaunchedEventArgs e)
        {
            apiDGA = Helper.ModRegistry.GetApi <IDynamicGameAssetsApi>("spacechase0.DynamicGameAssets");
            apiJA  = Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");


            // get Generic Mod Config Menu's API (if it's installed)
            var configMenu = Helper.ModRegistry.GetApi <IGenericModConfigMenuApi>("spacechase0.GenericModConfigMenu");

            if (configMenu is null)
            {
                return;
            }

            // register mod
            configMenu.Register(
                mod: ModManifest,
                reset: () => Config = new ModConfig(),
                save: () => Helper.WriteConfig(Config)
                );

            configMenu.AddBoolOption(
                mod: ModManifest,
                name: () => "Mod Enabled?",
                getValue: () => Config.EnableMod,
                setValue: value => Config.EnableMod = value
                );
            configMenu.AddBoolOption(
                mod: ModManifest,
                name: () => "Reset Farm Cave Event",
                tooltip: () => "Will reset the cave the next time you load a save. REMOVES ALL OBJECTS IN CAVE",
                getValue: () => Config.ResetEvent,
                setValue: value => Config.ResetEvent = value
                );
        }
Exemple #4
0
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            var sc = Helper.ModRegistry.GetApi <ISpaceCoreApi>("spacechase0.SpaceCore");

            sc.RegisterSerializerType(typeof(NullObject));
            sc.RegisterSerializerType(typeof(Drill));
            sc.RegisterSerializerType(typeof(ConveyorBelt));
            sc.RegisterSerializerType(typeof(Unhopper));
            sc.RegisterSerializerType(typeof(WireCutter));
            sc.RegisterSerializerType(typeof(ConnectorBase));
            sc.RegisterSerializerType(typeof(LogicConnector));
            sc.RegisterSerializerType(typeof(LeverBlock));
            sc.RegisterCustomProperty(typeof(GameLocation), "BelowGroundObjects",
                                      typeof(NetVector2Dictionary <StardewValley.Object, NetRef <StardewValley.Object> >),
                                      AccessTools.Method(typeof(GameLocation_BelowGroundObjects), nameof(GameLocation_BelowGroundObjects.get_BelowGroundObjects)),
                                      AccessTools.Method(typeof(GameLocation_BelowGroundObjects), nameof(GameLocation_BelowGroundObjects.set_BelowGroundObjects)));
            sc.RegisterCustomProperty(typeof(GameLocation), "ElevatedObjects",
                                      typeof(NetVector2Dictionary <StardewValley.Object, NetRef <StardewValley.Object> >),
                                      AccessTools.Method(typeof(GameLocation_ElevatedObjects), nameof(GameLocation_ElevatedObjects.get_ElevatedObjects)),
                                      AccessTools.Method(typeof(GameLocation_ElevatedObjects), nameof(GameLocation_ElevatedObjects.set_ElevatedObjects)));

            dga = Helper.ModRegistry.GetApi <IDynamicGameAssetsApi>("spacechase0.DynamicGameAssets");
            dga.AddEmbeddedPack(this.ModManifest, Path.Combine(Helper.DirectoryPath, "assets", "dga"));
            dgaPack = DynamicGameAssets.Mod.GetPacks().First(cp => cp.GetManifest().UniqueID == ModManifest.UniqueID);

            var gmcm = Helper.ModRegistry.GetApi <IGenericModConfigMenuApi>("spacechase0.GenericModConfigMenu");

            gmcm.Register(ModManifest, () => Config = new Configuration(), () => Helper.WriteConfig(Config));
            gmcm.AddKeybindList(ModManifest, () => Config.PlacementModifier, (kl) => Config.PlacementModifier = kl, () => Helper.Translation.Get("config.placement-modifier.name"), () => Helper.Translation.Get("config.placement-modifier.tooltip"));
        }
Exemple #5
0
        /// <summary>A SMAPI GameLaunched event that enables DGA support if that mod is available.</summary>
        public void EnableDGA(object sender, GameLaunchedEventArgs e)
        {
            try
            {
                IDynamicGameAssetsApi api = Helper.ModRegistry.GetApi <IDynamicGameAssetsApi>("spacechase0.DynamicGameAssets"); //attempt to get an instance of DGA's API

                if (api == null)                                                                                                //if the API is NOT available
                {
                    Monitor.Log($"Optional API not found: Dynamic Game Assets (DGA).", LogLevel.Trace);
                    return;
                }
                else //if the API is available
                {
                    Monitor.Log($"Optional API found: Dynamic Game Assets (DGA).", LogLevel.Trace);
                }

                Utility.DGAItemAPI = api; //pass the API to this mod's static utility property
            }
            catch (Exception ex)
            {
                Utility.Monitor.Log($"An error happened while loading FTM's Dynamic Game Assets (DGA) interface. FTM will be unable to spawn custom items added by DGA. The auto-generated error message has been added to the log.", LogLevel.Warn);
                Utility.Monitor.Log($"----------", LogLevel.Trace);
                Utility.Monitor.Log($"{ex.ToString()}", LogLevel.Trace);
            }
        }
 private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e)
 {
     if (Helper1.ModRegistry.Get("spacechase0.JsonAssets") != null)
     {
         JAAPI = Helper1.ModRegistry.GetApi <IApi>("spacechase0.JsonAssets");
     }
     if (Helper1.ModRegistry.Get("spacechase0.DynamicGameAssets") != null)
     {
         DGAAPI = Helper1.ModRegistry.GetApi <IDynamicGameAssetsApi>("spacechase0.DynamicGameAssets");
     }
 }
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            dgAPI = DynamicGameAssets.Mod.instance.GetApi() as IDynamicGameAssetsApi;

            API = Helper.ModRegistry.GetApi <IAlmanacAPI>("leclair.almanac");
            if (API == null)
            {
                Log("Unable to get Almanac's API.", LogLevel.Error);
            }

            API?.SetCropPriority(ModManifest, 10);
            API?.SetCropCallback(ModManifest, UpdateCrops);
        }
Exemple #8
0
        internal bool HookIntoDynamicGameAssets(IModHelper helper)
        {
            _dynamicGameAssetsApi = helper.ModRegistry.GetApi <IDynamicGameAssetsApi>("spacechase0.DynamicGameAssets");

            if (_dynamicGameAssetsApi is null)
            {
                _monitor.Log("Failed to hook into spacechase0.DynamicGameAssets.", LogLevel.Error);
                return(false);
            }

            _monitor.Log("Successfully hooked into spacechase0.DynamicGameAssets.", LogLevel.Debug);
            return(true);
        }
Exemple #9
0
        private void GameLoop_GameLaunched(object sender, StardewModdingAPI.Events.GameLaunchedEventArgs e)
        {
            apiDGA = Helper.ModRegistry.GetApi <IDynamicGameAssetsApi>("spacechase0.DynamicGameAssets");
            IManifest manifest = new MyManifest("aedenthorn.CoinCollectorDGA", "CoinCollectorDGA", "aedenthorn", "CoinCollectorDGA", new SemanticVersion("0.1.0"))
            {
                ContentPackFor = new MyManifestContentPackFor
                {
                    UniqueID = "spacechase0.DynamicGameAssets"
                },
                ExtraFields = new Dictionary <string, object>()
                {
                    { "DGA.FormatVersion", 2 }, { "DGA.ConditionsFormatVersion", "1.23.0" }
                }
            };

            apiDGA.AddEmbeddedPack(manifest, $"{Helper.DirectoryPath}/dga");

            if (config.BlipAudioPath.Length > 0)
            {
                try
                {
                    blipEffectCenter = SoundEffect.FromStream(new FileStream($"{Helper.DirectoryPath}/{config.BlipAudioPath}", FileMode.Open));
                    blipEffectLeft   = SoundEffect.FromStream(new FileStream($"{Helper.DirectoryPath}/{config.BlipAudioPathLeft}", FileMode.Open));
                    blipEffectRight  = SoundEffect.FromStream(new FileStream($"{Helper.DirectoryPath}/{config.BlipAudioPathRight}", FileMode.Open));
                }
                catch { }
            }

            totalRarities = 0;

            foreach (IContentPack contentPack in Helper.ContentPacks.GetOwned())
            {
                CoinDataDict dict = contentPack.ReadJsonFile <CoinDataDict>("content.json") ?? new CoinDataDict();
                foreach (CoinData data in dict.data)
                {
                    try
                    {
                        coinDataDict.Add(data.id, data);
                        totalRarities += data.rarity;
                    }
                    catch (Exception ex)
                    {
                        Monitor.Log($"Exception getting data for {data.id} in content pack {contentPack.Manifest.Name}:\n{ex}", LogLevel.Error);
                    }
                }
            }
            Monitor.Log($"Loaded coin data for {coinDataDict.Count} coins.");
        }
        private void GameLoop_GameLaunched(object sender, StardewModdingAPI.Events.GameLaunchedEventArgs e)
        {
            apiDGA = Helper.ModRegistry.GetApi <IDynamicGameAssetsApi>("spacechase0.DynamicGameAssets");
            apiJA  = Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");


            // get Generic Mod Config Menu's API (if it's installed)
            var configMenu = Helper.ModRegistry.GetApi <IGenericModConfigMenuApi>("spacechase0.GenericModConfigMenu");

            if (configMenu is null)
            {
                return;
            }

            // register mod
            configMenu.Register(
                mod: ModManifest,
                reset: () => Config = new ModConfig(),
                save: () => Helper.WriteConfig(Config)
                );

            configMenu.AddBoolOption(
                mod: ModManifest,
                name: () => "Mod Enabled?",
                getValue: () => Config.EnableMod,
                setValue: value => Config.EnableMod = value
                );
            configMenu.AddTextOption(
                mod : ModManifest,
                name : () => "Oversize % / Day",
                getValue : () => "" + Config.SizeIncreasePerDay,
                setValue : delegate(string value) { try { Config.SizeIncreasePerDay = float.Parse(value, CultureInfo.InvariantCulture); } catch { } }
                );
            configMenu.AddTextOption(
                mod : ModManifest,
                name : () => "Loot % / Oversize",
                getValue : () => "" + Config.LootIncreasePerDay,
                setValue : delegate(string value) { try { Config.LootIncreasePerDay = float.Parse(value, CultureInfo.InvariantCulture); } catch { } }
                );
            configMenu.AddNumberOption(
                mod: ModManifest,
                name: () => "Max Oversize Days",
                getValue: () => Config.MaxDaysSizeIncrease,
                setValue: value => Config.MaxDaysSizeIncrease = value
                );
        }
        private void GameLoop_GameLaunched(object sender, StardewModdingAPI.Events.GameLaunchedEventArgs e)
        {
            apiDGA = Helper.ModRegistry.GetApi <IDynamicGameAssetsApi>("spacechase0.DynamicGameAssets");
            IManifest manifest = new MyManifest("aedenthorn.TentDGA", "TentDGA", "aedenthorn", "TentDGA", new SemanticVersion("0.1.0"))
            {
                ContentPackFor = new MyManifestContentPackFor
                {
                    UniqueID = "spacechase0.DynamicGameAssets"
                },
                ExtraFields = new Dictionary <string, object>()
                {
                    { "DGA.FormatVersion", 2 }, { "DGA.ConditionsFormatVersion", "1.23.0" }
                }
            };

            apiDGA.AddEmbeddedPack(manifest, $"{Helper.DirectoryPath}/dga");

            // get Generic Mod Config Menu's API (if it's installed)
            var configMenu = Helper.ModRegistry.GetApi <IGenericModConfigMenuApi>("spacechase0.GenericModConfigMenu");

            if (configMenu is null)
            {
                return;
            }

            // register mod
            configMenu.Register(
                mod: ModManifest,
                reset: () => Config = new ModConfig(),
                save: () => Helper.WriteConfig(Config)
                );

            configMenu.AddBoolOption(
                mod: ModManifest,
                name: () => "Mod Enabled?",
                getValue: () => Config.EnableMod,
                setValue: value => Config.EnableMod = value
                );
            configMenu.AddBoolOption(
                mod: ModManifest,
                name: () => "Save On Tent?",
                getValue: () => Config.SaveOnTent,
                setValue: value => Config.SaveOnTent = value
                );
        }
Exemple #12
0
        private void GameLoop_GameLaunched(object sender, StardewModdingAPI.Events.GameLaunchedEventArgs e)
        {
            apiDGA = Helper.ModRegistry.GetApi <IDynamicGameAssetsApi>("spacechase0.DynamicGameAssets");
            apiJA  = Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");

            // get Generic Mod Config Menu's API (if it's installed)
            var configMenu = Helper.ModRegistry.GetApi <IGenericModConfigMenuApi>("spacechase0.GenericModConfigMenu");

            if (configMenu is null)
            {
                return;
            }

            // register mod
            configMenu.Register(
                mod: ModManifest,
                reset: () => Config = new ModConfig(),
                save: () => Helper.WriteConfig(Config)
                );

            configMenu.AddBoolOption(
                mod: ModManifest,
                name: () => "Mod Enabled?",
                getValue: () => Config.EnableMod,
                setValue: value => Config.EnableMod = value
                );
            configMenu.AddNumberOption(
                mod: ModManifest,
                name: () => "Days to fill",
                getValue: () => Config.DaysToFill,
                setValue: value => Config.DaysToFill = value
                );
            configMenu.AddTextOption(
                mod: ModManifest,
                name: () => "Product Object",
                tooltip: () => "index or name (JA and DGA should work)",
                getValue: () => Config.Product,
                setValue: value => Config.Product = value
                );
        }
Exemple #13
0
        public DataLoader(IModHelper helper, IManifest manifest)
        {
            Helper    = helper;
            ModConfig = helper.ReadConfig <ModConfig>();
            i18n      = Helper.Translation;
            DgaApi    = DataLoader.Helper.ModRegistry.GetApi <IDynamicGameAssetsApi>("spacechase0.DynamicGameAssets");

            LooseSpritesName = Helper.Content.GetActualAssetKey("common/LooseSprites.png", ContentSource.ModFolder);
            LooseSprites     = Helper.Content.Load <Texture2D>("common/LooseSprites.png");

            // load tools
            ToolsSprites = Helper.Content.Load <Texture2D>("tools/Tools.png");
            ToolsLoader  = new ToolsLoader(ToolsSprites, Helper.Content.Load <Texture2D>("tools/MenuTiles.png"), Helper.Content.Load <Texture2D>("common/CustomLetterBG.png"));
            ToolsLoader.LoadMail();

            // load recipes
            if (!ModConfig.DisableMeat)
            {
                RecipeLoader = new RecipesLoader();
                RecipeLoader.LoadMails();
            }

            //load treats mail
            if (!ModConfig.DisableTreats)
            {
                LoadTreatsMail();
            }

            // load animal data
            AnimalBuildingData = DataLoader.Helper.Data.ReadJsonFile <AnimalBuildingData>("data\\animalBuilding.json") ?? new AnimalBuildingData();
            DataLoader.Helper.Data.WriteJsonFile("data\\animalBuilding.json", AnimalBuildingData);
            AnimalData = DataLoader.Helper.Data.ReadJsonFile <AnimalData>("data\\animals.json") ?? new AnimalData();
            DataLoader.Helper.Data.WriteJsonFile("data\\animals.json", AnimalData);
            AnimalContestData = DataLoader.Helper.Data.ReadJsonFile <AnimalContestData>("data\\animalContest.json") ?? new AnimalContestData();
            DataLoader.Helper.Data.WriteJsonFile("data\\animalContest.json", AnimalContestData);

            // look cooking data
            CookingData = Helper.Data.ReadJsonFile <CookingData>("data\\cooking.json") ?? new CookingData();
            if (CookingData.Meatloaf.Recipe == null)
            {
                CookingData.CloneRecipeAndAmount(new CookingData());
            }
            Helper.Data.WriteJsonFile("data\\cooking.json", CookingData);

            // load Livin' With The Animals channel
            TvController.AddChannel(new LivingWithTheAnimalsChannel());

            // add editors (must happen *after* data is initialised above, since SMAPI may reload affected assets immediately)
            var editors = Helper.Content.AssetEditors;
            var loaders = Helper.Content.AssetLoaders;

            if (!ModConfig.DisableAnimalContest)
            {
                editors.Add(new EventsLoader());
                loaders.Add(this);
            }
            editors.Add(ToolsLoader);
            editors.Add(this);
            if (!ModConfig.DisableMeat)
            {
                editors.Add(RecipeLoader);
            }

            CreateConfigMenu(manifest);
        }
Exemple #14
0
 private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
 {
     dga = Helper.ModRegistry.GetApi <IDynamicGameAssetsApi>("spacechase0.DynamicGameAssets");
 }
Exemple #15
0
        private void GameLoop_GameLaunched(object sender, StardewModdingAPI.Events.GameLaunchedEventArgs e)
        {
            apiDGA = Helper.ModRegistry.GetApi <IDynamicGameAssetsApi>("spacechase0.DynamicGameAssets");
            apiJA  = Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");

            var obj = Helper.ModRegistry.GetApi("Pathoschild.Automate");

            if (obj != null)
            {
                SMonitor.Log($"patching automate");

                harmony.Patch(
                    original: AccessTools.Method(obj.GetType().Assembly.GetType("Pathoschild.Stardew.Automate.Framework.Machines.Objects.SeedMakerMachine"), "SetInput"),
                    transpiler: new HarmonyMethod(typeof(ModEntry), nameof(ModEntry.SeedMakerMachine_SetInput_Transpiler))
                    );
            }

            // get Generic Mod Config Menu's API (if it's installed)
            var configMenu = Helper.ModRegistry.GetApi <IGenericModConfigMenuApi>("spacechase0.GenericModConfigMenu");

            if (configMenu is null)
            {
                return;
            }

            // register mod
            configMenu.Register(
                mod: ModManifest,
                reset: () => Config = new ModConfig(),
                save: () => Helper.WriteConfig(Config)
                );

            configMenu.AddBoolOption(
                mod: ModManifest,
                name: () => "Mod Enabled?",
                getValue: () => Config.EnableMod,
                setValue: value => Config.EnableMod = value
                );
            configMenu.AddNumberOption(
                mod: ModManifest,
                name: () => "Min Seeds",
                getValue: () => Config.MinSeeds,
                setValue: value => Config.MinSeeds = value
                );
            configMenu.AddNumberOption(
                mod: ModManifest,
                name: () => "Max Seeds",
                getValue: () => Config.MaxSeeds,
                setValue: value => Config.MaxSeeds = value
                );
            configMenu.AddNumberOption(
                mod: ModManifest,
                name: () => "Min Mixed Seeds",
                getValue: () => Config.MinMixedSeeds,
                setValue: value => Config.MinMixedSeeds = value
                );
            configMenu.AddNumberOption(
                mod: ModManifest,
                name: () => "Max Seeds",
                getValue: () => Config.MaxMixedSeeds,
                setValue: value => Config.MaxMixedSeeds = value
                );
            configMenu.AddTextOption(
                mod : ModManifest,
                name : () => "Ancient Seed % Chance",
                getValue : () => "" + Config.AncientSeedChance,
                setValue : delegate(string value) { try { Config.AncientSeedChance = float.Parse(value, CultureInfo.InvariantCulture); } catch { } }
                );
            configMenu.AddTextOption(
                mod : ModManifest,
                name : () => "Mixed Seed % Chance",
                getValue : () => "" + Config.MixedSeedChance,
                setValue : delegate(string value) { try { Config.MixedSeedChance = float.Parse(value, CultureInfo.InvariantCulture); } catch { } }
                );
        }