Skip to content

Commit

Permalink
Initial fixes for v41.0
Browse files Browse the repository at this point in the history
  • Loading branch information
doombubbles committed Feb 7, 2024
1 parent 3ce51f1 commit 0b209b8
Show file tree
Hide file tree
Showing 17 changed files with 338 additions and 96 deletions.
2 changes: 2 additions & 0 deletions BloonsTD6 Mod Helper/Api/Enums/UpgradeType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public static class UpgradeType
public const string TripleGuns = "Triple Guns";
public const string ArmorPiercingDarts = "Armor Piercing Darts";
public const string SubCommander = "Sub Commander";
public const string MonkeysubParagon = "MonkeySub Paragon";
public const string FasterShootingBuccaneer = "Buccaneer-Faster Shooting";
public const string DoubleShotBuccaneer = "Buccaneer-Double Shot";
public const string Destroyer = "Buccaneer-Destroyer";
Expand Down Expand Up @@ -765,6 +766,7 @@ public static class UpgradeType
{ "TripleGuns", TripleGuns },
{ "ArmorPiercingDarts", ArmorPiercingDarts },
{ "SubCommander", SubCommander },
{ "MonkeysubParagon", MonkeysubParagon },
{ "FasterShootingBuccaneer", FasterShootingBuccaneer },
{ "DoubleShotBuccaneer", DoubleShotBuccaneer },
{ "Destroyer", Destroyer },
Expand Down
260 changes: 251 additions & 9 deletions BloonsTD6 Mod Helper/Api/Enums/VanillaSprites.cs

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion BloonsTD6 Mod Helper/Api/UI/ModGameMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,16 @@ internal static void PatchAllTheOpens(HarmonyLib.Harmony harmony)
{
foreach (var type in Types.Keys)
{
if (MelonUtils.IsUnderWineOrSteamProton() && type == typeof(AchievementsScreen)) continue;
if (MelonUtils.IsUnderWineOrSteamProton() &&

This comment has been minimized.

Copy link
@Emilerg

Emilerg Mar 7, 2024

Gut

(type == typeof(AchievementsScreen) ||
type == typeof(GameEventsScreen) ||
type == typeof(CollectionEventUI) ||
type == typeof(PlaySocialScreen) ||
type == typeof(HeroInGameScreen) ||
type == typeof(LevelUpScreen)))
{
continue;
}

var data = DataNames.GetValueOrDefault(type, "data");
try
Expand Down
52 changes: 36 additions & 16 deletions BloonsTD6 Mod Helper/BloonsTD6Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,11 @@ public virtual void OnNewGameModel(GameModel result)
/// <param name="towerInventory"></param>
/// <param name="allTowersInTheGame"></param>
[Obsolete("No longer implemented.")]
public virtual void OnTowerInventoryInitialized(TowerInventory towerInventory,
List<TowerDetailsModel> allTowersInTheGame)
public virtual void OnTowerInventoryInitialized
(
TowerInventory towerInventory,
List<TowerDetailsModel> allTowersInTheGame
)
{
}

Expand Down Expand Up @@ -417,10 +420,13 @@ public virtual void OnBloonPopped(Bloon bloon)
/// Equivalent to a HarmonyPostFix on Bloon.Damaged
/// </summary>
[Obsolete("No longer implemented")]
public virtual void PostBloonDamaged(Bloon bloon, float totalAmount, Projectile projectile,
public virtual void PostBloonDamaged
(
Bloon bloon, float totalAmount, Projectile projectile,
bool distributeToChildren, bool overrideDistributeBlocker, bool createEffect, [Optional] Tower tower,
[Optional] BloonProperties immuneBloonProperties, bool canDestroyProjectile = true,
bool ignoreNonTargetable = false, bool blockSpawnChildren = false)
bool ignoreNonTargetable = false, bool blockSpawnChildren = false
)
{
}

Expand All @@ -433,8 +439,11 @@ public virtual void PostBloonDamaged(Bloon bloon, float totalAmount, Projectile
/// <param name="newEmissions"></param>
/// <param name="round"></param>
/// <param name="index"></param>
public virtual void OnBloonEmissionsAdded(Spawner spawner, Il2CppReferenceArray<BloonEmissionModel> newEmissions,
int round, int index = 0)
public virtual void OnBloonEmissionsAdded
(
Spawner spawner, Il2CppReferenceArray<BloonEmissionModel> newEmissions,
int round, int index = 0
)
{
}

Expand All @@ -449,8 +458,11 @@ public virtual void OnBloonEmissionsAdded(Spawner spawner, Il2CppReferenceArray<
/// <param name="index"></param>
/// <param name="startingDist"></param>
/// <param name="bloon"></param>
public virtual void OnBloonEmitted(Spawner spawner, BloonModel bloonModel, int round, int index, float startingDist,
ref Bloon bloon)
public virtual void OnBloonEmitted
(
Spawner spawner, BloonModel bloonModel, int round, int index, float startingDist,
ref Bloon bloon
)
{
}

Expand Down Expand Up @@ -560,8 +572,11 @@ public virtual void OnTowerLoaded(Tower tower, TowerSaveDataModel saveData)
/// <br />
/// Equivalent to a HarmonyPostFix on Simulation.AddCash
/// </summary>
public virtual void OnCashAdded(double amount, Simulation.CashType from,
int cashIndex, Simulation.CashSource source, Tower tower)
public virtual void OnCashAdded
(
double amount, Simulation.CashType from,
int cashIndex, Simulation.CashSource source, Tower tower
)
{
}

Expand All @@ -570,8 +585,11 @@ public virtual void OnCashAdded(double amount, Simulation.CashType from,
/// <br />
/// Equivalent to a HarmonyPostFix on Simulation.RemoveCash
/// </summary>
public virtual void OnCashRemoved(double amount, Simulation.CashType from, int cashIndex,
Simulation.CashSource source)
public virtual void OnCashRemoved
(
double amount, Simulation.CashType from, int cashIndex,
Simulation.CashSource source
)
{
}

Expand Down Expand Up @@ -715,8 +733,7 @@ public virtual void OnGameObjectsReset()
/// <param name="index"></param>
/// <param name="showAmount"></param>
/// <param name="button"></param>
public virtual void OnTowerButtonCreated(TowerModel tower, int index, bool showAmount,
ref TowerPurchaseButton button)
public virtual void OnTowerButtonCreated(TowerModel tower, int index, bool showAmount, ref ITowerPurchaseButton button)
{
}

Expand All @@ -728,8 +745,11 @@ public virtual void OnTowerButtonCreated(TowerModel tower, int index, bool showA
/// <param name="towerInventory"></param>
/// <param name="baseTowers"></param>
/// <returns></returns>
public virtual void PreTowerInventoryInit(TowerInventory towerInventory,
ref IEnumerable<TowerDetailsModel> baseTowers)
public virtual void PreTowerInventoryInit
(
TowerInventory towerInventory,
ref IEnumerable<TowerDetailsModel> baseTowers
)
{
}

Expand Down
11 changes: 7 additions & 4 deletions BloonsTD6 Mod Helper/Extensions/ModelExtensions/BloonModelExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ public static void SpawnBloonModel(this BloonModel bloonModel)
/// <param name="bloonModel"></param>
/// <param name="count">Number of bloons in this emission model</param>
/// <param name="spacing">Space between each bloon in this emission model</param>
public static Il2CppReferenceArray<BloonEmissionModel> CreateBloonEmissionModel(this BloonModel bloonModel,
int count, int spacing) => Game.instance.model.CreateBloonEmissions(bloonModel, count, spacing);
public static Il2CppReferenceArray<BloonEmissionModel> CreateBloonEmissionModel
(
this BloonModel bloonModel,
int count, int spacing
) => Game.instance.model.CreateBloonEmissions(bloonModel, count, spacing);

/// <summary>
/// Return all BloonToSimulations with this BloonModel
Expand All @@ -101,9 +104,9 @@ public static List<BloonToSimulation> GetAllBloonToSim(this BloonModel bloonMode

var bloonSims = InGame.instance.GetUnityToSimulation()?.GetAllBloons();
if (bloonSims is null || !bloonSims.Any())
return Array.Empty<BloonToSimulation>().ToList();
return new List<BloonToSimulation>();

var results = bloonSims.Where(b => b.GetBaseModel().IsEqual(bloonModel)).ToList();
var results = bloonSims.ToList().Where(b => b.GetBaseModel().IsEqual(bloonModel)).ToList();
return results;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Il2CppAssets.Scripts.Models.TowerSets;
using Il2CppAssets.Scripts.Unity;
using Il2CppAssets.Scripts.Unity.UI_New.InGame.StoreMenu;
using UnityEngine;
namespace BTD_Mod_Helper.Extensions;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public static TowerDetailsModel GetTowerDetailsModel(this TowerModel towerModel)
/// Return the TowerPurchaseButton for this TowerModel.
/// </summary>
public static TowerPurchaseButton GetTowerPurchaseButton(this TowerModel towerModel) =>
ShopMenu.instance.GetTowerButtonFromBaseId(towerModel.GetBaseId());
ShopMenu.instance.GetTowerButtonFromBaseId(towerModel.GetBaseId()).GetComponent<TowerPurchaseButton>();

/// <summary>
/// Return the number position of this TowerModel in the list of all tower models
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ namespace BTD_Mod_Helper.Extensions;
/// </summary>
public static class StandardTowerPurchaseButtonExt
{
/*
/// <summary>
/// Set the background image of this button
/// </summary>
/// <param name="button"></param>
/// <param name="texture2D"></param>
public static void SetBackground(this StandardTowerPurchaseButton button, Texture2D texture2D)
public static void SetBackground(this TowerPurchaseButton button, Texture2D texture2D)
{
button.bg = button.gameObject.GetComponent<Image>();
var sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height),
Expand All @@ -28,10 +29,11 @@ public static void SetBackground(this StandardTowerPurchaseButton button, Textur
/// </summary>
/// <param name="button"></param>
/// <param name="sprite"></param>
public static void SetBackground(this StandardTowerPurchaseButton button, Sprite sprite)
public static void SetBackground(this TowerPurchaseButton button, Sprite sprite)
{
button.bg = button.gameObject.GetComponent<Image>();
button.bg.overrideSprite = sprite;
button.bg.sprite = sprite;
}
*/
}
5 changes: 4 additions & 1 deletion BloonsTD6 Mod Helper/LATEST.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
- Fixed hints for custom round sets
- Fixes for BTD6 v41.0
- Updated VanillaSprites and UpgradeTypes for v41.0
- Fixed hints for custom round sets
- Fixed some more crashes for Linux / Wine / Proton users
2 changes: 1 addition & 1 deletion BloonsTD6 Mod Helper/ModHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace BTD_Mod_Helper;
public static class ModHelper
{
internal const string Name = "BloonsTD6 Mod Helper";
internal const string Version = "3.1.16";
internal const string Version = "3.1.17";
internal const string RepoOwner = "gurrenm3";
internal const string RepoName = "BTD-Mod-Helper";
internal const string Description =
Expand Down
2 changes: 1 addition & 1 deletion BloonsTD6 Mod Helper/Patches/InGame/Hotkeys_Setup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ private static void Postfix(Hotkeys __instance)
{
foreach (var towerPurchaseButton in ShopMenu.instance.ActiveTowerButtons)
{
var towerBaseId = towerPurchaseButton.towerModel.baseId;
var towerBaseId = towerPurchaseButton.TowerModel.baseId;

if (!ModTowerHelper.ModTowerCache.TryGetValue(towerBaseId, out var modTower) || modTower.Hotkey == null)
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ internal static class ShopMenu_CreateTowerButton
{

[HarmonyPostfix]
private static void Postfix(TowerModel model, int buttonIndex, bool showCounts,
ref TowerPurchaseButton __result)
private static void Postfix(TowerModel model, int buttonIndex, bool showCounts, ref ITowerPurchaseButton __result)
{
var unref__result = __result;
ModHelper.PerformHook(mod =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
using UnityEngine.UI;
namespace BTD_Mod_Helper.Patches.UI;

[HarmonyPatch(typeof(StandardTowerPurchaseButton), nameof(StandardTowerPurchaseButton.DetermineBackgroundSprite))]
internal class StandardTowerPurchaseButton_DetermineBackgroundSprite
[HarmonyPatch(typeof(TowerPurchaseButton2D), nameof(TowerPurchaseButton2D.DetermineBackgroundSprite))]
internal class TowerPurchaseButton2D_DetermineBackgroundSprite
{
[HarmonyPrefix]
internal static bool Prefix(StandardTowerPurchaseButton __instance, ref SpriteReference __result)
internal static bool Prefix(TowerPurchaseButton2D __instance, ref SpriteReference __result)
{
if (__instance.towerModel.GetModTower()?.ModTowerSet is ModTowerSet modTowerSet)
{
Expand All @@ -20,11 +20,11 @@ internal static bool Prefix(StandardTowerPurchaseButton __instance, ref SpriteRe
}
}

[HarmonyPatch(typeof(StandardTowerPurchaseButton), nameof(StandardTowerPurchaseButton.UpdateDisplay))]
internal class StandardTowerPurchaseButton_UpdateTowerDisplay
[HarmonyPatch(typeof(TowerPurchaseButton2D), nameof(TowerPurchaseButton2D.UpdateDisplay))]
internal class TowerPurchaseButton2D_UpdateTowerDisplay
{
[HarmonyPostfix]
internal static void Postfix(StandardTowerPurchaseButton __instance)
internal static void Postfix(TowerPurchaseButton2D __instance)
{
if (__instance.towerModel.GetModTower()?.ModTowerSet is ModTowerSet modTowerSet)
{
Expand Down
16 changes: 8 additions & 8 deletions Documentation/BTD_Mod_Helper.BloonsTD6Mod.md
Original file line number Diff line number Diff line change
Expand Up @@ -898,34 +898,34 @@ Equivalent to a HarmonyPostFix on TitleScreen.Start
public virtual void OnTitleScreen();
```

<a name='BTD_Mod_Helper.BloonsTD6Mod.OnTowerButtonCreated(TowerModel,int,bool,TowerPurchaseButton)'></a>
<a name='BTD_Mod_Helper.BloonsTD6Mod.OnTowerButtonCreated(TowerModel,int,bool,ITowerPurchaseButton)'></a>

## BloonsTD6Mod.OnTowerButtonCreated(TowerModel, int, bool, TowerPurchaseButton) Method
## BloonsTD6Mod.OnTowerButtonCreated(TowerModel, int, bool, ITowerPurchaseButton) Method

Called after a TowerPurchaseButton is created
<br/>
Equivalent to a HarmonyPostfix on ShopMenu.CreateTowerButton

```csharp
public virtual void OnTowerButtonCreated(TowerModel tower, int index, bool showAmount, ref TowerPurchaseButton button);
public virtual void OnTowerButtonCreated(TowerModel tower, int index, bool showAmount, ref ITowerPurchaseButton button);
```
#### Parameters

<a name='BTD_Mod_Helper.BloonsTD6Mod.OnTowerButtonCreated(TowerModel,int,bool,TowerPurchaseButton).tower'></a>
<a name='BTD_Mod_Helper.BloonsTD6Mod.OnTowerButtonCreated(TowerModel,int,bool,ITowerPurchaseButton).tower'></a>

`tower` [Il2CppAssets.Scripts.Models.Towers.TowerModel](https://docs.microsoft.com/en-us/dotnet/api/Il2CppAssets.Scripts.Models.Towers.TowerModel 'Il2CppAssets.Scripts.Models.Towers.TowerModel')

<a name='BTD_Mod_Helper.BloonsTD6Mod.OnTowerButtonCreated(TowerModel,int,bool,TowerPurchaseButton).index'></a>
<a name='BTD_Mod_Helper.BloonsTD6Mod.OnTowerButtonCreated(TowerModel,int,bool,ITowerPurchaseButton).index'></a>

`index` [System.Int32](https://docs.microsoft.com/en-us/dotnet/api/System.Int32 'System.Int32')

<a name='BTD_Mod_Helper.BloonsTD6Mod.OnTowerButtonCreated(TowerModel,int,bool,TowerPurchaseButton).showAmount'></a>
<a name='BTD_Mod_Helper.BloonsTD6Mod.OnTowerButtonCreated(TowerModel,int,bool,ITowerPurchaseButton).showAmount'></a>

`showAmount` [System.Boolean](https://docs.microsoft.com/en-us/dotnet/api/System.Boolean 'System.Boolean')

<a name='BTD_Mod_Helper.BloonsTD6Mod.OnTowerButtonCreated(TowerModel,int,bool,TowerPurchaseButton).button'></a>
<a name='BTD_Mod_Helper.BloonsTD6Mod.OnTowerButtonCreated(TowerModel,int,bool,ITowerPurchaseButton).button'></a>

`button` [Il2CppAssets.Scripts.Unity.UI_New.InGame.StoreMenu.TowerPurchaseButton](https://docs.microsoft.com/en-us/dotnet/api/Il2CppAssets.Scripts.Unity.UI_New.InGame.StoreMenu.TowerPurchaseButton 'Il2CppAssets.Scripts.Unity.UI_New.InGame.StoreMenu.TowerPurchaseButton')
`button` [Il2CppAssets.Scripts.Unity.UI_New.InGame.StoreMenu.ITowerPurchaseButton](https://docs.microsoft.com/en-us/dotnet/api/Il2CppAssets.Scripts.Unity.UI_New.InGame.StoreMenu.ITowerPurchaseButton 'Il2CppAssets.Scripts.Unity.UI_New.InGame.StoreMenu.ITowerPurchaseButton')

<a name='BTD_Mod_Helper.BloonsTD6Mod.OnTowerCreated(Tower,Entity,Model)'></a>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,4 @@ Extensions for StandardTowerPurchaseButtons
public static class StandardTowerPurchaseButtonExt
```

Inheritance [System.Object](https://docs.microsoft.com/en-us/dotnet/api/System.Object 'System.Object') &#129106; StandardTowerPurchaseButtonExt
### Methods

<a name='BTD_Mod_Helper.Extensions.StandardTowerPurchaseButtonExt.SetBackground(thisStandardTowerPurchaseButton,Sprite)'></a>

## StandardTowerPurchaseButtonExt.SetBackground(this StandardTowerPurchaseButton, Sprite) Method

Set the background image of this button

```csharp
public static void SetBackground(this StandardTowerPurchaseButton button, Sprite sprite);
```
#### Parameters

<a name='BTD_Mod_Helper.Extensions.StandardTowerPurchaseButtonExt.SetBackground(thisStandardTowerPurchaseButton,Sprite).button'></a>

`button` [Il2CppAssets.Scripts.Unity.UI_New.InGame.StoreMenu.StandardTowerPurchaseButton](https://docs.microsoft.com/en-us/dotnet/api/Il2CppAssets.Scripts.Unity.UI_New.InGame.StoreMenu.StandardTowerPurchaseButton 'Il2CppAssets.Scripts.Unity.UI_New.InGame.StoreMenu.StandardTowerPurchaseButton')
<a name='BTD_Mod_Helper.Extensions.StandardTowerPurchaseButtonExt.SetBackground(thisStandardTowerPurchaseButton,Sprite).sprite'></a>

`sprite` [UnityEngine.Sprite](https://docs.microsoft.com/en-us/dotnet/api/UnityEngine.Sprite 'UnityEngine.Sprite')
<a name='BTD_Mod_Helper.Extensions.StandardTowerPurchaseButtonExt.SetBackground(thisStandardTowerPurchaseButton,Texture2D)'></a>

## StandardTowerPurchaseButtonExt.SetBackground(this StandardTowerPurchaseButton, Texture2D) Method

Set the background image of this button

```csharp
public static void SetBackground(this StandardTowerPurchaseButton button, Texture2D texture2D);
```
#### Parameters

<a name='BTD_Mod_Helper.Extensions.StandardTowerPurchaseButtonExt.SetBackground(thisStandardTowerPurchaseButton,Texture2D).button'></a>

`button` [Il2CppAssets.Scripts.Unity.UI_New.InGame.StoreMenu.StandardTowerPurchaseButton](https://docs.microsoft.com/en-us/dotnet/api/Il2CppAssets.Scripts.Unity.UI_New.InGame.StoreMenu.StandardTowerPurchaseButton 'Il2CppAssets.Scripts.Unity.UI_New.InGame.StoreMenu.StandardTowerPurchaseButton')
<a name='BTD_Mod_Helper.Extensions.StandardTowerPurchaseButtonExt.SetBackground(thisStandardTowerPurchaseButton,Texture2D).texture2D'></a>

`texture2D` [UnityEngine.Texture2D](https://docs.microsoft.com/en-us/dotnet/api/UnityEngine.Texture2D 'UnityEngine.Texture2D')
Inheritance [System.Object](https://docs.microsoft.com/en-us/dotnet/api/System.Object 'System.Object') &#129106; StandardTowerPurchaseButtonExt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static TowerModel GetTower(this TowerDetailsModel towerDetailsModel);
Get the TowerPurchaseButton that is used to buy this specific TowerDetailModel

```csharp
public static TowerPurchaseButton GetTowerPurchaseButton(this TowerDetailsModel towerDetailsModel);
public static Transform GetTowerPurchaseButton(this TowerDetailsModel towerDetailsModel);
```
#### Parameters

Expand All @@ -82,7 +82,7 @@ public static TowerPurchaseButton GetTowerPurchaseButton(this TowerDetailsModel
`towerDetailsModel` [Il2CppAssets.Scripts.Models.TowerSets.TowerDetailsModel](https://docs.microsoft.com/en-us/dotnet/api/Il2CppAssets.Scripts.Models.TowerSets.TowerDetailsModel 'Il2CppAssets.Scripts.Models.TowerSets.TowerDetailsModel')
#### Returns
[Il2CppAssets.Scripts.Unity.UI_New.InGame.StoreMenu.TowerPurchaseButton](https://docs.microsoft.com/en-us/dotnet/api/Il2CppAssets.Scripts.Unity.UI_New.InGame.StoreMenu.TowerPurchaseButton 'Il2CppAssets.Scripts.Unity.UI_New.InGame.StoreMenu.TowerPurchaseButton')
[UnityEngine.Transform](https://docs.microsoft.com/en-us/dotnet/api/UnityEngine.Transform 'UnityEngine.Transform')
<a name='BTD_Mod_Helper.Extensions.TowerDetailsModelExt.IsHero(thisTowerDetailsModel)'></a>

Expand Down
Loading

0 comments on commit 0b209b8

Please sign in to comment.