コード例 #1
0
ファイル: PanningMod.cs プロジェクト: ZaRx485/smapi-mod-dump
        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")));
            }
        }
コード例 #2
0
        public override void Entry(IModHelper helper)
        {
            Instance = this;
            helper.Events.Display.RenderedHud += Display_RenderedHud;
            helper.Events.GameLoop.SaveLoaded += GameLoop_SaveLoaded;

            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");
            }
        }
コード例 #3
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")));
            }
        }
コード例 #4
0
        public override void Entry(IModHelper helper)
        {
            Instance  = this;
            modHelper = helper;

            config = helper.Data.ReadJsonFile <ModConfig>("config.json") ?? ModConfigDefaultConfig.CreateDefaultConfig("config.json");
            config = ModConfigDefaultConfig.UpdateConfigToLatest(config, "config.json");

            if (config.enableMod)
            {
                helper.Events.Input.ButtonReleased += Input_ButtonReleased;
                helper.Events.GameLoop.DayStarted  += GameLoop_DayStarted;
                helper.Events.GameLoop.TimeChanged += GameLoop_TimeChanged;
                helper.Events.GameLoop.SaveLoaded  += GameLoop_SaveLoaded;
                //helper.Events.GameLoop.GameLaunched += GameLoop_GameLaunched;

                harmony = HarmonyInstance.Create("com.aairthegreat.mod.trainloot");
                harmony.Patch(typeof(TrainCar).GetMethod("draw"), null, new HarmonyMethod(typeof(TrainCarOverrider).GetMethod("postfix_getTrainTreasure")));
                harmony.Patch(typeof(Railroad).GetMethod("PlayTrainApproach"), new HarmonyMethod(typeof(RailroadOverrider).GetMethod("prefix_playTrainApproach")));
                string trainCarFile = Path.Combine("DataFiles", "trains.json");
                trainCars = helper.Data.ReadJsonFile <Dictionary <TRAINS, TrainData> >(trainCarFile) ?? TrainDefaultConfig.CreateTrainCarData(trainCarFile);

                bool updateLoot = false;
                foreach (var train in  trainCars.Values)
                {
                    //updated list to include new base game treasure
                    if (!train.HasItem(806))
                    {
                        train.treasureList.Add(new TrainTreasure(806, "Leprechaun Shoes", 0.01, LOOT_RARITY.RARE, true));
                        updateLoot = true;
                    }
                }

                if (updateLoot)
                {
                    helper.Data.WriteJsonFile(trainCarFile, trainCars);
                }

                SetupMultiplayerObject();
            }
        }
コード例 #5
0
        public override void Entry(IModHelper helper)
        {
            Instance = this;
            config   = helper.Data.ReadJsonFile <ModConfig>("config.json") ?? ModConfigDefaultConfig.CreateDefaultConfig("config.json");

            if (config.enableMod)
            {
                harmony = HarmonyInstance.Create("com.aairthegreat.mod.garbagecan");
                harmony.Patch(typeof(Town).GetMethod("checkAction"), new HarmonyMethod(typeof(GarbageCanOverrider).GetMethod("prefix_betterGarbageCans")));

                string garbageCanFile = Path.Combine("DataFiles", "garbage_cans.json");
                garbageCans = helper.Data.ReadJsonFile <Dictionary <GARBAGE_CANS, GarbageCan> >(garbageCanFile) ?? GarbageCanDefaultConfig.CreateGarbageCans(garbageCanFile);

                AddTrashToCans(config.baseTrashChancePercent);
                helper.Events.GameLoop.SaveLoaded += GameLoop_SaveLoaded;
                helper.Events.GameLoop.DayStarted += GameLoop_DayStarted;
                Type      type = typeof(Game1);
                FieldInfo info = type.GetField("multiplayer", BindingFlags.NonPublic | BindingFlags.Static);
                multiplayer = info.GetValue(null) as Multiplayer;
            }
        }
コード例 #6
0
        public override void Entry(IModHelper helper)
        {
            Instance = this;
            config   = helper.Data.ReadJsonFile <ModConfig>("config.json") ?? ModConfigDefaultConfig.CreateDefaultConfig("config.json");

            if (config.enableMod)
            {
                helper.Events.Input.ButtonReleased += Input_ButtonReleased;
                helper.Events.GameLoop.DayStarted  += GameLoop_DayStarted;
                helper.Events.GameLoop.TimeChanged += GameLoop_TimeChanged;
                helper.Events.GameLoop.SaveLoaded  += GameLoop_SaveLoaded;

                harmony = HarmonyInstance.Create("com.aairthegreat.mod.trainloot");
                harmony.Patch(typeof(TrainCar).GetMethod("draw"), null, new HarmonyMethod(typeof(TrainCarOverrider).GetMethod("postfix_getTrainTreasure")));

                string trainCarFile = Path.Combine("DataFiles", "trains.json");
                trainCars = helper.Data.ReadJsonFile <Dictionary <TRAINS, TrainData> >(trainCarFile) ?? TrainDefaultConfig.CreateTrainCarData(trainCarFile);

                SetupMultiplayerObject();
            }
        }
コード例 #7
0
        public override void Entry(IModHelper helper)
        {
            Instance = this;
            helper.Events.Display.RenderedHud += Display_RenderedHud;

            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 (!helper.Translation.GetTranslations().Any())
            {
                this.Monitor.Log("The translation files in this mod's i18n folder seem to be missing. The mod will still work, but you'll see 'missing translation' messages. Try reinstalling the mod to fix this.", LogLevel.Warn);
            }

            ConfigStaticTranslationStrings();
        }