Decompiled source of TmbolPack v1.3.0
BepInEx/plugins/custom-AISlopTextureReplacer/AISlopTextureReplacer.dll
Decompiled 5 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("AISlopTextureReplacer")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("AISlopTextureReplacer")] [assembly: AssemblyTitle("AISlopTextureReplacer")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Plguin { public static class MyPluginInfo { public const string PLUGIN_GUID = "AISlopTextureReplacer"; public const string PLUGIN_NAME = "AISlopTextureReplacer"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace TextureReplacer { [BepInPlugin("com.tmbolslop.texturereplacer", "TMBOL AI Slop Texture Replacer", "1.3.0")] public class Plugin : BaseUnityPlugin { private static ManualLogSource Log; private static readonly Dictionary<string, Texture2D> ReplacementTextures = new Dictionary<string, Texture2D>(StringComparer.OrdinalIgnoreCase); private static readonly HashSet<int> InspectedIds = new HashSet<int>(); private void Awake() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; LoadTexturesFromDisk(); Harmony val = new Harmony("com.tmbolslop.texturereplacer"); val.Patch((MethodBase)AccessTools.Method(typeof(GameObject), "SetActive", new Type[1] { typeof(bool) }, (Type[])null), new HarmonyMethod(typeof(Plugin), "OnSetActive_Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(RawImage), "OnEnable", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "RawImage_OnEnable", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(Image), "OnEnable", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "Image_OnEnable", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Runtime Texture Replacer initialized."); } private void LoadTexturesFromDisk() { //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); string text = Path.Combine(directoryName, "Textures"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); Log.LogInfo((object)("Created folder: " + text)); return; } Log.LogInfo((object)("Loading textures from: " + text)); IEnumerable<string> enumerable = from f in Directory.EnumerateFiles(text, "*.*", SearchOption.AllDirectories) where f.EndsWith(".png", StringComparison.OrdinalIgnoreCase) || f.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase) select f; foreach (string item in enumerable) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(item); try { byte[] array = File.ReadAllBytes(item); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (ImageConversion.LoadImage(val, array)) { ReplacementTextures[fileNameWithoutExtension] = val; Log.LogInfo((object)("Loaded texture: '" + fileNameWithoutExtension + "'")); } } catch (Exception ex) { Log.LogError((object)("Error loading '" + fileNameWithoutExtension + "': " + ex.Message)); } } } private static void OnSetActive_Prefix(GameObject __instance, bool value) { //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) if (!value || (Object)(object)__instance == (Object)null) { return; } int instanceID = ((Object)__instance).GetInstanceID(); if (!InspectedIds.Add(instanceID)) { return; } try { Renderer[] componentsInChildren = __instance.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { Material[] materials = val.materials; foreach (Material val2 in materials) { if ((Object)(object)val2 == (Object)null) { continue; } string[] texturePropertyNames = val2.GetTexturePropertyNames(); foreach (string text in texturePropertyNames) { Texture texture = val2.GetTexture(text); Texture2D val3 = (Texture2D)(object)((texture is Texture2D) ? texture : null); if (val3 != null) { Texture2D value3; if (ReplacementTextures.TryGetValue(((Object)val3).name, out var value2)) { val2.SetTexture(text, (Texture)(object)value2); Log.LogWarning((object)("[3D] '" + ((Object)val3).name + "'→'" + text + "' on '" + ((Object)val).name + "'")); } else if (ReplacementTextures.TryGetValue(text, out value3)) { val2.SetTexture(text, (Texture)(object)value3); Log.LogWarning((object)("[3D] replaced by prop '" + text + "' on '" + ((Object)val).name + "'")); } } } } } } catch (Exception arg) { Log.LogError((object)$"3D replace error: {arg}"); } try { RawImage[] componentsInChildren2 = __instance.GetComponentsInChildren<RawImage>(true); foreach (RawImage val4 in componentsInChildren2) { Texture texture2 = val4.texture; Texture2D val5 = (Texture2D)(object)((texture2 is Texture2D) ? texture2 : null); if (val5 != null && ReplacementTextures.TryGetValue(((Object)val5).name, out var value4)) { val4.texture = (Texture)(object)value4; Log.LogWarning((object)("[UI RawImage] '" + ((Object)val5).name + "' swapped on '" + ((Object)val4).name + "'")); } } } catch (Exception arg2) { Log.LogError((object)$"RawImage replace error: {arg2}"); } try { Image[] componentsInChildren3 = __instance.GetComponentsInChildren<Image>(true); foreach (Image val6 in componentsInChildren3) { Sprite sprite = val6.sprite; if ((Object)(object)sprite != (Object)null && ReplacementTextures.TryGetValue(((Object)sprite).name, out var value5)) { Sprite sprite2 = Sprite.Create(value5, new Rect(0f, 0f, (float)((Texture)value5).width, (float)((Texture)value5).height), new Vector2(0.5f, 0.5f), sprite.pixelsPerUnit); val6.sprite = sprite2; Log.LogWarning((object)("[UI Image] '" + ((Object)sprite).name + "' swapped on '" + ((Object)val6).name + "'")); } } } catch (Exception arg3) { Log.LogError((object)$"Image replace error: {arg3}"); } } public static void RawImage_OnEnable(RawImage __instance) { Texture texture = __instance.texture; Texture2D val = (Texture2D)(object)((texture is Texture2D) ? texture : null); if (val != null && ReplacementTextures.TryGetValue(((Object)val).name, out var value)) { __instance.texture = (Texture)(object)value; Log.LogWarning((object)("[UI RawImage] OnEnable swapped '" + ((Object)val).name + "'")); } } public static void Image_OnEnable(Image __instance) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) Sprite sprite = __instance.sprite; if ((Object)(object)sprite != (Object)null && ReplacementTextures.TryGetValue(((Object)sprite).name, out var value)) { Sprite sprite2 = Sprite.Create(value, new Rect(0f, 0f, (float)((Texture)value).width, (float)((Texture)value).height), new Vector2(0.5f, 0.5f), sprite.pixelsPerUnit); __instance.sprite = sprite2; Log.LogWarning((object)("[UI Image] OnEnable swapped '" + ((Object)sprite).name + "'")); } } } }
BepInEx/plugins/custom-SummitRoster/ProgressMap.dll
Decompiled 5 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using TMPro; using UnityEngine; using UnityEngine.TextCore; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ProgressMap")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Altimeter")] [assembly: AssemblyTitle("ProgressMap")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Plguin { public static class MyPluginInfo { public const string PLUGIN_GUID = "ProgressMap"; public const string PLUGIN_NAME = "Altimeter"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace ProgressMap { [BepInPlugin("com.jsapp.SummitRoster", "SummitRoster", "1.1.0")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Harmony.CreateAndPatchAll(typeof(Plugin), (string)null); Logger.LogInfo((object)"Plugin com.jsapp.SummitRoster is loaded!"); } [HarmonyPatch(typeof(RunManager), "StartRun")] [HarmonyPostfix] private static void Post_LoadIsland() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown Logger.LogInfo((object)"Patch running ProgressMap"); GameObject val = new GameObject("ProgressMap", new Type[1] { typeof(ProgressMap) }); } } public class ProgressMap : MonoBehaviourPunCallbacks { private GameObject overlay; private TMP_FontAsset mainFont; private Dictionary<Character, GameObject> characterLabels = new Dictionary<Character, GameObject>(); private const float totalMountainHeight = 1920f; private const float barHeightPixels = 400f; private const float leftOffset = 30f; private const float bottomOffset = 250f; private void Awake() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Expected O, but got Unknown //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)overlay != (Object)null) { Object.DestroyImmediate((Object)(object)overlay); } overlay = new GameObject("ProgressMap"); Canvas val = overlay.AddComponent<Canvas>(); val.renderMode = (RenderMode)0; CanvasScaler val2 = overlay.AddComponent<CanvasScaler>(); val2.uiScaleMode = (ScaleMode)1; val2.referenceResolution = new Vector2(1920f, 1080f); if ((Object)(object)mainFont == (Object)null) { TMP_FontAsset[] source = Resources.FindObjectsOfTypeAll<TMP_FontAsset>(); mainFont = ((IEnumerable<TMP_FontAsset>)source).FirstOrDefault((Func<TMP_FontAsset, bool>)delegate(TMP_FontAsset a) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) FaceInfo faceInfo = ((TMP_Asset)a).faceInfo; return ((FaceInfo)(ref faceInfo)).familyName == "Daruma Drop One"; }); } GameObject val3 = new GameObject("PeakText", new Type[2] { typeof(RectTransform), typeof(TextMeshProUGUI) }); val3.transform.SetParent(overlay.transform, false); TextMeshProUGUI component = val3.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component).font = mainFont; ((TMP_Text)component).text = "TMBOL"; ((Graphic)component).color = new Color(1f, 1f, 1f, 0.3f); RectTransform component2 = val3.GetComponent<RectTransform>(); component2.sizeDelta = ((TMP_Text)component).GetPreferredValues(); Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(0f, 0.5f); component2.anchorMax = val4; component2.anchorMin = val4; component2.pivot = new Vector2(0.5f, 0f); float num = 30f; component2.anchoredPosition = new Vector2(30f + num, 450f); GameObject val5 = new GameObject("AltitudeBar"); val5.transform.SetParent(overlay.transform, false); RectTransform val6 = val5.AddComponent<RectTransform>(); ((Vector2)(ref val4))..ctor(0f, 0.5f); val6.anchorMax = val4; val6.anchorMin = val4; val6.sizeDelta = new Vector2(10f, 400f); val6.anchoredPosition = new Vector2(30f, 250f); Image val7 = val5.AddComponent<Image>(); ((Graphic)val7).color = new Color(0.75f, 0.75f, 0.69f, 0.3f); } private void Start() { characterLabels.Clear(); foreach (Character allCharacter in Character.AllCharacters) { AddCharacter(allCharacter); } } private void LateUpdate() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<Character, GameObject> characterLabel in characterLabels) { characterLabel.Deconstruct(out var key, out var value); Character val = key; GameObject val2 = value; float heightInMeters = val.refs.stats.heightInMeters; string nickName = val.refs.view.Owner.NickName; TextMeshProUGUI componentInChildren = val2.GetComponentInChildren<TextMeshProUGUI>(); ((TMP_Text)componentInChildren).text = $"{nickName} {heightInMeters}m"; ((Component)componentInChildren).gameObject.GetComponent<RectTransform>().sizeDelta = ((TMP_Text)componentInChildren).GetPreferredValues() * 1.1f; ((Graphic)componentInChildren).color = val.refs.customization.PlayerColor; ((Graphic)val2.GetComponentInChildren<Image>()).color = val.refs.customization.PlayerColor; float num = Mathf.InverseLerp(0f, 1920f, heightInMeters); float num2 = Mathf.Lerp(-200f, 200f, num); RectTransform component = val2.GetComponent<RectTransform>(); component.anchoredPosition = new Vector2(80f, 250f + num2); } } public override void OnPlayerEnteredRoom(Player newPlayer) { Debug.Log((object)"Adding player to map"); ((MonoBehaviour)this).StartCoroutine(WaitAndAddPlayer(newPlayer)); } private IEnumerator WaitAndAddPlayer(Player newPlayer) { yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)PlayerHandler.GetPlayerCharacter(newPlayer) != (Object)null)); ProgressMap map = GameObject.Find("ProgressMap").GetComponent<ProgressMap>(); map.AddCharacter(PlayerHandler.GetPlayerCharacter(newPlayer)); } public override void OnPlayerLeftRoom(Player leavingPlayer) { Debug.Log((object)"Removing player from map"); ProgressMap component = GameObject.Find("ProgressMap").GetComponent<ProgressMap>(); component.RemoveCharacter(PlayerHandler.GetPlayerCharacter(leavingPlayer)); } public void AddCharacter(Character character) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) Debug.Log((object)$"Adding character {character}"); if (!characterLabels.ContainsKey(character)) { string nickName = character.refs.view.Owner.NickName; GameObject val = new GameObject("Label_" + nickName); val.transform.SetParent(overlay.transform, false); RectTransform val2 = val.AddComponent<RectTransform>(); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0f, 0.5f); val2.anchorMax = val3; val2.anchorMin = val3; GameObject val4 = new GameObject("Marker"); val4.transform.SetParent(val.transform, false); Image val5 = val4.AddComponent<Image>(); ((Graphic)val5).color = character.refs.customization.PlayerColor; RectTransform component = val4.GetComponent<RectTransform>(); ((Vector2)(ref val3))..ctor(0f, 0.5f); component.anchorMax = val3; component.anchorMin = val3; component.pivot = new Vector2(0.5f, 1f); component.sizeDelta = new Vector2(10f, 5f); GameObject val6 = new GameObject("Text"); val6.transform.SetParent(val.transform, false); TextMeshProUGUI val7 = val6.AddComponent<TextMeshProUGUI>(); ((Graphic)val7).color = character.refs.customization.PlayerColor; ((TMP_Text)val7).font = mainFont; ((TMP_Text)val7).fontSize = 18f; RectTransform component2 = val6.GetComponent<RectTransform>(); ((Vector2)(ref val3))..ctor(0f, 0.5f); component2.anchorMax = val3; component2.anchorMin = val3; component2.pivot = new Vector2(0f, 0.5f); component2.anchoredPosition = new Vector2(20f, 0f); characterLabels[character] = val; } } public void RemoveCharacter(Character character) { GameObject val = characterLabels[character]; Object.DestroyImmediate((Object)(object)val); characterLabels.Remove(character); } } }