Пример #1
0
 private void OnBeforeModCtor(object mod)
 {
     if (_imported)
     {
         return;
     }
     Utils.SafeWrap(() =>
     {
         if (Localizer.Config.AutoImport)
         {
             var wrapped = new LoadedModWrapper(mod);
             Utils.LogInfo($"Early auto import for mod: [{wrapped.Name}]");
             Import(wrapped);
         }
     });
 }
Пример #2
0
        public Localizer()
        {
            Instance        = this;
            LoadedLocalizer = new LoadedModWrapper("Terraria.ModLoader.Core.AssemblyManager".Type().ValueOf("loadedMods").Invoke("get_Item", "!Localizer"));
            this.SetField("<File>k__BackingField", LoadedLocalizer.File);
            this.SetField("<Code>k__BackingField", LoadedLocalizer.Code);
            Log = LogManager.GetLogger(nameof(Localizer));

            Harmony = HarmonyInstance.Create(nameof(Localizer));
            Harmony.Patch("Terraria.ModLoader.Core.AssemblyManager".Type().Method("Instantiate"), new HarmonyMethod(NoroHelper.MethodInfo(() => AfterLocalizerCtorHook(null))));

            State    = OperationTiming.BeforeModCtor;
            TmodFile = Instance.ValueOf <TmodFile>("File");
            Init();
            _initiated = true;
        }
Пример #3
0
        public Localizer()
        {
            Instance = this;
            var mod = new LoadedModWrapper(Tr().GetType("Terraria.ModLoader.Core.AssemblyManager")
                                           .Field("loadedMods")
                                           .Method("get_Item", "!Localizer"));

            this.SetField("<File>k__BackingField", mod.File);
            this.SetField("<Code>k__BackingField", mod.Code);
            Log = LogManager.GetLogger(nameof(Localizer));

            HarmonyInstance = HarmonyInstance.Create(nameof(Localizer));
            var prefix = new HarmonyMethod(typeof(Localizer).GetMethod(nameof(AfterLocalizerCtorHook), ReflectionHelper.All));

            HarmonyInstance.Patch(Tr().GetType("Terraria.ModLoader.Core.AssemblyManager")
                                  .GetMethod("Instantiate", ReflectionHelper.All), prefix);

            State    = OperationTiming.BeforeModCtor;
            TmodFile = Instance.Prop("File") as TmodFile;
            Init();
            _initiated = true;
        }