using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("moneybag-protect")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("moneybag-protect")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("bd193c0c-6f85-4926-a22c-803a2fb18f8a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MoneybagProtect;
[BepInPlugin("mod.moneybagprotect", "Moneybag Protect", "1.1.0")]
public class MoneybagProtect : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("mod.moneybagprotect");
public ConfigEntry<float> CustomProtectTimer;
public ConfigEntry<string> CustomProtectColor;
public static MoneybagProtect Instance { get; private set; }
public static ManualLogSource LogInstance { get; private set; }
private void Awake()
{
Instance = this;
LogInstance = ((BaseUnityPlugin)this).Logger;
CustomProtectTimer = ((BaseUnityPlugin)this).Config.Bind<float>("settings", "protection", 10f, "amount of time tax refund moneybag is protected after spawn");
CustomProtectColor = ((BaseUnityPlugin)this).Config.Bind<string>("settings", "protectionColor", "cyan", "color of the protection effect. possible values: red, green, cyan, yellow, magenta, white");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Moneybag Protect 1.1.0 loaded");
harmony.PatchAll();
}
public Color GetColorFromConfig()
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
return (Color)(CustomProtectColor.Value.ToLower() switch
{
"red" => Color.red,
"green" => Color.green,
"cyan" => Color.cyan,
"yellow" => Color.yellow,
"magenta" => Color.magenta,
"white" => Color.white,
_ => Color.cyan,
});
}
}
[HarmonyPatch(typeof(SurplusValuable), "Start")]
public class SurplusValuableStartPatch
{
private static void Postfix(SurplusValuable __instance)
{
FieldInfo field = typeof(SurplusValuable).GetField("indestructibleTimer", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
float value = MoneybagProtect.Instance.CustomProtectTimer.Value;
field.SetValue(__instance, value);
float num = (float)field.GetValue(__instance);
MoneybagProtect.LogInstance.LogInfo((object)$"Moneybag Protect: indestructibleTimer changed to {num} for SurplusValuable instance");
}
else
{
MoneybagProtect.LogInstance.LogError((object)"Moneybag Protect: Couldn't locate 'indestructibleTimer' in SurplusValuable");
}
}
}
[HarmonyPatch(typeof(SurplusValuable), "Update")]
public class SurplusValuableUpdatePatch
{
private static void Postfix(SurplusValuable __instance)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
FieldInfo field = typeof(SurplusValuable).GetField("indestructibleTimer", BindingFlags.Instance | BindingFlags.NonPublic);
if (field == null)
{
MoneybagProtect.LogInstance.LogError((object)"Moneybag Protect: can't locate 'indestructibleTimer' in SurplusValuable");
return;
}
float num = (float)field.GetValue(__instance);
Renderer componentInChildren = ((Component)__instance).GetComponentInChildren<Renderer>();
if ((Object)(object)componentInChildren == (Object)null)
{
MoneybagProtect.LogInstance.LogError((object)"Moneybag Protect: can't locate Renderer component in SurplusValuable or its children");
}
else if (num > 0f)
{
Color colorFromConfig = MoneybagProtect.Instance.GetColorFromConfig();
componentInChildren.material.SetColor("_EmissionColor", colorFromConfig * Mathf.LinearToGammaSpace(1f));
componentInChildren.material.EnableKeyword("_EMISSION");
}
else
{
componentInChildren.material.DisableKeyword("_EMISSION");
}
}
}