Skip to content

Commit

Permalink
2.0.2 -> Fix price bug (Thanks @Mattcy1 !), make price increase less …
Browse files Browse the repository at this point in the history
…drastic
  • Loading branch information
DarkTerraYT committed Nov 1, 2024
1 parent 08155c1 commit 46eb8be
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
21 changes: 19 additions & 2 deletions Api/Enhancements/ModEnhancement.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BTD_Mod_Helper.Api;
using BTD_Mod_Helper.Api.Helpers;
using BTD_Mod_Helper.Extensions;
using EnhancementMonkey.Api.Enhancements.Paragon;
using EnhancementMonkey.Api.Enhancements.Unlocks;
Expand All @@ -13,7 +14,9 @@
using Il2CppAssets.Scripts.Unity.UI_New.InGame;
using Il2CppAssets.Scripts.Unity.UI_New.InGame.AbilitiesMenu;
using Il2CppAssets.Scripts.Unity.UI_New.Popups;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;

namespace EnhancementMonkey.Api.Enhancements
{
Expand All @@ -40,6 +43,20 @@ protected ModEnhancement() { }
[EnhancementType.Paragon] = 0
};

/// <summary>
/// Updates <see cref="TrueBaseCost"/> based on <see cref="InGame.instance"/>, if it's not null.
/// </summary>
public static void UpdateTrueBaseCostsByGameMode()
{
if (InGame.instance.GetGameModel() != null)
{
foreach(var enhancement in GetContent<ModEnhancement>())
{
enhancement.TrueBaseCost = CostHelper.CostForDifficulty(enhancement.BaseCost, InGame.instance);
}
}
}

public sealed override int RegisterPerFrame => EnhancementsLoadedPerFrame;

// Methods
Expand Down Expand Up @@ -136,7 +153,7 @@ public void ApplyEnhancement(Il2CppAssets.Scripts.Simulation.Towers.Tower tower)
}
}

Cost += (int)(BaseCost * CostMultiplier); // Fix Price Multi - Mattcy1
Cost += (int) (BaseCost * (CostMultiplier - 1));

ModifyOther();
AbilityMenu.instance.AbilitiesChanged(); // Update Ability Menu
Expand Down Expand Up @@ -403,7 +420,7 @@ public virtual void OnLock()
/// <summary>
/// Used in the mod for locking
/// </summary>
public uint TimesBought = 0;
public int TimesBought = 0;
/// <summary>
/// Can be bought, if this is set to true then the enhancement will be hidden on next open
/// </summary>
Expand Down
4 changes: 0 additions & 4 deletions Api/Ui/MainUi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,6 @@ private static IEnumerator LoadEnhancementPanels(List<ModEnhancement> enhancemen
InGame.instance.AddCash(-enhancement.Cost);
enhancementMonkey.worth += enhancement.Cost;


enhancement.Cost += (int)(enhancement.TrueBaseCost * enhancement.CostMultiplier); // Fixed Price Multi - Mattcy1
enhancement.TimesBought++;

if (!BoughtEnhancements.Contains(enhancement))
Expand All @@ -391,8 +389,6 @@ private static IEnumerator LoadEnhancementPanels(List<ModEnhancement> enhancemen
if (DebugMode)
{
Debug("Bought Enhancement!", LogLevel.Info);
Debug(enhancement.TrueBaseCost, LogLevel.Info);
Debug(enhancement.CostMultiplier, LogLevel.Info);
}
if (PopupScreen.instance != null)
{
Expand Down
10 changes: 8 additions & 2 deletions EnhancementMonkey.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using BTD_Mod_Helper.Api;
using BTD_Mod_Helper.Api.ModOptions;
using BTD_Mod_Helper.Extensions;
using EnhancementMonkey;
using EnhancementMonkey.Api.Enhancements.Paragon;
using EnhancementMonkey.Api.Ui.Submenues;
using HarmonyLib;
using Il2CppAssets.Scripts.Models;
using Il2CppAssets.Scripts.Models.Profile;
using Il2CppAssets.Scripts.Simulation;
using Il2CppAssets.Scripts.Simulation.Objects;
using Il2CppAssets.Scripts.Simulation.Towers;
Expand All @@ -13,6 +16,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static Il2CppAssets.Scripts.Simulation.Simulation;

Expand All @@ -28,6 +32,7 @@ public class EnhancementMonkey : BloonsTD6Mod
public static bool MonkeyTown = false;

public static List<ModEnhancement> BoughtEnhancements = [];

Check failure on line 34 in EnhancementMonkey.cs

View workflow job for this annotation

GitHub Actions / build

Invalid expression term '['

Check failure on line 34 in EnhancementMonkey.cs

View workflow job for this annotation

GitHub Actions / build

Syntax error; value expected

/// <summary>
/// Logs a certain thing if <see cref="DebugMode"/> and the minimum log level is at least this log level
/// </summary>
Expand Down Expand Up @@ -182,6 +187,7 @@ public static void Reset()

enhancement.Added = false;
}

if (LevelsUnlocked)
{
foreach (ModEnhancement enhancement in ModEnhancement.Enhancements)
Expand All @@ -201,15 +207,15 @@ public static void Reset()
MonkeyTown = false;
}



public override void OnGameModelLoaded(GameModel model)
{
Reset();
foreach ((string name, bool value) in ModSubmenu.Filters)
{
ModSubmenu.Filters[name] = true;
}


}

public override void OnCashAdded(double amount, Simulation.CashType from, int cashIndex, Simulation.CashSource source, Tower tower)
Expand Down
2 changes: 1 addition & 1 deletion LATEST.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Bug fixes, fix for v45, greatly improve submenu loading.
Fix pricing bug
2 changes: 1 addition & 1 deletion ModHelperData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace EnhancementMonkey;
public static class ModHelperData
{
public const string WorksOnVersion = "45";
public const string Version = "2.0.1";
public const string Version = "2.0.2";
public const string Name = "Enhancement Monkey";

public const string Description = "Ancient monkey but instead of rng it's strategy, but also adds a bit more than that.\nAll supported mods are not required but content from them won't load without the mod\n\n\nThis mod uses templates to make adding enhancements easier. This is for sake of time, and also making the mod easier to modify. \nFor info on how to use these templates check out the wiki on github! (You can get to github by pressing the home button)\n\n Any and all bugs get reported to me directly on discord (dm, my discord server or btd6 mod helper discord) or on github";
Expand Down

0 comments on commit 46eb8be

Please sign in to comment.