using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mirror;
using UnityEngine;
[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("com.CRotater.3924")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+c549a4b0e8b21c220bb5a931ac0438f80741ecb8")]
[assembly: AssemblyProduct("CRotater")]
[assembly: AssemblyTitle("Character Rotater")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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.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]
[Microsoft.CodeAnalysis.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;
}
}
[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 Character_Rotater
{
public static class CommandParser
{
public static void HandleCommand(string[] args)
{
if (args.Length < 1)
{
PrintHelp();
return;
}
switch (args[0].ToLower())
{
case "toggle":
Main.rotatorEnabled = !Main.rotatorEnabled;
LogChatMessage("Rotator " + (Main.rotatorEnabled ? "Enabled" : "Disabled") + ".");
break;
case "mode":
HandleModeCommand(args);
break;
case "set":
HandleSetCommand(args);
break;
case "reset":
Main.ResetSettingsToDefault();
LogChatMessage("Rotation values have been reset to their defaults.");
break;
default:
PrintHelp();
break;
}
}
private static void HandleModeCommand(string[] args)
{
if (args.Length > 1 && (args[1].ToLower() == "static" || args[1].ToLower() == "rotating"))
{
Main.isStatic = args[1].ToLower() == "static";
LogChatMessage("Rotator mode set to " + (Main.isStatic ? "Static" : "Rotating") + ".");
}
else
{
LogChatMessage("Usage: /rotator mode <static|rotating>");
}
}
private static void HandleSetCommand(string[] args)
{
if (args.Length < 2)
{
LogChatMessage("Usage: /rotator set <axis><value> OR /rotator set <x> <y> <z>");
return;
}
if (args.Length > 3 && TryParseValue(args[1], Main.rotationValueX, out var result) && TryParseValue(args[2], Main.rotationValueY, out var result2) && TryParseValue(args[3], Main.rotationValueZ, out var result3))
{
Main.rotationValueX = result;
Main.rotationValueY = result2;
Main.rotationValueZ = result3;
LogChatMessage($"Rotation set to X:{result:F0}, Y:{result2:F0}, Z:{result3:F0}.");
return;
}
bool flag = false;
for (int i = 1; i < args.Length; i++)
{
string text = args[i].ToLower();
char c = text[0];
string text2 = text.Substring(1);
if (string.IsNullOrEmpty(text2) && i + 1 < args.Length)
{
text2 = args[i + 1];
i++;
}
switch (c)
{
case 'x':
{
if (TryParseValue(text2, Main.rotationValueX, out var result5))
{
Main.rotationValueX = result5;
flag = true;
}
break;
}
case 'y':
{
if (TryParseValue(text2, Main.rotationValueY, out var result6))
{
Main.rotationValueY = result6;
flag = true;
}
break;
}
case 'z':
{
if (TryParseValue(text2, Main.rotationValueZ, out var result4))
{
Main.rotationValueZ = result4;
flag = true;
}
break;
}
}
}
if (flag)
{
LogChatMessage($"Current rotation: X:{Main.rotationValueX:F0}, Y:{Main.rotationValueY:F0}, Z:{Main.rotationValueZ:F0}.");
}
else
{
LogChatMessage("Invalid format. Use `/rotator set x<val> y<val>...`");
}
}
private static bool TryParseValue(string input, float currentValue, out float result)
{
input = input.Trim();
result = currentValue;
if (string.IsNullOrEmpty(input))
{
return false;
}
float result4;
if (input.StartsWith("+"))
{
if (float.TryParse(input.Substring(1), out var result2))
{
result = Mathf.Clamp(currentValue + result2, -360f, 360f);
return true;
}
}
else if (input.StartsWith("-"))
{
if (float.TryParse(input, out var result3))
{
result = Mathf.Clamp(currentValue + result3, -360f, 360f);
return true;
}
}
else if (float.TryParse(input, out result4))
{
result = Mathf.Clamp(result4, -360f, 360f);
return true;
}
return false;
}
private static void LogChatMessage(string message)
{
Player mainPlayer = Player._mainPlayer;
if (mainPlayer != null)
{
ChatBehaviour chatBehaviour = mainPlayer._chatBehaviour;
if (chatBehaviour != null)
{
chatBehaviour.New_ChatMessage("<color=#00FFFF>[Rotator]</color> " + message);
}
}
}
private static void PrintHelp()
{
LogChatMessage("--- Character Rotator Help ---");
LogChatMessage("/rotator toggle - Toggles the rotator on/off.");
LogChatMessage("/rotator mode <static|rotating>");
LogChatMessage("/rotator set <x/y/z><value> - e.g., /rot set y90 x+10");
LogChatMessage("/rotator reset - Resets all rotation values to default.");
}
}
[BepInPlugin("com.s0apy.CRotater", "CRotater", "1.0.2")]
public class Main : BaseUnityPlugin
{
internal static ManualLogSource Log;
private readonly Harmony harmony = new Harmony("com.s0apy.CRotater");
internal static ConfigEntry<bool> configRotatorEnabled;
internal static ConfigEntry<bool> configIsStatic;
internal static ConfigEntry<float> configRotationValueX;
internal static ConfigEntry<float> configRotationValueY;
internal static ConfigEntry<float> configRotationValueZ;
internal static ConfigEntry<KeyCode> configToggleMenuKey;
private bool showMenu = false;
private Rect windowRect = new Rect(20f, 20f, 300f, 250f);
private readonly int windowId = new Random().Next(1000, 9999);
public static bool rotatorEnabled
{
get
{
return configRotatorEnabled.Value;
}
set
{
configRotatorEnabled.Value = value;
}
}
public static bool isStatic
{
get
{
return configIsStatic.Value;
}
set
{
configIsStatic.Value = value;
}
}
public static float rotationValueX
{
get
{
return configRotationValueX.Value;
}
set
{
configRotationValueX.Value = value;
}
}
public static float rotationValueY
{
get
{
return configRotationValueY.Value;
}
set
{
configRotationValueY.Value = value;
}
}
public static float rotationValueZ
{
get
{
return configRotationValueZ.Value;
}
set
{
configRotationValueZ.Value = value;
}
}
private void Awake()
{
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
configRotatorEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("1. General", "Enabled", false, "Enable or disable the character rotator.");
configIsStatic = ((BaseUnityPlugin)this).Config.Bind<bool>("1. General", "StaticMode", false, "If true, sets a static rotation angle. If false, character spins continuously.");
configToggleMenuKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("2. Controls", "ToggleMenuKey", (KeyCode)277, "The key to press to show/hide the rotator menu.");
configRotationValueX = ((BaseUnityPlugin)this).Config.Bind<float>("3. Rotation", "ValueX", 0f, "Rotation Speed (if not static) or Angle (if static) on the X-axis.");
configRotationValueY = ((BaseUnityPlugin)this).Config.Bind<float>("3. Rotation", "ValueY", 100f, "Rotation Speed (if not static) or Angle (if static) on the Y-axis.");
configRotationValueZ = ((BaseUnityPlugin)this).Config.Bind<float>("3. Rotation", "ValueZ", 0f, "Rotation Speed (if not static) or Angle (if static) on the Z-axis.");
harmony.PatchAll();
Log.LogInfo((object)string.Format("[{0} v{1}] has loaded! Press '{2}' to open the menu.", "CRotater", "1.0.2", configToggleMenuKey.Value));
}
public static void ResetSettingsToDefault()
{
isStatic = (bool)((ConfigEntryBase)configIsStatic).DefaultValue;
rotationValueX = (float)((ConfigEntryBase)configRotationValueX).DefaultValue;
rotationValueY = (float)((ConfigEntryBase)configRotationValueY).DefaultValue;
rotationValueZ = (float)((ConfigEntryBase)configRotationValueZ).DefaultValue;
}
private void Update()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(configToggleMenuKey.Value))
{
showMenu = !showMenu;
}
}
private void OnGUI()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
if (showMenu)
{
windowRect = GUI.Window(windowId, windowRect, new WindowFunction(DrawWindow), "Character Rotator");
}
}
private void DrawWindow(int id)
{
rotatorEnabled = GUILayout.Toggle(rotatorEnabled, "Enable Rotator", Array.Empty<GUILayoutOption>());
isStatic = GUILayout.Toggle(isStatic, "Static Mode", Array.Empty<GUILayoutOption>());
GUILayout.Space(10f);
string arg = (isStatic ? "Angle" : "Speed");
GUILayout.Label($"X-Axis {arg}: {rotationValueX:F0}", Array.Empty<GUILayoutOption>());
rotationValueX = GUILayout.HorizontalSlider(rotationValueX, -360f, 360f, Array.Empty<GUILayoutOption>());
GUILayout.Label($"Y-Axis {arg}: {rotationValueY:F0}", Array.Empty<GUILayoutOption>());
rotationValueY = GUILayout.HorizontalSlider(rotationValueY, -360f, 360f, Array.Empty<GUILayoutOption>());
GUILayout.Label($"Z-Axis {arg}: {rotationValueZ:F0}", Array.Empty<GUILayoutOption>());
rotationValueZ = GUILayout.HorizontalSlider(rotationValueZ, -360f, 360f, Array.Empty<GUILayoutOption>());
GUILayout.Space(10f);
if (GUILayout.Button("Reset to Defaults", Array.Empty<GUILayoutOption>()))
{
ResetSettingsToDefault();
}
GUI.DragWindow();
}
}
internal static class ModInfo
{
public const string GUID = "com.s0apy.CRotater";
public const string NAME = "CRotater";
public const string VERSION = "1.0.2";
}
}
namespace Character_Rotater.Patches
{
[HarmonyPatch(typeof(ChatBehaviour), "Cmd_SendChatMessage")]
internal class ChatPatch
{
[HarmonyPrefix]
public static bool InterceptChatCommands(string _message)
{
string text = _message.Trim();
if (text.StartsWith("/rotator") || text.StartsWith("/rot"))
{
string[] array = text.Split(' ');
string[] array2 = new string[array.Length - 1];
for (int i = 1; i < array.Length; i++)
{
array2[i - 1] = array[i];
}
CommandParser.HandleCommand(array2);
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Player))]
internal class RotationPatch
{
[HarmonyPostfix]
[HarmonyPatch("Update")]
public static void OverrideRotation(Player __instance)
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance == (Object)(object)Player._mainPlayer && Main.rotatorEnabled)
{
Quaternion rotation = ((!Main.isStatic) ? Quaternion.Euler(Time.time * Main.rotationValueX, Time.time * Main.rotationValueY, Time.time * Main.rotationValueZ) : Quaternion.Euler(Main.rotationValueX, Main.rotationValueY, Main.rotationValueZ));
NetworkTransformUnreliable netTransform = __instance._netTransform;
if ((Object)(object)netTransform != (Object)null)
{
((Component)netTransform).transform.rotation = rotation;
}
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}