Skip to content

Commit

Permalink
Further fix ApplyOutLineShader
Browse files Browse the repository at this point in the history
  • Loading branch information
doombubbles committed Aug 13, 2024
1 parent e97563b commit 4bcd0ef
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static class Il2CppSystemDictionaryExt
/// </summary>
public static List<TValue> GetValues<TKey, TValue>(this Dictionary<TKey, TValue> keyValuePairs)
{
return keyValuePairs._entries.Select(entry => entry.value).ToIl2CppList();
return keyValuePairs._entries.Select(entry => entry.value).Take(keyValuePairs.Count).ToIl2CppList();
}


Expand Down
18 changes: 16 additions & 2 deletions BloonsTD6 Mod Helper/Extensions/UnityExtensions/RendererExt.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Il2CppAssets.Scripts.Models.GenericBehaviors;
using Il2CppAssets.Scripts.Models.Towers;
using Il2CppAssets.Scripts.Unity;
using Il2CppAssets.Scripts.Unity.Display;
using Il2CppNinjaKiwi.Common.ResourceUtils;
using UnityEngine;
using Object = UnityEngine.Object;

Expand Down Expand Up @@ -126,8 +131,17 @@ public static int GetBoneIndex(this SkinnedMeshRenderer skinnedMeshRenderer, str
/// </summary>
public static void ApplyOutlineShader(this Renderer renderer)
{
var shader = Resources.FindObjectsOfTypeAll<Shader>().First(shader => shader.name == DefaultShader);
renderer.material.shader = shader;
var shader = Resources.FindObjectsOfTypeAll<Shader>().FirstOrDefault(shader => shader.name == DefaultShader);
if (shader == null)
{
var dummyDisplay = Game.instance.model.GetTowerWithName(TowerType.DartMonkey).display;
Game.instance.GetDisplayFactory().FindAndSetupPrototypeAsync(dummyDisplay, DisplayCategory.Default,
new Action<UnityDisplayNode>(udn => renderer.material.shader = udn.GetRenderers().First().material.shader));
}
else
{
renderer.material.shader = shader;
}
renderer.gameObject.layer = LayerMask.NameToLayer("Towers");
}
}
5 changes: 2 additions & 3 deletions BloonsTD6 Mod Helper/LATEST.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
- An error indicator will now show on the main menu Mods Button if any mods have load errors
- Added a new load error for not being on MelonLoader 0.6.1
- Fixed unneeded errors on Epic about Il2CppFacepunch.Steamworks
- Re-fixed the ApplyOutlineShader method to work even if no other displays caused the Shader to already be loaded
- The space bar can now be used to skip the Title Screen animation and press the Start button
1 change: 1 addition & 0 deletions BloonsTD6 Mod Helper/MelonMain.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using BTD_Mod_Helper;
using BTD_Mod_Helper.Api;
Expand Down
2 changes: 1 addition & 1 deletion BloonsTD6 Mod Helper/btd6.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!--BloonsTD6 property gets automatically set correctly when this file is generated by the Mod Helper on startup-->
<BloonsTD6>C:\Program Files (x86)\Steam\steamapps\common\BloonsTD6</BloonsTD6>
<BloonsTD6 Condition="'$(BloonsTD6)' == ''">C:\Program Files (x86)\Steam\steamapps\common\BloonsTD6</BloonsTD6>
<Il2CppAssemblies>$(BloonsTD6)\MelonLoader\Il2CppAssemblies</Il2CppAssemblies>
<ManagedFolder>$(BloonsTD6)\MelonLoader\Managed</ManagedFolder>
<OutputFolder Condition="'$(OutputFolder)' == ''">Mods</OutputFolder>
Expand Down

0 comments on commit 4bcd0ef

Please sign in to comment.