Example #1
0
 private void Enabled_SettingChanged(object sender, EventArgs e)
 {
     if (Enabled.Value)
     {
         TweakLogger.LogInfo("TweakBase", $"Enabled Tweak: {Name}.");
     }
     else
     {
         TweakLogger.LogInfo("TweakBase", $"Disabled Tweak: {Name}.");
     }
 }
Example #2
0
 private void EnableTweak(Type type, TweakAttribute customAttr)
 {
     try
     {
         var   ctor  = type.GetConstructor(constructorParameters);
         Tweak tweak = (Tweak)ctor.Invoke(new object[4] {
             Config, customAttr.Name, customAttr.DefaultEnabled, customAttr.Description
         });                                                                                                                             //Init this array outside the loop if making this a lib or you just have a lot of tweaks.
         tweak.ReloadHooks();
     }
     catch
     {
         TweakLogger.Log($"Couldn't load tweak: {customAttr.Name}", 0);
     }
 }
Example #3
0
 /// <summary>Use Reflection to set the name from the HarbTweak attribute to prevent having to declare it twice</summary>
 /// <param name="config">A reference to the Config of the calling plugin</param>
 /// <param name="name">The name of this tweak, should be identical to the HarbTweak attribute name.</param>
 /// <param name="defaultEnabled">If this tweak is enabled by default.</param>
 /// <param name="description">If this tweak is enabled by default.</param>
 public Tweak(ConfigFile config, string name, bool defaultEnabled, string description)
 {
     Config  = config;
     Name    = name;
     Enabled = AddConfig("Enabled", defaultEnabled, description);
     Enabled.SettingChanged += Enabled_SettingChanged;
     MakeConfig();
     if (Enabled.Value)
     {
         TweakLogger.Log($"Loaded Tweak: {Name}.");
     }
     else
     {
         TweakLogger.Log($"Prepared Tweak: {Name}.");
     }
 }
Example #4
0
        private void MultiShopController_on_CreateTerminals1(On.RoR2.MultiShopController.orig_CreateTerminals orig, RoR2.MultiShopController self)
        {
            orig(self);

            int questionCount          = 0;
            int sameCount              = 0;
            List <PickupIndex> pickups = new List <PickupIndex>();

            Xoroshiro128Plus rng = self.GetFieldValue <Xoroshiro128Plus>("rng");

            GameObject[]           terminals = self.GetFieldValue <GameObject[]>("terminalGameObjects");
            ShopTerminalBehavior[] behaviors = new ShopTerminalBehavior[3];
            for (int i = 0; i < 3; i++)
            {
                GameObject           terminal = terminals[i];
                ShopTerminalBehavior stb      = terminal.GetComponent <ShopTerminalBehavior>();

                behaviors[i] = stb;
                if (stb)
                {
                    bool shopDirty = false;
                    bool hidden    = stb.pickupIndexIsHidden;
                    if (hidden)
                    {
                        questionCount++;
                        if (questionCount > maxQuestions.Value)
                        {
                            hidden     = false;
                            shopDirty |= true;
                        }
                    }
                    PickupIndex pickupIndex = stb.CurrentPickupIndex();
                    if (pickups.Contains(pickupIndex))
                    {
                        sameCount++;
                        if (sameCount > maxSame.Value)
                        {
                            shopDirty |= true;
                            switch (self.itemTier)
                            {
                            case ItemTier.Tier1:
                                pickupIndex = rng.NextElementUniform(Run.instance.availableTier1DropList);
                                break;

                            case ItemTier.Tier2:
                                pickupIndex = rng.NextElementUniform(Run.instance.availableTier2DropList);
                                break;

                            case ItemTier.Tier3:
                                pickupIndex = rng.NextElementUniform(Run.instance.availableTier3DropList);
                                break;

                            case ItemTier.Lunar:
                                pickupIndex = rng.NextElementUniform(Run.instance.availableLunarDropList);
                                break;
                            }
                        }
                    }
                    pickups.Add(pickupIndex);

                    if (shopDirty)
                    {
                        stb.SetPickupIndex(pickupIndex, hidden);
                    }
                }
                else
                {
                    TweakLogger.LogWarning("MultiShopImprovements", "Something was wrong with a terminal, aborting.");
                    return;
                }
            }
            while (questionCount > maxQuestions.Value)
            {
                questionCount--;
                behaviors[questionCount].SetPickupIndex(pickups[questionCount], false);
            }
            if (sameCount > maxSame.Value)
            {
            }
        }
Example #5
0
 private void LogLevel_SettingChanged(object _, EventArgs __)
 {
     TweakLogger.SetLogLevel(LogLevel.Value);
 }
Example #6
0
 protected void LogInfo(string text)
 {
     TweakLogger.LogInfo(Name, text);
 }