Exemplo n.º 1
0
        /*********
        ** Private methods
        *********/
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            JsonAssets = ModHelper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");
            if (JsonAssets is null)
            {
                Monitor.Log("JsonAssets is needed to load Mega Storage chests", LogLevel.Error);
                return;
            }

            ConvenientChests = ModHelper.ModRegistry.GetApi <IConvenientChestsApi>("aEnigma.ConvenientChests");
            if (!(ConvenientChests is null))
            {
                ModConfig.Instance.LargeChest.EnableCategories = false;
                ModConfig.Instance.MagicChest.EnableCategories = false;
                ModConfig.Instance.SuperMagicChest.EnableChest = false;
            }

            if (ModConfig.Instance.LargeChest.EnableChest)
            {
                JsonAssets.LoadAssets(Path.Combine(ModHelper.DirectoryPath, "assets", "LargeChest"));
            }
            if (ModConfig.Instance.MagicChest.EnableChest)
            {
                JsonAssets.LoadAssets(Path.Combine(ModHelper.DirectoryPath, "assets", "MagicChest"));
            }
            if (ModConfig.Instance.SuperMagicChest.EnableChest)
            {
                JsonAssets.LoadAssets(Path.Combine(ModHelper.DirectoryPath, "assets", "SuperMagicChest"));
            }

            JsonAssets.IdsAssigned += OnIdsAssigned;
            ItemPatcher.Start();
            SaveManager.Start();
            StateManager.Start();
        }
Exemplo n.º 2
0
 private void OnGameLaunched(object sender,
                             GameLaunchedEventArgs e)
 {
     _jsonAssets = Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");
     _jsonAssets.LoadAssets(Path.Combine(Helper.DirectoryPath,
                                         "assets"));
 }
Exemplo n.º 3
0
        private void GameLoop_GameLaunched(object sender, GameLaunchedEventArgs e) //Get JsonAssets Api and directory on Game launch
        {
            JA = Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");
            JA.LoadAssets(Path.Combine(Helper.DirectoryPath, "assets"));

            hasExtendedReach = Helper.ModRegistry.IsLoaded("spacechase0.ExtendedReach");
            hasJA            = Helper.ModRegistry.IsLoaded("spacechase0.JsonAssets");

            if (!hasJA)
            {
                Monitor.Log($"JsonAssets was not loaded, the mod will force itself to stop to avoid crashes", LogLevel.Error);
                Helper.Events.GameLoop.Saving       -= GameLoop_Saving;
                Helper.Events.GameLoop.SaveLoaded   -= GameLoop_SaveLoaded;
                Helper.Events.GameLoop.GameLaunched -= GameLoop_GameLaunched;

                Helper.Events.Input.ButtonPressed -= Input_ButtonPressed;

                Helper.Events.World.ObjectListChanged -= World_ObjectListChanged;

                Helper.Events.Multiplayer.PeerConnected      -= Multiplayer_PeerConnected;
                Helper.Events.Multiplayer.ModMessageReceived -= Multiplayer_ModMessageReceived;
            }
            else
            {
                return;
            }
        }
Exemplo n.º 4
0
 private void LoadJsonAssetsObjects()
 {
     JsonAssets = Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");
     if (JsonAssets == null)
     {
         Log.E("Can't access the Json Assets API. Is the mod installed correctly?");
         return;
     }
     JsonAssets.LoadAssets(Path.Combine(Helper.DirectoryPath, EasterPackPath));
 }
Exemplo n.º 5
0
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            _catShopStock = new Dictionary <ISalable, int[]>();

            _ja = Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");
            if (_ja == null)
            {
                Log.E("Can't access the Json Assets API. Is the mod installed correctly?");
                return;
            }

            foreach (var pack in Const.HatPacks)
            {
                _ja.LoadAssets(Path.Combine(Helper.DirectoryPath, "Assets", Const.HatsDir, pack));
            }
            foreach (var pack in Const.ClothingPacks)
            {
                _ja.LoadAssets(Path.Combine(Helper.DirectoryPath, "Assets", Const.ClothingDir, pack));
            }
        }
Exemplo n.º 6
0
 private void GameLoop_GameLaunched(object sender, GameLaunchedEventArgs e)
 {
     JsonAssets = helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");
     if (JsonAssets == null)
     {
         ModEntry.monitor.Log("Json Assets API not detected: mirror and catalogue items not added", LogLevel.Info);
     }
     else
     {
         JsonAssets.LoadAssets(Path.Combine(helper.DirectoryPath, "assets"));
     }
 }
Exemplo n.º 7
0
 public void GameLoop_GameLaunched(object sender, GameLaunchedEventArgs e)
 {
     this.JsonAssets = base.Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");
     if (JsonAssets == null)
     {
         Monitor.Log("Can't load Json Assets API for Placeable Mine Shaft", 0);
     }
     else
     {
         JsonAssets.LoadAssets(Path.Combine(Helper.DirectoryPath, "assets/json-assets"));
     }
 }
Exemplo n.º 8
0
 public void GameLoop_GameLaunched(object sender, GameLaunchedEventArgs e)
 {
     JsonAssets = Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");
     if (JsonAssets == null)
     {
         Monitor.Log("Can't load Json Assets API for Terrarium", LogLevel.Error);
     }
     else
     {
         JsonAssets.LoadAssets(Path.Combine(Helper.DirectoryPath, "json-assets"));
     }
 }
Exemplo n.º 9
0
 private void GameLoop_GameLaunched(object sender, StardewModdingAPI.Events.GameLaunchedEventArgs e)
 {
     JsonAssets = Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");
     if (JsonAssets == null)
     {
         Monitor.Log("Can't load Json Assets API for scarecrows");
     }
     else
     {
         JsonAssets.LoadAssets(Path.Combine(Helper.DirectoryPath, "assets/json-assets"));
     }
 }
Exemplo n.º 10
0
 public void GameLoop_GameLaunched(object sender, GameLaunchedEventArgs e)
 {
     JsonAssets = Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");
     if (JsonAssets == null)
     {
         Monitor.Log("Can't load Json Assets API for Instant Growth Powder", 0);
     }
     else
     {
         JsonAssets.LoadAssets(Path.Combine(Helper.DirectoryPath, "assets/json-assets"));
     }
 }
Exemplo n.º 11
0
 private void GameLoop_GameLaunched(object sender, StardewModdingAPI.Events.GameLaunchedEventArgs e)
 {
     mJsonAssets = base.Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");
     if (mJsonAssets == null)
     {
         Monitor.Log("Can't load Json Assets API for Moveable Mailbox", LogLevel.Warn);
     }
     else
     {
         mJsonAssets.LoadAssets(Path.Combine(Helper.DirectoryPath, "json-assets"));
     }
 }
Exemplo n.º 12
0
 private void GameLoop_GameLaunched(object sender, GameLaunchedEventArgs e)
 {
     JsonAssets = Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");
     if (JsonAssets == null)
     {
         Monitor.Log("Can't load Json Assets API, which is needed for Home Sewing Kit to function", LogLevel.Error);
     }
     else
     {
         JsonAssets.LoadAssets(Path.Combine(Helper.DirectoryPath, "assets"));
     }
 }
Exemplo n.º 13
0
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            GenerateCat();

            JsonAssets = Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");
            if (JsonAssets == null)
            {
                Log.E("Can't access the Json Assets API. Is the mod installed correctly?");
                return;
            }

            JsonAssets.LoadAssets(Path.Combine(Helper.DirectoryPath, "assets", ModConsts.HatsDir, "Tuxedo Top Hats"));
            foreach (string pack in ModConsts.HatPacks)
            {
                JsonAssets.LoadAssets(Path.Combine(Helper.DirectoryPath, "assets", ModConsts.HatsDir, pack));
            }
            foreach (string pack in ModConsts.ClothingPacks)
            {
                JsonAssets.LoadAssets(Path.Combine(Helper.DirectoryPath, "assets", ModConsts.ClothingDir, pack));
            }
        }
Exemplo n.º 14
0
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            LoadApis();

            if (!jsonAssetsFound)
            {
                ModMonitor.Log("JsonAssets not found.", LogLevel.Error);
                return;
            }

            jsonAssetsApi.LoadAssets(Path.Combine(ModHelper.DirectoryPath, "assets", "VersatileGrabber"));
            jsonAssetsApi.IdsAssigned += OnIdsAssigned;
        }
Exemplo n.º 15
0
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            _catShopStock = new Dictionary <ISalable, int[]>();

            _jsonAssets = Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");
            if (_jsonAssets == null)
            {
                Log.E("Can't access the Json Assets API. Is the mod installed correctly?");
                return;
            }

            var objFolder = new DirectoryInfo(Path.Combine(Helper.DirectoryPath, Const.JAShirtsDir));

            foreach (var subfolder in objFolder.GetDirectories())
            {
                _jsonAssets.LoadAssets(Path.Combine(Helper.DirectoryPath, Const.JAShirtsDir, subfolder.Name));
            }

            objFolder = new DirectoryInfo(Path.Combine(Helper.DirectoryPath, Const.JAHatsDir));
            foreach (var subfolder in objFolder.GetDirectories())
            {
                _jsonAssets.LoadAssets(Path.Combine(Helper.DirectoryPath, Const.JAHatsDir, subfolder.Name));
            }
        }
Exemplo n.º 16
0
 public void GameLoop_GameLaunched(object sender, GameLaunchedEventArgs e)
 {
     JsonAssets = Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");
     if (JsonAssets == null)
     {
         Monitor.Log("Can't load Json Assets API for Parrot Perch");
     }
     else
     {
         JsonAssets.LoadAssets(Path.Combine(Helper.DirectoryPath, "json-assets"));
     }
     advancedLootFrameworkApi = context.Helper.ModRegistry.GetApi <IAdvancedLootFrameworkApi>("aedenthorn.AdvancedLootFramework");
     if (advancedLootFrameworkApi != null)
     {
         Monitor.Log($"loaded AdvancedLootFramework API", LogLevel.Debug);
         giftList = advancedLootFrameworkApi.LoadPossibleTreasures(possibleGifts.Keys.ToArray(), -1, 100);
         Monitor.Log($"Got {giftList.Count} possible treasures");
     }
 }
Exemplo n.º 17
0
 private void GameLaunched(object sender, GameLaunchedEventArgs e) //Get JsonAssets Api and directory on Game launch
 {
     JA = Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");
     JA.LoadAssets(Path.Combine(Helper.DirectoryPath, "assets"));
 }
Exemplo n.º 18
0
        private static void LoadJsonAssetsObjects()
        {
            JsonAssets = Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");
            if (JsonAssets == null)
            {
                Log.E("Can't access the Json Assets API. Is the mod installed correctly?");
                return;
            }

            if (ModEntry.Config.DebugMode)
            {
                Log.W("Loading Basic Objects Pack.");
            }
            JsonAssets.LoadAssets(path: Path.Combine(Helper.DirectoryPath, AssetManager.BasicObjectsPackPath));

            if (!ModEntry.Config.AddCookingSkillAndRecipes)
            {
                Log.W("Did not add new recipes: Recipe additions are disabled in config file.");
            }
            else
            {
                if (ModEntry.Config.DebugMode)
                {
                    Log.W("Loading New Recipes Pack.");
                }
                JsonAssets.LoadAssets(path: Path.Combine(Helper.DirectoryPath, AssetManager.NewRecipesPackPath));
            }

            if (!ModEntry.Config.AddNewCropsAndStuff)
            {
                Log.W("Did not add new objects: New stuff is disabled in config file.");
            }
            else if (UsingPPJACrops)
            {
                Log.I("Did not add new crops: [PPJA] Fruits and Veggies already adds these objects.");
            }
            else
            {
                if (ModEntry.Config.DebugMode)
                {
                    Log.W("Loading New Crops Pack.");
                }
                JsonAssets.LoadAssets(path: Path.Combine(Helper.DirectoryPath, AssetManager.NewCropsPackPath));
            }

            if (UsingNettlesCrops)
            {
                Log.I("Did not add nettles: Other mods already add these items.");
            }
            else if (!Utils.AreNettlesActive())
            {
                Log.I("Did not add nettles: Currently disabled in code.");
            }
            else
            {
                if (ModEntry.Config.DebugMode)
                {
                    Log.W("Loading Nettles Pack.");
                }
                JsonAssets.LoadAssets(path: Path.Combine(Helper.DirectoryPath, AssetManager.NettlesPackPath));
            }
        }
Exemplo n.º 19
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"));
 }
Exemplo n.º 20
0
        private void LoadContentPacks(bool isReload = false)
        {
            this.Reset(false, isReload);

            // Load the owned content packs
            foreach (IContentPack contentPack in Helper.ContentPacks.GetOwned())
            {
                Monitor.Log($"Loading companions from pack: {contentPack.Manifest.Name} {contentPack.Manifest.Version} by {contentPack.Manifest.Author}", LogLevel.Debug);

                var companionFolders = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Companions")).GetDirectories();
                if (companionFolders.Count() == 0)
                {
                    Monitor.Log($"No sub-folders found under Companions for the content pack {contentPack.Manifest.Name}!", LogLevel.Warn);
                    continue;
                }

                // Load in the companions
                foreach (var companionFolder in companionFolders)
                {
                    if (!File.Exists(Path.Combine(companionFolder.FullName, "companion.json")))
                    {
                        Monitor.Log($"Content pack {contentPack.Manifest.Name} is missing a companion.json under {companionFolder.Name}!", LogLevel.Warn);
                        continue;
                    }

                    CompanionModel companion = contentPack.ReadJsonFile <CompanionModel>(Path.Combine(companionFolder.Parent.Name, companionFolder.Name, "companion.json"));
                    companion.Name  = companion.Name.Replace(" ", "");
                    companion.Owner = contentPack.Manifest.UniqueID;

                    // Save the TileSheet, if one is given
                    if (String.IsNullOrEmpty(companion.TileSheetPath) && !File.Exists(Path.Combine(companionFolder.FullName, "companion.png")))
                    {
                        Monitor.Log($"Unable to add companion {companion.Name} from {contentPack.Manifest.Name}: No associated companion.png or TileSheetPath given", LogLevel.Warn);
                        continue;
                    }
                    else if (String.IsNullOrEmpty(companion.TileSheetPath))
                    {
                        companion.TileSheetPath = contentPack.ModContent.GetInternalAssetName(Path.Combine(companionFolder.Parent.Name, companionFolder.Name, "companion.png")).Name;
                    }

                    // Save the PortraitSheet, if one is given
                    if (companion.Portrait != null)
                    {
                        if (!File.Exists(Path.Combine(companionFolder.FullName, "portrait.png")))
                        {
                            Monitor.Log($"Warning for companion {companion.Name} from {contentPack.Manifest.Name}: Portrait property was given but no portrait.png was found", LogLevel.Warn);
                        }
                        else
                        {
                            companion.PortraitSheetPath = contentPack.ModContent.GetInternalAssetName(Path.Combine(companionFolder.Parent.Name, companionFolder.Name, "portrait.png")).Name;
                        }
                    }

                    if (contentPack.Translation != null)
                    {
                        companion.Translations = contentPack.Translation;
                    }
                    Monitor.Log(companion.ToString(), LogLevel.Trace);

                    // Add the companion to our cache
                    CompanionManager.companionModels.Add(companion);

                    // Cache the full name of the companion, so that it can be reference by a Content Patcher token
                    if (_contentPatcherApi != null)
                    {
                        var assetToken = $"{TOKEN_HEADER}{companion.GetId()}";
                        AssetManager.idToAssetToken[companion.GetId()] = assetToken;

                        if (!isReload)
                        {
                            var modelObject = Helper.GameContent.Load <TokenModel>(assetToken);
                            //var modelObject = AssetManager.GetCompanionModelObject(Helper.Content.Load<Dictionary<string, object>>(assetToken, ContentSource.GameContent));
                            trackedModels[$"{CustomCompanions.TOKEN_HEADER}{companion.GetId()}"] = modelObject.Companion;
                        }
                    }
                }

                if (_jsonAssetsApi != null && !isReload)
                {
                    // Load in the rings that will be paired to a companion
                    if (!Directory.Exists(Path.Combine(contentPack.DirectoryPath, "Objects")))
                    {
                        Monitor.Log($"No summoning rings available from {contentPack.Manifest.Name}, this may be intended", LogLevel.Trace);
                        continue;
                    }

                    foreach (var ringFolder in new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Objects")).GetDirectories())
                    {
                        if (!File.Exists(Path.Combine(ringFolder.FullName, "object.json")))
                        {
                            Monitor.Log($"Content pack {contentPack.Manifest.Name} is missing a object.json under {ringFolder.Name}!", LogLevel.Warn);
                            continue;
                        }

                        RingModel ring = contentPack.ReadJsonFile <RingModel>(Path.Combine(ringFolder.Parent.Name, ringFolder.Name, "object.json"));
                        ring.Owner = contentPack.Manifest.UniqueID;

                        RingManager.rings.Add(ring);
                    }

                    // Generate content.json for Json Assets
                    contentPack.WriteJsonFile("content-pack.json", new ContentPackModel
                    {
                        Name        = contentPack.Manifest.Name,
                        Author      = contentPack.Manifest.Author,
                        Version     = contentPack.Manifest.Version.ToString(),
                        Description = contentPack.Manifest.Description,
                        UniqueID    = contentPack.Manifest.UniqueID,
                        UpdateKeys  = contentPack.Manifest.UpdateKeys,
                    });

                    // Load in the associated rings objects (via JA)
                    _jsonAssetsApi.LoadAssets(contentPack.DirectoryPath);
                }
            }
        }