Пример #1
0
        public override void Entry(IModHelper helper)
        {
            Mod.Instance = this;
            Log.Monitor  = this.Monitor;

            this.BossBarBg       = this.Helper.Content.Load <Texture2D>("assets/bossbar-bg.png");
            this.BossBarFg       = this.Helper.Content.Load <Texture2D>("assets/bossbar-fg.png");
            this.PrevCropDataKey = $"{this.ModManifest.UniqueID}/prev-data";

            this.Helper.Events.GameLoop.GameLaunched   += this.OnGameLaunched;
            helper.Events.GameLoop.SaveCreated         += this.OnCreated;
            helper.Events.GameLoop.SaveLoaded          += this.OnLoaded;
            helper.Events.GameLoop.Saving              += this.OnSaving;
            this.Helper.Events.GameLoop.UpdateTicked   += this.OnUpdated;
            helper.Events.GameLoop.DayStarted          += this.OnDayStarted;
            helper.Events.GameLoop.DayEnding           += this.OnDayEnding;
            this.Helper.Events.Player.Warped           += this.OnWarped;
            this.Helper.Events.Player.InventoryChanged += this.OnInventoryChanged;
            this.Helper.Events.Input.ButtonPressed     += this.OnButtonPressed;
            this.Helper.Events.Display.RenderedHud     += this.OnRenderedHud;

            SpaceEvents.OnBlankSave     += this.OnBlankSave;
            SpaceEvents.ActionActivated += this.OnActionActivated;
            SpaceEvents.BombExploded    += this.BombExploded;

            HarmonyPatcher.Apply(this,
                                 new HoeDirtPatcher()
                                 );
        }
Пример #2
0
        void StartValheimVR()
        {
            HarmonyPatcher.DoPatching();

            if (VHVRConfig.NonVrPlayer())
            {
                LogDebug("Non VR Mode Patching Complete.");
                return;
            }

            if (VRManager.InitializeVR())
            {
                VRManager.StartVR();
                vrPlayer = new GameObject("VRPlayer");
                DontDestroyOnLoad(vrPlayer);
                vrPlayer.AddComponent <VRPlayer>();
                vrGui = new GameObject("VRGui");
                DontDestroyOnLoad(vrGui);
                vrGui.AddComponent <VRGUI>();
                if (VHVRConfig.RecenterOnStart())
                {
                    VRManager.tryRecenter();
                }
            }
            else
            {
                LogError("Could not initialize VR.");
                enabled = false;
            }
        }
Пример #3
0
        internal static void Init()
        {
            DetectMoreAccessories();

            HarmonyPatcher.PatchAll(typeof(Hooks));

            MakerAPI.InsideMakerChanged   += MakerAPI_InsideMakerChanged;
            MakerAPI.MakerFinishedLoading += (sender, args) => OnSelectedMakerSlotChanged(sender, 0);

            if (MoreAccessoriesInstalled)
            {
                var getAccCmpM = AccessTools.Method(_moreAccessoriesType, "GetChaAccessoryComponent");
                _getChaAccessoryCmp = (control, componentIndex) => (ChaAccessoryComponent)getAccCmpM.Invoke(_moreAccessoriesInstance, new object[] { control, componentIndex });

                var getAccCmpIndexM = AccessTools.Method(_moreAccessoriesType, "GetChaAccessoryComponentIndex");
                _getChaAccessoryCmpIndex = (control, component) => (int)getAccCmpIndexM.Invoke(_moreAccessoriesInstance, new object[] { control, component });
            }
            else
            {
                _getChaAccessoryCmp      = (control, i) => control.cusAcsCmp[i];
                _getChaAccessoryCmpIndex = (control, component) => Array.IndexOf(control.cusAcsCmp, component);
            }

            if (KoikatuAPI.EnableDebugLogging)
            {
                SelectedMakerAccSlotChanged += (sender, args) => KoikatuAPI.Log(LogLevel.Message,
                                                                                $"SelectedMakerAccSlotChanged - id: {args.SlotIndex}, cvs: {args.CvsAccessory.transform.name}, component: {args.AccessoryComponent?.name ?? "null"}");
#if KK
                AccessoriesCopied += (sender, args) => KoikatuAPI.Log(LogLevel.Message,
                                                                      $"AccessoriesCopied - ids: {string.Join(", ", args.CopiedSlotIndexes.Select(x => x.ToString()).ToArray())}, src:{args.CopySource}, dst:{args.CopyDestination}");
#endif
                AccessoryTransferred += (sender, args) => KoikatuAPI.Log(LogLevel.Message,
                                                                         $"AccessoryTransferred - srcId:{args.SourceSlotIndex}, dstId:{args.DestinationSlotIndex}");
            }
        }
Пример #4
0
 public override void Entry(IModHelper helper)
 {
     Utility.SetLogger(Monitor);
     Utility.SetConfigManager(new ConfigManager.ConfigManager(helper.ReadConfig <Config>()));
     HarmonyPatcher.RegisterPatches();
     _ = new RegisterGameEvents(helper);
 }
Пример #5
0
        /*********
        ** Public methods
        *********/
        /// <inheritdoc />
        public override void Entry(IModHelper helper)
        {
            I18n.Init(helper.Translation);
            Mod.Instance = this;
            Log.Monitor  = this.Monitor;
            this.Config  = helper.ReadConfig <ModConfig>();

            helper.Events.GameLoop.GameLaunched += this.OnGameLaunched;
            helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
            helper.Events.Display.MenuChanged   += this.OnMenuChanged;
            helper.Events.Display.RenderedWorld += this.OnRenderedWorld;

            SpaceEvents.OnItemEaten += this.OnItemEaten;

            HarmonyPatcher.Apply(
                this,
                new AxePatcher(),
                new CropPatcher(),
                new Game1Patcher(),
                new HoePatcher(),
                new PickaxePatcher(),
                new WateringCanPatcher()
                );

            ConsoleCommandHelper.RegisterCommandsInAssembly(this);
        }
Пример #6
0
        public void PreLoad()
        {
            HarmonyPatcher.GetInstance().PatchAll(Assembly.GetExecutingAssembly());

            SRML.Console.Console.RegisterCommand(new SetColorsCommand());
            TranslationPatcher.AddTranslationKey("pedia", RAVEBALL_KEY, "Rave Ball");
            TranslationPatcher.AddTranslationKey("pedia", RAVEBALL_UI_KEY, "Rave Ball");
            TranslationPatcher.AddTranslationKey("pedia", RAVEBALL_DESC_KEY,
                                                 "This ball may look plain, but it makes slimes want to party!");
            //IdentifiableRegistry.CreateIdentifiableId(RAVE_BALL_ID, "RAVE_BALL_TOY");
            var bundle = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly()
                                                    .GetManifestResourceStream(typeof(Main), "colorfulslimes"));
            var g = bundle.LoadAsset <GameObject>("raveball");

            g.AddComponent <RegionMember>();
            g.AddComponent <Identifiable>().id = CustomIds.RAVE_BALL_TOY;
            g.layer = LayerMask.NameToLayer("Actor");
            g.AddComponent <Vacuumable>().size = Vacuumable.Size.LARGE;
            g.AddComponent <Raveball>();
            g.transform.GetChild(0).gameObject.AddComponent <VacDelaunchTrigger>();

            LookupRegistry.RegisterIdentifiablePrefab(g);

            SaveRegistry.RegisterDataParticipant <SlimePainter>();
        }
Пример #7
0
        public override void Entry(IModHelper helper)
        {
            Mod.Instance = this;
            Log.Monitor  = this.Monitor;

            HarmonyPatcher.Apply(this,
                                 new ChestPatcher()
                                 );
        }
Пример #8
0
        /*********
        ** Public methods
        *********/
        /// <inheritdoc />
        public override void Entry(IModHelper helper)
        {
            Log.Monitor = this.Monitor;

            helper.Events.Input.ButtonPressed += this.OnButtonPressed;

            HarmonyPatcher.Apply(this,
                                 new ObjectPatcher(this.OnMachineMinutesElapsed)
                                 );
        }
Пример #9
0
        public override void Entry(IModHelper helper)
        {
            Mod.Instance = this;
            Log.Monitor  = this.Monitor;

            HarmonyPatcher.Apply(this,
                                 new xTileLayerPatcher()
                                 );

            this.Helper.ConsoleCommands.Add("llt_adddummy", "", this.DoCommand);
        }
Пример #10
0
        public override void Entry(IModHelper helper)
        {
            Mod.Instance = this;
            Log.Monitor  = this.Monitor;

            BaseEnchantment.GetAvailableEnchantments().Add(new MoreLuresEnchantment());

            HarmonyPatcher.Apply(this,
                                 new FishingRodPatcher()
                                 );
        }
        public void OnStart()
        {
            logger.Debug("Plugin.OnStart");

            HarmonyPatcher.ApplyPatches();

            GameObject timeTrackerGo = new GameObject("TimeTracker");

            timeTrackerGo.AddComponent <TimeTracker>();
            Object.DontDestroyOnLoad(timeTrackerGo);
        }
Пример #12
0
        internal static void Init()
        {
            HarmonyPatcher.PatchAll(typeof(Hooks));

            // Cards -------------------------
            ExtendedSave.CardBeingSaved += OnCardBeingSaved;
            MakerAPI.ChaFileLoaded      += (sender, args) =>
            {
                var chaControl = MakerAPI.GetCharacterControl();
                if (chaControl != null)
                {
                    ReloadChara(chaControl);
                }
            };

            // Coordinates -------------------
            ExtendedSave.CoordinateBeingSaved += file =>
            {
                if (file == null)
                {
                    return;
                }

                // Safe to assume we're in maker
                var character = MakerAPI.GetCharacterControl();
                if (character == null)
                {
                    KoikatuAPI.Log(LogLevel.Error, "[KKAPI] OnCoordinateBeingSaved fired outside chara maker for " + file.coordinateName);
                    KoikatuAPI.Log(LogLevel.Info, new StackTrace());
                    return;
                }

                OnCoordinateBeingSaved(character, file);
            };
            ExtendedSave.CoordinateBeingLoaded += file =>
            {
                if (Hooks.ClothesFileControlLoading || file == null)
                {
                    return;
                }

                // Coord cards are loaded by loading into the character's nowCoordinate
                var cf = ChaControls.FirstOrDefault(x => x.nowCoordinate == file);
                if (cf != null)
                {
                    OnCoordinateBeingLoaded(cf, file);
                }
            };

            if (KoikatuAPI.EnableDebugLogging)
            {
                RegisterExtraBehaviour <TestCharaCustomFunctionController>(null);
            }
        }
Пример #13
0
        public override void Entry(IModHelper helper)
        {
            Log.Monitor = this.Monitor;
            Mod.Config  = helper.ReadConfig <Configuration>();

            HarmonyPatcher.Apply(this,
                                 new GameLocationPatcher()
                                 );

            helper.Events.GameLoop.GameLaunched += this.OnGameLaunched;
        }
Пример #14
0
        public override void Entry(IModHelper helper)
        {
            Mod.Instance = this;
            Log.Monitor  = this.Monitor;

            helper.Events.GameLoop.GameLaunched += this.OnGameLaunched;

            HarmonyPatcher.Apply(this,
                                 new ObjectPatcher(getStatueId: () => Mod.Ja.GetBigCraftableId("Statue of Generosity"))
                                 );
        }
Пример #15
0
        /// <summary>
        /// Called firstly when SMAPI finished loading of the mod.
        /// </summary>
        /// <param name="helper"></param>
        public override void Entry(IModHelper helper)
        {
            // Loads configuration from file.
            Config conf = Helper.ReadConfig <Config>();

            // Initialize InstanceHolder.
            InstanceHolder.Init(this, conf);

            // Initialize Logger
            Logger.Init(this);

            // Register events.
            EventHolder.RegisterEvents(Helper.Events);


            // Registration commands.
            Helper.ConsoleCommands.Add("joedebug", "Debug command for JoE", OnDebugCommand);

            // Limit config values.
            ConfigLimitation.LimitConfigValues();

            // Check mod compatibilities.
            if (ModChecker.IsCoGLoaded(helper))
            {
                Logger.Log("CasksOnGround detected.");
                IsCoGOn = true;
            }

            if (ModChecker.IsCaLoaded(helper))
            {
                Logger.Log("CasksAnywhere detected.");
                IsCaOn = true;
            }

            if (ModChecker.IsCcLoaded(helper))
            {
                Logger.Log("Convenient Chests detected. JoE's CraftingFromChests feature will be disabled and won't patch the game.");
                Conf.CraftingFromChests = false;
                IsCcOn = true;
            }
            else if (!Conf.SafeMode)
            {
                Logger.Log("Start patching using Harmony...");
                HarmonyPatched = HarmonyPatcher.Init();
            }
            else
            {
                Logger.Log("SafeMode enabled, and won't patch the game.");
            }
            helper.WriteConfig(Conf);
            MineIcons.Init(helper);
        }
Пример #16
0
        public override void Entry(IModHelper helper)
        {
            Mod.Instance = this;
            Log.Monitor  = this.Monitor;

            helper.Events.Display.MenuChanged += this.OnMenuChanged;

            HarmonyPatcher.Apply(this,
                                 new FarmerPatcher(),
                                 new RaftPatcher(),
                                 new ToolPatcher()
                                 );
        }
Пример #17
0
        static void Patch()
        {
            TypeReplacements.Add(typeof(TMPro.TextMeshProUGUI), typeof(WeaverCore.Assets.TMPro.TextMeshProUGUI));
            TypeReplacements.Add(typeof(TMPro.TextMeshPro), typeof(WeaverCore.Assets.TMPro.TextMeshPro));


            var original = typeof(UnityEngine.GameObject).GetMethod("AddComponent", new Type[] { typeof(Type) });
            var prefix   = typeof(TMPROAddComponentPatches).GetMethod("AddComponentPrefix", BindingFlags.Public | BindingFlags.Static);

            var patcher = HarmonyPatcher.Create("com.TMProAddComponent.patch");

            patcher.Patch(original, prefix, null);
        }
Пример #18
0
        public override void Entry(IModHelper helper)
        {
            Mod.Instance = this;
            Log.Monitor = this.Monitor;
            Mod.Config = helper.ReadConfig<Configuration>();

            helper.Events.Display.RenderedWorld += this.OnRenderWorld;
            helper.Events.GameLoop.GameLaunched += this.OnGameLaunched;

            HarmonyPatcher.Apply(this,
                new TileRadiusPatcher()
            );
        }
Пример #19
0
        public override void Entry(IModHelper helper)
        {
            Mod.Instance = this;
            Log.Monitor  = this.Monitor;

            HarmonyPatcher.Apply(this,
                                 new CropPatcher(),
                                 new GameLocationPatcher(),
                                 new HoeDirtPatcher(),
                                 new ObjectPatcher(),
                                 new UtilityPatcher()
                                 );
        }
Пример #20
0
        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides simplified APIs for writing mods.</param>
        public override void Entry(IModHelper helper)
        {
            Mod.Instance = this;
            Log.Monitor  = this.Monitor;

            SpaceEvents.OnItemEaten += this.OnItemEaten;

            Skills.RegisterSkill(Mod.Skill = new Skill());

            HarmonyPatcher.Apply(this,
                                 new CraftingPagePatcher(),
                                 new CraftingRecipePatcher()
                                 );
        }
Пример #21
0
        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides simplified APIs for writing mods.</param>
        public override void Entry(IModHelper helper)
        {
            Mod.Instance = this;
            Log.Monitor  = this.Monitor;

            helper.Events.GameLoop.UpdateTicking  += this.OnUpdateTicking;
            helper.Events.Input.ButtonPressed     += this.OnButtonPressed;
            helper.Events.World.ObjectListChanged += this.OnObjectListChanged;

            HarmonyPatcher.Apply(this,
                                 new ItemPatcher(),
                                 new ObjectPatcher()
                                 );
        }
Пример #22
0
            public static void InitHooks()
            {
                HarmonyPatcher.PatchAll(typeof(Hooks));

                var i = HarmonyInstance.Create(typeof(Hooks).FullName);

                var target = typeof(ChaControl).GetMethods().Single(info => info.Name == nameof(ChaControl.Initialize) && info.GetParameters().Length >= 5);

                i.Patch(target, null, new HarmonyMethod(typeof(Hooks), nameof(Hooks.ChaControl_InitializePostHook)));

                var target2 = typeof(ChaControl).GetMethods().Single(info => info.Name == nameof(ChaControl.ReloadAsync) && info.GetParameters().Length >= 5);

                i.Patch(target2, null, new HarmonyMethod(typeof(Hooks), nameof(Hooks.ReloadAsyncPostHook)));
            }
Пример #23
0
    public ModEntry()
    {
        // add mead entry to BAGI's ContentSourceManager dictionary
        // this will fix a likely KeyNotFoundException
        var artisanGoodToSourceTypeDict = (IDictionary)"BetterArtisanGoodIcons.Content.ContentSourceManager".ToType()
                                          .RequireField("artisanGoodToSourceType").GetValue(null) !;

        artisanGoodToSourceTypeDict.Add(Globals.MeadAsArtisanGoodEnum, "Flowers");

        // apply patches
        var harmony = new Harmony(ManifestUniqueID);

        HarmonyPatcher.Apply(harmony);
    }
Пример #24
0
        /*********
        ** Public methods
        *********/
        /// <inheritdoc />
        public override void Entry(IModHelper helper)
        {
            I18n.Init(helper.Translation);
            Log.Monitor             = this.Monitor;
            this.Config             = helper.ReadConfig <Configuration>();
            this.WigglyArmsRenderer = new(helper.Input, helper.Reflection);

            helper.Events.Display.RenderedWorld += this.OnRenderWorld;
            helper.Events.GameLoop.GameLaunched += this.OnGameLaunched;

            HarmonyPatcher.Apply(this,
                                 new TileRadiusPatcher()
                                 );
        }
Пример #25
0
        private LocationConfigManager Config = null !; // set in Entry


        /*********
        ** Public methods
        *********/
        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides simplified APIs for writing mods.</param>
        public override void Entry(IModHelper helper)
        {
            // read config
            this.Config = new LocationConfigManager(
                helper.ReadConfig <ModConfig>()
                );

            // read data
            var fallbackTileTypes = this.LoadFallbackTileTypes();

            // add patches
            HarmonyPatcher.Apply(this,
                                 new LocationPatcher(this.Monitor, this.Config, fallbackTileTypes)
                                 );
        }
Пример #26
0
        // Called before GameContext.Awake
        // this is where you want to register stuff (like custom enum values or identifiable id's)
        // and patch anything you want to patch with harmony
        public void PreLoad()
        {
            Debug.Log("We did it!");
            HarmonyPatcher.GetInstance().PatchAll(Assembly.GetExecutingAssembly());


            // this code registers a callback that's run every time a saved game is loaded
            // in this case it spawns a mosaic boom largo
            SRCallbacks.OnSaveGameLoaded += (scenecontext) =>
            {
                var playerModel = SceneContext.Instance.GameModel.GetPlayerModel();
                SRBehaviour.InstantiateActor(
                    GameContext.Instance.LookupDirector.GetPrefab(Identifiable.Id.MOSAIC_BOOM_LARGO), MonomiPark.SlimeRancher.Regions.RegionRegistry.RegionSetId.UNSET, playerModel.position,
                    playerModel.rotation);
            };
        }
Пример #27
0
        public override void Entry(IModHelper helper)
        {
            Mod.Instance = this;
            Log.Monitor  = this.Monitor;

            this.Helper.Events.Player.Warped += this.OnWarped;

            SpaceEvents.ShowNightEndMenus += this.OnNightMenus;

            Mod.ClockTex = this.Helper.Content.Load <Texture2D>("assets/clock.png");

            HarmonyPatcher.Apply(this,
                                 new Game1Patcher(),
                                 new ObjectPatcher()
                                 );
        }
Пример #28
0
        /// <summary>
        /// Called firstly when SMAPI finished loading of the mod.
        /// </summary>
        /// <param name="helper"></param>
        public override void Entry(IModHelper helper)
        {
            // Initialize Logger
            Logger.Init(Monitor);

            // Initialize InstanceHolder.
            InstanceHolder.Init(this);

            // Register events.
            EventHolder.RegisterEvents(Helper.Events);


            // Registration commands.
            Helper.ConsoleCommands.Add("joedebug", "Debug command for JoE", OnDebugCommand);
            Helper.ConsoleCommands.Add("joerelcon", "Reloading config command for JoE", OnReloadConfigCommand);


            // Limit config values.
            ConfigLimitation.LimitConfigValues();

            // Check mod compatibilities.
            if (ModChecker.IsCoGLoaded(helper))
            {
                Logger.Log("CasksOnGround detected.");
                IsCoGOn = true;
            }

            if (ModChecker.IsCaLoaded(helper))
            {
                Logger.Log("CasksAnywhere detected.");
                IsCaOn = true;
            }

            // Do patching stuff
            if (!Conf.SafeMode)
            {
                HarmonyPatcher.DoPatching();
            }
            else
            {
                Logger.Log("Bypassing patching...");
            }

            helper.WriteConfig(Conf);
            MineIcons.Init(helper);
        }
Пример #29
0
        /*********
        ** Public methods
        *********/
        /// <inheritdoc />
        public override void Entry(IModHelper helper)
        {
            I18n.Init(helper.Translation);

            // read config
            this.Config = this.Helper.ReadConfig <ModConfig>();

            // read data
            ModData?data = this.Helper.Data.ReadJsonFile <ModData>("assets/data.json");

            this.Data = data ?? new ModData();
            {
                string dataPath = Path.Combine(this.Helper.DirectoryPath, "assets", "data.json");
                if (data == null || !File.Exists(dataPath))
                {
                    this.Monitor.Log("The mod's 'assets/data.json' file is missing, so this mod can't work correctly. Please reinstall the mod to fix this.", LogLevel.Error);
                    return;
                }
                if (CommonHelper.GetFileHash(dataPath) != ModEntry.DataFileHash)
                {
                    this.Monitor.Log("Found edits to 'assets/data.json'.");
                }
            }

            // hook events
            helper.Events.Content.AssetRequested += this.OnAssetRequested;
            helper.Events.GameLoop.SaveLoaded    += this.OnSaveLoaded;
            helper.Events.GameLoop.DayEnding     += this.DayEnding;
            helper.Events.GameLoop.GameLaunched  += this.OnGameLaunched;

            // hook Harmony patch
            HarmonyPatcher.Apply(this,
                                 new FarmPatcher(
                                     monitor: this.Monitor,
                                     config: this.Config,
                                     isSmallBeachFarm: location => this.IsSmallBeachFarm(location, out _),
                                     getFishType: this.GetFishType
                                     ),
                                 new CharacterCustomizationPatcher(
                                     config: this.Config,
                                     farmTypeId: this.ModManifest.UniqueID
                                     )
                                 );
        }
Пример #30
0
 void StartValheimVR()
 {
     HarmonyPatcher.DoPatching();
     if (VRManager.InitializeVR())
     {
         VRManager.StartVR();
         vrPlayer = new GameObject("VRPlayer");
         DontDestroyOnLoad(vrPlayer);
         VRPlayer playerComponent = vrPlayer.AddComponent <VRPlayer>();
         vrGui = new GameObject("VRGui");
         DontDestroyOnLoad(vrGui);
         vrGui.AddComponent <VRGUI>();
     }
     else
     {
         LogError("Could not initialize VR.");
         enabled = false;
     }
 }