using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.NET.Common;
using BepInExResoniteShim;
using Elements.Core;
using FrooxEngine;
using HarmonyLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]
[assembly: AssemblyCompany("LeCloutPanda")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+f818798ec2671aa76290618bd9e07f17c23bafaf")]
[assembly: AssemblyProduct("Fucked Up Math")]
[assembly: AssemblyTitle("FuckedUpMath")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/LeCloutPanda/FuckedUpMath")]
[assembly: AssemblyVersion("1.0.1.0")]
[module: RefSafetyRules(11)]
namespace FuckedUpMath;
[ResonitePlugin("dev.lecloutpanda.fuckedupmath", "Fucked Up Math", "1.0.1", "LeCloutPanda", "https://github.com/LeCloutPanda/FuckedUpMath")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Patch : BasePlugin
{
public enum MathFunction
{
cos,
sin,
ceil,
floor,
tan
}
[HarmonyPatch(typeof(MathX))]
private class TheFuckening
{
[HarmonyPostfix]
[HarmonyPatch("Cos", new global::System.Type[] { typeof(float) })]
private static float CosPatch(float d, ref float __result)
{
if (!ShouldRun())
{
return __result;
}
return FuckedMath(d, COS_REPLACEMENT.Value);
}
[HarmonyPostfix]
[HarmonyPatch("Sin", new global::System.Type[] { typeof(float) })]
private static float SinPatch(float a, ref float __result)
{
if (!ShouldRun())
{
return __result;
}
return FuckedMath(a, SIN_REPLACEMENT.Value);
}
[HarmonyPostfix]
[HarmonyPatch("Ceil", new global::System.Type[] { typeof(float) })]
private static float CeilPatch(float a, ref float __result)
{
if (!ShouldRun())
{
return __result;
}
return FuckedMath(a, CEIL_REPLACEMENT.Value);
}
[HarmonyPostfix]
[HarmonyPatch("Floor", new global::System.Type[] { typeof(float) })]
private static float FloorPatch(float d, ref float __result)
{
if (!ShouldRun())
{
return __result;
}
return FuckedMath(d, FLOOR_REPLACEMENT.Value);
}
[HarmonyPostfix]
[HarmonyPatch("Tan", new global::System.Type[] { typeof(float) })]
private static float TanPatch(float a, ref float __result)
{
if (!ShouldRun())
{
return __result;
}
return FuckedMath(a, TAN_REPLACEMENT.Value);
}
}
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static EventHandler <>9__9_0;
internal void <Load>b__9_0(object? sender, EventArgs e)
{
if (RANDOMIZE.Value)
{
ENABLED.Value = false;
COS_REPLACEMENT.Value = GetRandomMathFunction();
SIN_REPLACEMENT.Value = GetRandomMathFunction();
CEIL_REPLACEMENT.Value = GetRandomMathFunction();
FLOOR_REPLACEMENT.Value = GetRandomMathFunction();
TAN_REPLACEMENT.Value = GetRandomMathFunction();
RANDOMIZE.Value = false;
}
}
}
private static ConfigEntry<bool> ENABLED;
private static ConfigEntry<MathFunction> COS_REPLACEMENT;
private static ConfigEntry<MathFunction> SIN_REPLACEMENT;
private static ConfigEntry<MathFunction> CEIL_REPLACEMENT;
private static ConfigEntry<MathFunction> FLOOR_REPLACEMENT;
private static ConfigEntry<MathFunction> TAN_REPLACEMENT;
private static ConfigEntry<bool> RANDOMIZE;
private static readonly Random random = new Random();
public override void Load()
{
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Expected O, but got Unknown
ENABLED = ((BasePlugin)this).Config.Bind<bool>("General", "Enabled", false, "Toggle the mod on/off");
COS_REPLACEMENT = ((BasePlugin)this).Config.Bind<MathFunction>("Replacements", "Cos Function", MathFunction.cos, "Replacement for the Cos function");
SIN_REPLACEMENT = ((BasePlugin)this).Config.Bind<MathFunction>("Replacements", "Sin Function", MathFunction.sin, "Replacement for the Sin function");
CEIL_REPLACEMENT = ((BasePlugin)this).Config.Bind<MathFunction>("Replacements", "Ceil Function", MathFunction.ceil, "Replacement for the Ceil function");
FLOOR_REPLACEMENT = ((BasePlugin)this).Config.Bind<MathFunction>("Replacements", "Floor Function", MathFunction.floor, "Replacement for the Floor function");
TAN_REPLACEMENT = ((BasePlugin)this).Config.Bind<MathFunction>("Replacements", "Tan Function", MathFunction.tan, "Replacement for the Tan function");
RANDOMIZE = ((BasePlugin)this).Config.Bind<bool>("General", "Randomize", false, "Randomize math function replacements");
ENABLED.Value = false;
ConfigEntry<bool> rANDOMIZE = RANDOMIZE;
object obj = <>c.<>9__9_0;
if (obj == null)
{
EventHandler val = delegate
{
if (RANDOMIZE.Value)
{
ENABLED.Value = false;
COS_REPLACEMENT.Value = GetRandomMathFunction();
SIN_REPLACEMENT.Value = GetRandomMathFunction();
CEIL_REPLACEMENT.Value = GetRandomMathFunction();
FLOOR_REPLACEMENT.Value = GetRandomMathFunction();
TAN_REPLACEMENT.Value = GetRandomMathFunction();
RANDOMIZE.Value = false;
}
};
<>c.<>9__9_0 = val;
obj = (object)val;
}
rANDOMIZE.SettingChanged += (EventHandler)obj;
((BasePlugin)this).HarmonyInstance.PatchAll();
}
private static bool ShouldRun()
{
if (Engine.Current.WorldManager.FocusedWorld == null)
{
return false;
}
if (!Engine.Current.WorldManager.FocusedWorld.IsAuthority)
{
return false;
}
if (!ENABLED.Value)
{
return false;
}
return true;
}
private static float FuckedMath(float value, MathFunction function)
{
return function switch
{
MathFunction.cos => MathF.Cos(value),
MathFunction.sin => MathF.Sin(value),
MathFunction.ceil => MathF.Ceiling(value),
MathFunction.floor => MathF.Floor(value),
MathFunction.tan => MathF.Tan(value),
_ => value,
};
}
public static MathFunction GetRandomMathFunction()
{
global::System.Array values = global::System.Enum.GetValues(typeof(MathFunction));
return (MathFunction)values.GetValue(random.Next(values.Length));
}
}
public static class PluginMetadata
{
public const string GUID = "dev.lecloutpanda.fuckedupmath";
public const string NAME = "Fucked Up Math";
public const string VERSION = "1.0.1";
public const string AUTHORS = "LeCloutPanda";
public const string REPOSITORY_URL = "https://github.com/LeCloutPanda/FuckedUpMath";
}