using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.SceneManagement;
using plog;
[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("BobotUtils")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c41d222e43e01bf595121464463426a582532adb")]
[assembly: AssemblyProduct("BobotUtils")]
[assembly: AssemblyTitle("BobotUtils")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace BobotUtils
{
[HarmonyPatch]
[BepInPlugin("bobot.BobotUtils", "Bobot Utils", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private const string GUID = "bobot.BobotUtils";
private static Harmony _harmony;
public static readonly Logger Log = new Logger("BobotUtils");
private void Start()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
SceneManager.sceneLoaded += TextureReplacer.SceneLoaded;
_harmony = new Harmony("bobot.BobotUtils");
_harmony.PatchAll();
}
}
public class TextureReplacer
{
public static List<ReplacementInfo> textureToReplace = new List<ReplacementInfo>();
public static void SceneLoaded(Scene scene, LoadSceneMode mode)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
foreach (ReplacementInfo item in textureToReplace)
{
Material val = Addressables.LoadAssetAsync<Material>((object)item.materialPath).WaitForCompletion();
if (!Object.op_Implicit((Object)(object)val))
{
continue;
}
foreach (KeyValuePair<string, Texture2D> item2 in item.propertyTexToChange)
{
val.SetTexture(item2.Key, (Texture)(object)item2.Value);
}
foreach (KeyValuePair<string, Color> item3 in item.propertyColourToChange)
{
val.SetColor(item3.Key, item3.Value);
}
foreach (KeyValuePair<string, float> item4 in item.propertyFloatToChange)
{
val.SetFloat(item4.Key, item4.Value);
}
}
}
}
public struct ReplacementInfo
{
public readonly string materialPath;
public readonly Dictionary<string, Texture2D> propertyTexToChange;
public readonly Dictionary<string, Color> propertyColourToChange;
public readonly Dictionary<string, float> propertyFloatToChange;
public ReplacementInfo(string materialPath, (string, Texture2D)[]? textures = null, (string, Color)[]? colours = null, (string, float)[]? floats = null)
{
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
this.materialPath = materialPath;
propertyTexToChange = new Dictionary<string, Texture2D>();
propertyColourToChange = new Dictionary<string, Color>();
propertyFloatToChange = new Dictionary<string, float>();
if (textures != null)
{
for (int i = 0; i < textures.Length; i++)
{
(string, Texture2D) tuple = textures[i];
propertyTexToChange.Add(tuple.Item1, tuple.Item2);
}
}
if (colours != null)
{
for (int j = 0; j < colours.Length; j++)
{
(string, Color) tuple2 = colours[j];
propertyColourToChange.Add(tuple2.Item1, tuple2.Item2);
}
}
if (floats != null)
{
for (int k = 0; k < floats.Length; k++)
{
(string, float) tuple3 = floats[k];
propertyFloatToChange.Add(tuple3.Item1, tuple3.Item2);
}
}
}
}
}