Skip to content

Commit

Permalink
Updated for MelonLoader 0.5.5 official release
Browse files Browse the repository at this point in the history
  • Loading branch information
doombubbles committed Sep 30, 2022
1 parent 49d2469 commit 4e208aa
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 127 deletions.
13 changes: 0 additions & 13 deletions BloonsTD6 Mod Helper/BloonsTD6Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,6 @@ namespace BTD_Mod_Helper;
/// </summary>
public abstract class BloonsTD6Mod : BloonsMod
{
/// <summary>
/// Adds a TowerModel to the official list of TowerModels being used by the game
/// <br/>
/// Equivalent to calling Game.instance.model.AddTowerToGame(...)
/// </summary>
/// <param name="newTowerModel">The new tower model</param>
/// <param name="towerDetailsModel">A TowerDetailsModel to go with it, if it'll be in the shop</param>
[Obsolete("Just use Game.instance.model.AddTowerToGame")]
public static void AddTowerToGame(TowerModel newTowerModel, TowerDetailsModel towerDetailsModel = null)
{
Game.instance.model.AddTowerToGame(newTowerModel, towerDetailsModel!);
}

#region Networking Hooks

/// <summary>
Expand Down
13 changes: 3 additions & 10 deletions BloonsTD6 Mod Helper/LATEST.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
- Added the `SquareIcon` ModHelperData bool property to make the icon draw as constrained within panels rather than being allowed to slightly overflow
- Added an impossible to miss Popup for if you're not using a compatible MelonLoader version
- Added the ability to use a `<!--Mod Browser Message Start-->` markdown comment in release messages to only include information beyond a certain point
- Added checkmark icons for Verified Modders in the Mod Browser
- Fixed issue where Double Cash mode was doubling cash generation it wasn't supposed to
- Fixed Round Set Changer setting
- Fixed sporadic issue with backing out of a Mod Settings menu
- Fixed `OnMenuClosed()` still happening if you pressed Escape too early for the menu to actually close
- Fixed monorepo mods using ZipName without DllName not showing up in the Mod Browser
- Internally switched from `.parent =` to `SetParent` calls to avoid flooding the MelonLoader debug log
- Updated for the official MelonLoader v0.5.5 release

Use this version of the mod alongside the MelonLoader 0.5.5 you get from the official installer, not the github actions / nightly builds that have been linked previously.
21 changes: 1 addition & 20 deletions BloonsTD6 Mod Helper/MelonMain.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Assets.Scripts.Models.TowerSets.Mods;
using Assets.Scripts.Simulation;
using Assets.Scripts.Simulation.Towers;
using Assets.Scripts.Unity;
using Assets.Scripts.Unity.UI_New.InGame;
using Assets.Scripts.Unity.UI_New.InGame.TowerSelectionMenu;
Expand All @@ -16,7 +12,6 @@
using BTD_Mod_Helper.Api.ModMenu;
using BTD_Mod_Helper.Api.ModOptions;
using BTD_Mod_Helper.Api.Towers;
using BTD_Mod_Helper.UI.Menus;
using BTD_Mod_Helper.UI.Modded;
using TaskScheduler = BTD_Mod_Helper.Api.TaskScheduler;

Expand All @@ -28,7 +23,7 @@ namespace BTD_Mod_Helper;

internal partial class MelonMain : BloonsTD6Mod
{
public override void OnApplicationStart()
public override void OnInitialize()
{
ModContentInstances.SetInstance(GetType(), this);

Expand Down Expand Up @@ -74,20 +69,6 @@ public override void OnApplicationStart()

public override void OnUpdate()
{
if (!MelonLoaderChecker.IsVersionNewEnough())
{
if (PopupScreen.instance != null && !PopupScreen.instance.IsPopupActive())
{
PopupScreen.instance.ShowPopup(PopupScreen.Placement.menuCenter, "Not On MelonLoader 0.5.5",
"Mod Helper failed to load. Not On MelonLoader 0.5.5. Click ok to be taken to a page with more information.",
new Action(() =>
{
ProcessHelper.OpenURL("https://github.com/gurrenm3/BTD-Mod-Helper/wiki/Install-Guide");
}), "Ok", null, "Cancel", Popup.TransitionAnim.Scale, instantClose: true);
}
return;
}

ModByteLoader.OnUpdate();

if (Game.instance is null)
Expand Down
2 changes: 1 addition & 1 deletion BloonsTD6 Mod Helper/Patches/Main_GetInitialLoadTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal static class Main_GetInitialLoadTasks
[HarmonyPostfix]
private static void Postfix(ref SeriesTasks __result)
{
if (ModHelper.FallbackToOldLoading || !MelonLoaderChecker.IsVersionNewEnough()) return;
if (ModHelper.FallbackToOldLoading) return;

var tasks = __result.Tasks.Cast<Il2CppReferenceArray<ITask>>().ToList();
var gameModelLoad = tasks.Last();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ internal static class LocalizationManger_LoadTableAsync
[HarmonyPostfix]
private static void Postfix(LocalizationManager._LoadTableAsync_d__45 __instance)
{
if (!MelonLoaderChecker.IsVersionNewEnough()) return;

var result = __instance.__t__builder.Task.Result;
if (result != null)
{
Expand Down
48 changes: 30 additions & 18 deletions Documentation/BTD_Mod_Helper.BloonsMod.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,39 @@ Runs after the Melon has registered. This callback waits until MelonLoader has f
public virtual void OnApplicationStart();
```

<a name='BTD_Mod_Helper.BloonsMod.OnEarlyInitialize()'></a>

## BloonsMod.OnEarlyInitialize() Method

Runs when the Melon is registered. Executed before the Melon's info is printed to the console. This callback should only be used a constructor for the Melon.

```csharp
public virtual void OnEarlyInitialize();
```

### Remarks
Please note that this callback may run before the Support Module is loaded.
<br>As a result, using unhollowed assemblies may not be possible yet and you would have to override <see cref="M:MelonLoader.MelonBase.OnInitializeMelon"/> instead.</br>

<a name='BTD_Mod_Helper.BloonsMod.OnEarlyInitializeMelon()'></a>

## BloonsMod.OnEarlyInitializeMelon() Method

Runs when the Melon is registered. Executed before the Melon's info is printed to the console. This callback should only be used a constructor for the Melon.

```csharp
public sealed override void OnEarlyInitializeMelon();
```

### Remarks
Please note that this callback may run before the Support Module is loaded.
<br>As a result, using unhollowed assemblies may not be possible yet and you would have to override <see cref="M:MelonLoader.MelonBase.OnInitializeMelon"/> instead.</br>

<a name='BTD_Mod_Helper.BloonsMod.OnInitialize()'></a>

## BloonsMod.OnInitialize() Method

Runs when the Melon is registered. Executed before the Melon's info is printed to the console. This callback should only be used a constructor for the Melon.

Please note that this callback may run before the Support Module is loaded and before the Engine is fully initialized.
<br>As a result, using unhollowed assemblies and creating/getting UnityEngine Objects may not be possible and you would have to override <see cref="M:MelonLoader.MelonBase.OnLoaderInitialized"/> instead.</br>
Runs after the Melon has registered. This callback waits until MelonLoader has fully initialized ([MelonLoader.MelonEvents.OnApplicationStart](https://docs.microsoft.com/en-us/dotnet/api/MelonLoader.MelonEvents.OnApplicationStart 'MelonLoader.MelonEvents.OnApplicationStart')).
```csharp
public virtual void OnInitialize();
Expand All @@ -211,10 +236,7 @@ public virtual void OnInitialize();

## BloonsMod.OnInitializeMelon() Method

Runs when the Melon is registered. Executed before the Melon's info is printed to the console. This callback should only be used a constructor for the Melon.

Please note that this callback may run before the Support Module is loaded and before the Engine is fully initialized.
<br>As a result, using unhollowed assemblies and creating/getting UnityEngine Objects may not be possible and you would have to override <see cref="M:MelonLoader.MelonBase.OnLoaderInitialized"/> instead.</br>
Runs after the Melon has registered. This callback waits until MelonLoader has fully initialized ([MelonLoader.MelonEvents.OnApplicationStart](https://docs.microsoft.com/en-us/dotnet/api/MelonLoader.MelonEvents.OnApplicationStart 'MelonLoader.MelonEvents.OnApplicationStart')).
```csharp
public sealed override void OnInitializeMelon();
Expand Down Expand Up @@ -271,16 +293,6 @@ public virtual void OnKeyUp(UnityEngine.KeyCode keyCode);

`keyCode` [UnityEngine.KeyCode](https://docs.microsoft.com/en-us/dotnet/api/UnityEngine.KeyCode 'UnityEngine.KeyCode')
<a name='BTD_Mod_Helper.BloonsMod.OnLoaderInitialized()'></a>

## BloonsMod.OnLoaderInitialized() Method

Runs after the Melon has registered. This callback waits until MelonLoader has fully initialized ([MelonLoader.MelonEvents.OnApplicationStart](https://docs.microsoft.com/en-us/dotnet/api/MelonLoader.MelonEvents.OnApplicationStart 'MelonLoader.MelonEvents.OnApplicationStart')).
```csharp
public sealed override void OnLoaderInitialized();
```

<a name='BTD_Mod_Helper.BloonsMod.OnModOptionsOpened()'></a>

## BloonsMod.OnModOptionsOpened() Method
Expand Down
25 changes: 0 additions & 25 deletions Documentation/BTD_Mod_Helper.BloonsTD6Mod.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,6 @@ public virtual bool ActOnMessage(NinjaKiwi.NKMulti.Message message);
#### Returns
[System.Boolean](https://docs.microsoft.com/en-us/dotnet/api/System.Boolean 'System.Boolean')
<a name='BTD_Mod_Helper.BloonsTD6Mod.AddTowerToGame(Assets.Scripts.Models.Towers.TowerModel,Assets.Scripts.Models.TowerSets.TowerDetailsModel)'></a>

## BloonsTD6Mod.AddTowerToGame(TowerModel, TowerDetailsModel) Method

Adds a TowerModel to the official list of TowerModels being used by the game
<br/>
Equivalent to calling Game.instance.model.AddTowerToGame(...)

```csharp
public static void AddTowerToGame(Assets.Scripts.Models.Towers.TowerModel newTowerModel, Assets.Scripts.Models.TowerSets.TowerDetailsModel towerDetailsModel=null);
```
#### Parameters

<a name='BTD_Mod_Helper.BloonsTD6Mod.AddTowerToGame(Assets.Scripts.Models.Towers.TowerModel,Assets.Scripts.Models.TowerSets.TowerDetailsModel).newTowerModel'></a>

`newTowerModel` [Assets.Scripts.Models.Towers.TowerModel](https://docs.microsoft.com/en-us/dotnet/api/Assets.Scripts.Models.Towers.TowerModel 'Assets.Scripts.Models.Towers.TowerModel')
The new tower model

<a name='BTD_Mod_Helper.BloonsTD6Mod.AddTowerToGame(Assets.Scripts.Models.Towers.TowerModel,Assets.Scripts.Models.TowerSets.TowerDetailsModel).towerDetailsModel'></a>

`towerDetailsModel` [Assets.Scripts.Models.TowerSets.TowerDetailsModel](https://docs.microsoft.com/en-us/dotnet/api/Assets.Scripts.Models.TowerSets.TowerDetailsModel 'Assets.Scripts.Models.TowerSets.TowerDetailsModel')
A TowerDetailsModel to go with it, if it'll be in the shop

<a name='BTD_Mod_Helper.BloonsTD6Mod.OnAbilityCast(Assets.Scripts.Simulation.Towers.Behaviors.Abilities.Ability)'></a>

## BloonsTD6Mod.OnAbilityCast(Ability) Method
Expand Down
2 changes: 1 addition & 1 deletion Shared/Api/Data/ModHelperData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public void SetVersion(string version)

public static void LoadAll()
{
foreach (var melonMod in ModHelper.Melons)
foreach (var melonMod in ModHelper.Melons.OrderBy(mod => mod.Priority))
{
try
{
Expand Down
32 changes: 0 additions & 32 deletions Shared/Api/Helpers/MelonLoaderChecker.cs

This file was deleted.

13 changes: 10 additions & 3 deletions Shared/BloonsMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,12 @@ public sealed override void OnInitializeMelon()
modHelperPatchAll = true;
}

OnApplicationStart();
OnInitialize();
}

/// <inheritdoc />
public sealed override void OnLoaderInitialized()
public sealed override void OnEarlyInitializeMelon()
{
if (modHelperPatchAll)
{
Expand Down Expand Up @@ -187,12 +188,18 @@ public sealed override void OnLoaderInitialized()
}
}

OnApplicationStart();
OnEarlyInitialize();
}

/// <inheritdoc cref="OnLoaderInitialized"/>
/// <inheritdoc cref="OnInitializeMelon"/>
public new virtual void OnApplicationStart()
{

}

/// <inheritdoc cref="OnEarlyInitializeMelon"/>
public virtual void OnEarlyInitialize()
{
}

/// <inheritdoc cref="OnInitializeMelon"/>
Expand Down
2 changes: 1 addition & 1 deletion Shared/ModHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static class ModHelper
#region ModHelperData for the Mod Helper

internal const string Name = "BloonsTD6 Mod Helper";
internal const string Version = "3.0.1";
internal const string Version = "3.0.2";
internal const string RepoOwner = "gurrenm3";
internal const string RepoName = "BTD-Mod-Helper";
internal const string Description = "A powerful and easy to use API for modding BTD6. Also the mod that is allowing all of this UI to happen right now :P";
Expand Down
1 change: 0 additions & 1 deletion Shared/Shared Project.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
<Compile Include="$(MSBuildThisFileDirectory)Api\Helpers\ActionHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Api\Helpers\CostHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Api\Helpers\Guard.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Api\Helpers\MelonLoaderChecker.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Api\Helpers\ModHelperFiles.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Api\Helpers\ProcessHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Api\Helpers\ResourceHandler.cs" />
Expand Down

0 comments on commit 4e208aa

Please sign in to comment.