示例#1
0
        public override void Entry(IModHelper helper)
        {
            Instance = this;
            helper.Events.Player.Warped        += Player_Warped;
            helper.Events.GameLoop.DayStarted  += GameLoop_DayStarted;
            helper.Events.Display.RenderedHud  += Display_RenderedHud;
            helper.Events.Input.ButtonReleased += Input_ButtonReleased;
            helper.Events.GameLoop.SaveLoaded  += GameLoop_SaveLoaded;

            config = this.Helper.Data.ReadJsonFile <ModConfig>("config.json") ?? ModConfigDefaultConfig.CreateDefaultConfig("config.json");

            if (config.useCustomPanningTreasure)
            {
                string treasureFile = Path.Combine("DataFiles", "Treasure.json");
                treasureGroups = this.Helper.Data.ReadJsonFile <Dictionary <TREASURE_GROUP, TreasureGroup> >(treasureFile) ?? TreasureGroupDefaultConfig.CreateTreasureGroup(treasureFile);

                harmony = HarmonyInstance.Create("com.aairthegreat.mod.panning");
                harmony.Patch(typeof(Pan).GetMethod("getPanItems"), null, new HarmonyMethod(typeof(PanOverrider).GetMethod("postfix_getPanItems")));
            }
        }
示例#2
0
        public override void Entry(IModHelper helper)
        {
            Instance = this;
            helper.Events.Player.Warped        += Player_Warped;
            helper.Events.GameLoop.DayStarted  += GameLoop_DayStarted;
            helper.Events.Display.RenderedHud  += Display_RenderedHud;
            helper.Events.Input.ButtonReleased += Input_ButtonReleased;
            helper.Events.GameLoop.SaveLoaded  += GameLoop_SaveLoaded;

            ConfigStaticTranslationStrings();

            try
            {
                config = this.Helper.Data.ReadJsonFile <ModConfig>("config.json") ?? ModConfigDefaultConfig.CreateDefaultConfig("config.json");
                config = ModConfigDefaultConfig.UpdateConfigToLatest(config, "config.json");
            }
            catch  //Really the only time this is going to error is when going from old version to new version of the config file or there is a bad config file
            {
                config = ModConfigDefaultConfig.UpdateConfigToLatest(config, "config.json") ?? ModConfigDefaultConfig.CreateDefaultConfig("config.json");
            }

            if (config.useCustomPanningTreasure)
            {
                string treasureFile = Path.Combine("DataFiles", "Treasure.json");
                treasureGroups = this.Helper.Data.ReadJsonFile <Dictionary <TREASURE_GROUP, TreasureGroup> >(treasureFile) ?? TreasureGroupDefaultConfig.CreateTreasureGroup(treasureFile);

                harmony = HarmonyInstance.Create("com.aairthegreat.mod.panning");
                harmony.Patch(typeof(Pan).GetMethod("getPanItems"), null, new HarmonyMethod(typeof(PanOverrider).GetMethod("postfix_getPanItems")));
            }
        }
示例#3
0
        private void UpdatePossibleTiles(GameLocation currentLocation)
        {
            if (!openWaterTiles.ContainsKey(currentLocation.Name))
            {
                string file = Path.Combine("DataFiles", $"{currentLocation.Name}.json");
                if (currentLocation.Name == "Farm")  // Special Case
                {
                    file = Path.Combine("DataFiles", farmFile);
                }

                MapOreConfig mapOreConfig = null;
                try
                {
                    mapOreConfig = this.Helper.Data.ReadJsonFile <MapOreConfig>(file);
                }
                catch
                {
                }
                if (mapOreConfig == null) //No file was found or old file...
                {
                    List <Point> possibleTiles = null;

                    try // Trying to see if there is an old file...
                    {
                        possibleTiles = this.Helper.Data.ReadJsonFile <List <Point> >(file);
                    }
                    catch
                    {
                    }


                    mapOreConfig = new MapOreConfig()
                    {
                        FileVersion            = 1,
                        AreaName               = currentLocation.Name,
                        NumberOfOreSpotsPerDay = config.maxNumberOfOrePointsGathered,
                        StartTime              = 0600,
                        EndTime        = 2600,
                        CustomTreasure = false
                    };

                    if (possibleTiles == null)
                    {
                        possibleTiles = new List <Point>();
                        int maxWidth  = currentLocation.Map.GetLayer("Back").LayerWidth;
                        int maxHeight = currentLocation.Map.GetLayer("Back").LayerHeight;
                        for (int width = 0; width < maxWidth; width++)
                        {
                            for (int height = 0; height < maxHeight; height++)
                            {
                                Point possibleOrePoint = new Point(width, height);
                                if (currentLocation.isWaterTile(width, height) && FishingRod.distanceToLand(width, height, currentLocation) <= 0)
                                {
                                    possibleTiles.Add(possibleOrePoint);
                                }
                            }
                        }
                    }

                    mapOreConfig.OreSpots = possibleTiles;

                    if (!currentLocation.Name.Contains("UndergroundMine"))
                    {
                        this.Helper.Data.WriteJsonFile(file, mapOreConfig); // Write out new file since we had to try and find spawn points.
                    }
                    else if (currentLocation.Name == "UndergroundMine20" ||
                             currentLocation.Name == "UndergroundMine60" ||
                             currentLocation.Name == "UndergroundMine100")
                    {
                        this.Helper.Data.WriteJsonFile(file, mapOreConfig); // The only mine levels with water
                    }
                }
                if (mapOreConfig.FileVersion == 0)
                {
                    mapOreConfig.FileVersion    = 1;
                    mapOreConfig.AreaName       = currentLocation.Name;
                    mapOreConfig.StartTime      = 600;
                    mapOreConfig.EndTime        = 2600;
                    mapOreConfig.CustomTreasure = false;
                    this.Helper.Data.WriteJsonFile(file, mapOreConfig);
                }

                if (mapOreConfig.CustomTreasure)
                {
                    string treasureFile  = Path.Combine("DataFiles", $"{currentLocation.Name}_Treasure.json");
                    var    tresureGroups = this.Helper.Data.ReadJsonFile <Dictionary <TREASURE_GROUP, TreasureGroup> >(treasureFile) ?? TreasureGroupDefaultConfig.CreateTreasureGroup(treasureFile);
                    areaTreasureGroups.Add(currentLocation.Name, tresureGroups);
                }
                openWaterTiles.Add(currentLocation.Name, mapOreConfig);
            }
        }