-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa8b7a3
commit 6fbd6fb
Showing
21 changed files
with
222 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Il2CppAssets.Scripts; | ||
using Il2CppAssets.Scripts.Utils; | ||
namespace BTD_Mod_Helper.Api.Helpers; | ||
|
||
/// <summary> | ||
/// Properties and methods for helping change in game time / time related values | ||
/// </summary> | ||
public static class TimeHelper | ||
{ | ||
/// <summary> | ||
/// Override for <see cref="TimeManager.FastForwardTimeScale"/> | ||
/// </summary> | ||
public static double OverrideFastForwardTimeScale { get; set; } = Constants.fastForwardTimeScaleMultiplier; | ||
|
||
/// <summary> | ||
/// Override for <see cref="TimeManager.MaxSimulationStepsPerUpdate"/> | ||
/// </summary> | ||
public static double OverrideMaxSimulationStepsPerUpdate { get; set; } = Constants.maxSimulationStepsPerUpdate; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
BloonsTD6 Mod Helper/Patches/Resources/ResourceLoader_OnSpriteLoaded.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using BTD_Mod_Helper.Api; | ||
using BTD_Mod_Helper.Api.Internal; | ||
using Il2CppNinjaKiwi.Common.ResourceUtils; | ||
using UnityEngine; | ||
using UnityEngine.AddressableAssets; | ||
using UnityEngine.ResourceManagement.AsyncOperations; | ||
|
||
namespace BTD_Mod_Helper.Patches.Resources; | ||
|
||
/// <summary> | ||
/// Fixes a weird bug that cropped up with v45 where custom sprites wouldn't always finish loading | ||
/// <br/> | ||
/// TODO investigate this further, fix initial flash of white square? | ||
/// </summary> | ||
[HarmonyPatch(typeof(ResourceLoader), nameof(ResourceLoader.OnSpriteLoaded))] | ||
internal static class ResourceLoader_OnSpriteLoaded | ||
{ | ||
[HarmonyPrefix] | ||
internal static void Prefix(ref AsyncOperationHandle<Sprite> handle) | ||
{ | ||
if (handle.Succeeded() && | ||
handle.Result == null && | ||
handle.LocationName.Contains(ModContent.HijackSpriteAtlas + ".spriteatlasv2")) | ||
{ | ||
var name = handle.LocationName | ||
[(handle.LocationName.IndexOf("[", StringComparison.Ordinal) + 1)..^1]; | ||
if (ResourceHandler.GetSprite(name) is Sprite spr) | ||
{ | ||
handle = Addressables.Instance.ResourceManager.CreateCompletedOperation(spr, ""); | ||
} | ||
} | ||
|
||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
BloonsTD6 Mod Helper/Patches/Sim/TimeManager_FastForwardTimeScale.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using BTD_Mod_Helper.Api.Helpers; | ||
using Il2CppAssets.Scripts; | ||
using Il2CppAssets.Scripts.Utils; | ||
namespace BTD_Mod_Helper.Patches.Sim; | ||
|
||
[HarmonyPatch(typeof(TimeManager), nameof(TimeManager.FastForwardTimeScale), MethodType.Getter)] | ||
internal static class TimeManager_FastForwardTimeScale | ||
{ | ||
[HarmonyPrefix] | ||
internal static bool Prefix(ref double __result) | ||
{ | ||
__result = TimeHelper.OverrideFastForwardTimeScale; | ||
return false; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
BloonsTD6 Mod Helper/Patches/Sim/TimeManager_MaxSimulationStepsPerUpdate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using BTD_Mod_Helper.Api.Helpers; | ||
using Il2CppAssets.Scripts.Utils; | ||
namespace BTD_Mod_Helper.Patches.Sim; | ||
|
||
[HarmonyPatch(typeof(TimeManager), nameof(TimeManager.MaxSimulationStepsPerUpdate), MethodType.Getter)] | ||
internal static class TimeManager_MaxSimulationStepsPerUpdate | ||
{ | ||
[HarmonyPrefix] | ||
internal static bool Prefix(ref double __result) | ||
{ | ||
__result = TimeHelper.OverrideMaxSimulationStepsPerUpdate; | ||
return false; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using BTD_Mod_Helper.Api.Helpers; | ||
using Il2CppAssets.Scripts.Unity.Menu; | ||
using Il2CppAssets.Scripts.Unity.UI_New.InGame; | ||
using Il2CppAssets.Scripts.Utils; | ||
using UnityEngine; | ||
namespace BTD_Mod_Helper.Patches.Sim; | ||
|
||
/// <summary> | ||
/// Sadly the FastForwardTimeScale call seems to have been inlined for 45.0 | ||
/// </summary> | ||
[HarmonyPatch(typeof(TimeManager), nameof(TimeManager.Update))] | ||
internal static class TimeManager_Update | ||
{ | ||
[HarmonyPostfix] | ||
internal static void Postfix() | ||
{ | ||
if (InGame.Bridge == null || InGame.instance == null) return; | ||
|
||
var paused = InGame.instance.IsCoop | ||
? TimeManager.coopPaused | ||
: !InGame.instance._reviewMapMode && TimeManager.gamePaused; | ||
|
||
var baseTime = paused ? 0 : 1; | ||
var fastForwardScale = TimeManager.FastForwardActive && !TimeManager.inBetweenRounds | ||
? TimeHelper.OverrideFastForwardTimeScale | ||
: 1; | ||
|
||
var time = baseTime * fastForwardScale * TimeManager.replayTimeScaleMultiplier; | ||
|
||
Time.timeScale = Mathf.Clamp((float) time, 0, 100); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#### [BloonsTD6 Mod Helper](README.md 'README') | ||
### [BTD_Mod_Helper.Api.Helpers](README.md#BTD_Mod_Helper.Api.Helpers 'BTD_Mod_Helper.Api.Helpers') | ||
|
||
## TimeHelper Class | ||
|
||
Properties and methods for helping change in game time / time related values | ||
|
||
```csharp | ||
public static class TimeHelper | ||
``` | ||
|
||
Inheritance [System.Object](https://docs.microsoft.com/en-us/dotnet/api/System.Object 'System.Object') 🡒 TimeHelper | ||
### Properties | ||
|
||
<a name='BTD_Mod_Helper.Api.Helpers.TimeHelper.OverrideFastForwardTimeScale'></a> | ||
|
||
## TimeHelper.OverrideFastForwardTimeScale Property | ||
|
||
Override for [Il2CppAssets.Scripts.Utils.TimeManager.FastForwardTimeScale](https://docs.microsoft.com/en-us/dotnet/api/Il2CppAssets.Scripts.Utils.TimeManager.FastForwardTimeScale 'Il2CppAssets.Scripts.Utils.TimeManager.FastForwardTimeScale') | ||
```csharp | ||
public static double OverrideFastForwardTimeScale { get; set; } | ||
``` | ||
|
||
#### Property Value | ||
[System.Double](https://docs.microsoft.com/en-us/dotnet/api/System.Double 'System.Double') | ||
<a name='BTD_Mod_Helper.Api.Helpers.TimeHelper.OverrideMaxSimulationStepsPerUpdate'></a> | ||
|
||
## TimeHelper.OverrideMaxSimulationStepsPerUpdate Property | ||
|
||
Override for [Il2CppAssets.Scripts.Utils.TimeManager.MaxSimulationStepsPerUpdate](https://docs.microsoft.com/en-us/dotnet/api/Il2CppAssets.Scripts.Utils.TimeManager.MaxSimulationStepsPerUpdate 'Il2CppAssets.Scripts.Utils.TimeManager.MaxSimulationStepsPerUpdate') | ||
```csharp | ||
public static double OverrideMaxSimulationStepsPerUpdate { get; set; } | ||
``` | ||
|
||
#### Property Value | ||
[System.Double](https://docs.microsoft.com/en-us/dotnet/api/System.Double 'System.Double') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.