Exemplo n.º 1
0
        public static void GameLoop_GameLaunched(object sender, GameLaunchedEventArgs e)
        {
            // load TMX pack

            IContentPack TMXcontentPack = Helper.ContentPacks.CreateFake(Path.Combine(Helper.DirectoryPath, "assets/tmx-pack"));

            object api = Helper.ModRegistry.GetApi("Platonymous.TMXLoader");

            if (api != null)
            {
                Helper.Reflection.GetMethod(api, "AddContentPack").Invoke(TMXcontentPack);
            }

            // load scuba gear

            ModEntry.JsonAssets = Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");
            bool flag = ModEntry.JsonAssets == null;

            if (flag)
            {
                Monitor.Log("Can't load Json Assets API for scuba gear");
            }
            else
            {
                ModEntry.JsonAssets.LoadAssets(Path.Combine(Helper.DirectoryPath, "assets/json-assets"));
            }

            // fix dive maps

            foreach (IContentPack contentPack in Helper.ContentPacks.GetOwned())
            {
                try
                {
                    Monitor.Log($"Reading content pack: {contentPack.Manifest.Name} {contentPack.Manifest.Version} from {contentPack.DirectoryPath}");
                    DiveMapData data = contentPack.ReadJsonFile <DiveMapData>("content.json");
                    foreach (DiveMap map in data.Maps)
                    {
                        if (map.Features.Contains("FixWaterTiles") && !ModEntry.changeLocations.ContainsKey(map.Name))
                        {
                            ModEntry.changeLocations.Add(map.Name, false);
                        }
                    }
                }
                catch
                {
                    Monitor.Log($"couldn't read content.json in content pack {contentPack.Manifest.Name}", LogLevel.Warn);
                }
            }

            // load breath audio

            if (Config.BreatheSound)
            {
                LoadBreatheSound();
            }
        }
Exemplo n.º 2
0
 public static void ReadDiveMapData(DiveMapData data)
 {
     foreach (DiveMap map in data.Maps)
     {
         if (!ModEntry.diveMaps.ContainsKey(map.Name))
         {
             ModEntry.diveMaps.Add(map.Name, map);
             Monitor.Log($"added dive map info for {map.Name}", LogLevel.Debug);
         }
         else
         {
             Monitor.Log($"dive map info already exists for {map.Name}", LogLevel.Warn);
         }
     }
 }
Exemplo n.º 3
0
 public bool AddContentPack(IContentPack contentPack)
 {
     try
     {
         Monitor.Log($"Reading content pack: {contentPack.Manifest.Name} {contentPack.Manifest.Version} from {contentPack.DirectoryPath}");
         DiveMapData data = contentPack.ReadJsonFile <DiveMapData>("content.json");
         SwimUtils.ReadDiveMapData(data);
         return(true);
     }
     catch
     {
         Monitor.Log($"couldn't read content.json in content pack {contentPack.Manifest.Name}", LogLevel.Warn);
         return(false);
     }
 }
Exemplo n.º 4
0
        public static void GameLoop_SaveLoaded(object sender, SaveLoadedEventArgs e)
        {
            // load scuba gear ids

            if (ModEntry.JsonAssets != null)
            {
                ModEntry.scubaMaskID = ModEntry.JsonAssets.GetHatId("Scuba Mask");
                ModEntry.scubaTankID = ModEntry.JsonAssets.GetClothingId("Scuba Tank");

                if (ModEntry.scubaMaskID == -1)
                {
                    Monitor.Log("Can't get ID for Swim mod item #1. Some functionality will be lost.");
                }
                else
                {
                    Monitor.Log(string.Format("Swim mod item #1 ID is {0}.", ModEntry.scubaMaskID));
                }

                if (ModEntry.scubaTankID == -1)
                {
                    Monitor.Log("Can't get ID for Swim mod item #2. Some functionality will be lost.");
                }
                else
                {
                    Monitor.Log(string.Format("Swim mod item #2 ID is {0}.", ModEntry.scubaTankID));
                }

                try
                {
                    ModEntry.scubaFinsID = Helper.Content.Load <Dictionary <int, string> >(@"Data/Boots", ContentSource.GameContent).First(x => x.Value.StartsWith("Scuba Fins")).Key;
                }
                catch
                {
                    Monitor.Log("Can't get ID for Swim mod item #3. Some functionality will be lost.");
                }
                if (ModEntry.scubaFinsID != -1)
                {
                    Monitor.Log(string.Format("Swim mod item #3 ID is {0}.", ModEntry.scubaFinsID));
                    if (Game1.player.boots != null && Game1.player.boots.Value != null && Game1.player.boots.Value.Name == "Scuba Fins" && Game1.player.boots.Value.parentSheetIndex != ModEntry.scubaFinsID)
                    {
                        Game1.player.boots.Value = new Boots(ModEntry.scubaFinsID);
                    }
                }
            }

            // load dive maps

            foreach (IContentPack contentPack in Helper.ContentPacks.GetOwned())
            {
                try
                {
                    Monitor.Log($"Reading content pack: {contentPack.Manifest.Name} {contentPack.Manifest.Version} from {contentPack.DirectoryPath}");
                    DiveMapData data = contentPack.ReadJsonFile <DiveMapData>("content.json");
                    SwimUtils.ReadDiveMapData(data);
                }
                catch
                {
                    Monitor.Log($"couldn't read content.json in content pack {contentPack.Manifest.Name}", LogLevel.Warn);
                }
            }

            Monitor.Log($"Reading content pack from assets/swim-map-content.json");

            try
            {
                DiveMapData myData = Helper.Data.ReadJsonFile <DiveMapData>("assets/swim-map-content.json");
                SwimUtils.ReadDiveMapData(myData);
            }
            catch (Exception ex)
            {
                Monitor.Log($"assets/swim-map-content.json file read error. Exception: {ex}", LogLevel.Warn);
            }

            if (!SwimUtils.IsWearingScubaGear() && Config.SwimSuitAlways)
            {
                Game1.player.changeIntoSwimsuit();
            }

            bubbleTexture = Helper.Content.Load <Texture2D>("LooseSprites/temporary_sprites_1", ContentSource.GameContent);
        }