using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Bounce.Singletons;
using HarmonyLib;
using ModdingTales;
using Unity.Mathematics;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SmoothMovePlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Nth Dimension")]
[assembly: AssemblyProduct("SmoothMovePlugin")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("SmoothMovePlugin")]
[assembly: ComVisible(false)]
[assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LordAshes;
[BepInPlugin("org.lordashes.plugins.smoothmove", "Smooth Move Plugin", "1.0.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class SmoothMovePlugin : BaseUnityPlugin
{
public static class Utility
{
public static bool isBoardLoaded()
{
return SimpleSingletonBehaviour<CameraController>.HasInstance && SingletonStateMBehaviour<BoardSessionManager, State<BoardSessionManager>>.HasInstance && !BoardSessionManager.IsLoading;
}
public static float ParseFloat(string value)
{
return float.Parse(value, CultureInfo.InvariantCulture);
}
public static GameObject FindInHierarchy(GameObject start, string seekName)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, seekName, null, single: true, ref results, ref done);
return (results.Count > 0) ? results.ElementAt(0) : null;
}
public static GameObject FindInHierarchyViaPartialName(GameObject start, string seekName)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, seekName, null, single: true, ref results, ref done, partial: true);
return (results.Count > 0) ? results.ElementAt(0) : null;
}
public static GameObject[] FindAllInHierarchy(GameObject start, string seekName)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, seekName, null, single: false, ref results, ref done);
return results.ToArray();
}
public static GameObject[] FindAllInHierarchyViaPartialName(GameObject start, string seekName)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, seekName, null, single: false, ref results, ref done, partial: true);
return results.ToArray();
}
public static GameObject FindWithComponentInHierarchy(GameObject start, string seekType)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, null, seekType, single: true, ref results, ref done);
return (results.Count > 0) ? results.ElementAt(0) : null;
}
public static GameObject[] FindAllWithComponentInHierarchy<T>(GameObject start, string seekType)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, null, seekType, single: false, ref results, ref done);
return results.ToArray();
}
public static void Traverse(Transform root, string seekName, string seekType, bool single, ref List<GameObject> results, ref bool done, bool partial = false)
{
try
{
if ((seekName == null || seekName == ((Object)((Component)root).gameObject).name || (partial && ((Object)((Component)root).gameObject).name.Contains(seekName))) && (seekType == null || (Object)(object)((Component)root).GetComponent(seekType) != (Object)null))
{
LoggingPlugin.LogTrace("Matched '" + ((Object)((Component)root).gameObject).name + "'");
results.Add(((Component)root).gameObject);
if (single)
{
done = true;
return;
}
}
foreach (Transform item in ExtensionMethods.Children(root))
{
if (!done)
{
Traverse(item, seekName, seekType, single, ref results, ref done, partial);
}
}
}
catch
{
}
}
public static object LookUp(in Dictionary<string, object> dictionary, string key)
{
foreach (KeyValuePair<string, object> item in dictionary)
{
if (item.Key.ToUpper() == key.ToUpper())
{
return item.Value;
}
}
return null;
}
public static void PostOnMainPage(BaseUnityPlugin plugin)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
string text = "Lord Ashes" + ("Lord Ashes".ToUpper().EndsWith("S") ? "'" : "'s");
ModdingUtils.Initialize(plugin, new ManualLogSource("Smooth Move Plugin"), text, false);
}
}
private enum Operation
{
moveForward = 1,
moveBackward,
rotateLeft,
rotateRight,
strafeLeft,
strafeRight
}
public const string Name = "Smooth Move Plugin";
public const string Guid = "org.lordashes.plugins.smoothmove";
public const string Version = "1.0.0.0";
public const string Author = "Lord Ashes";
public static SmoothMovePlugin _self;
private KeyboardShortcut moveForward;
private KeyboardShortcut moveBackward;
private KeyboardShortcut rotateLeft;
private KeyboardShortcut rotateRight;
private KeyboardShortcut strafeLeft;
private KeyboardShortcut strafeRight;
private float advanceSpeed = 0.1f;
private float rotateSpeed = 1f;
private void Awake()
{
//IL_001e: 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_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: 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_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Expected O, but got Unknown
_self = this;
LoggingPlugin.SetLogLevel(((BaseUnityPlugin)this).Config.Bind<DiagnosticLevel>("Settings", "Diagnostic Level", (DiagnosticLevel)3, (ConfigDescription)null).Value);
string? assemblyQualifiedName = ((object)this).GetType().AssemblyQualifiedName;
DiagnosticLevel logLevel = LoggingPlugin.GetLogLevel();
Debug.Log((object)(assemblyQualifiedName + ": Active. (Diagnostic Mode = " + ((object)(DiagnosticLevel)(ref logLevel)).ToString() + ")"));
moveForward = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Move Forward", new KeyboardShortcut((KeyCode)117, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null).Value;
moveBackward = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Move Backward", new KeyboardShortcut((KeyCode)110, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null).Value;
rotateLeft = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Rotate Left", new KeyboardShortcut((KeyCode)104, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null).Value;
rotateRight = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Rotate Right", new KeyboardShortcut((KeyCode)106, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null).Value;
strafeLeft = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Strafe Left", new KeyboardShortcut((KeyCode)104, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null).Value;
strafeRight = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Strafe Right", new KeyboardShortcut((KeyCode)106, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null).Value;
advanceSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Move Speed", 1f, (ConfigDescription)null).Value;
rotateSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Rotate Speed", 1f, (ConfigDescription)null).Value;
Harmony val = new Harmony("org.lordashes.plugins.smoothmove");
val.PatchAll();
Utility.PostOnMainPage((BaseUnityPlugin)(object)this);
}
private void Update()
{
if (((KeyboardShortcut)(ref moveForward)).IsPressed())
{
ProcessOperation(Operation.moveForward);
}
if (((KeyboardShortcut)(ref moveBackward)).IsPressed())
{
ProcessOperation(Operation.moveBackward);
}
if (((KeyboardShortcut)(ref rotateLeft)).IsPressed())
{
ProcessOperation(Operation.rotateLeft);
}
if (((KeyboardShortcut)(ref rotateRight)).IsPressed())
{
ProcessOperation(Operation.rotateRight);
}
if (((KeyboardShortcut)(ref strafeLeft)).IsPressed())
{
ProcessOperation(Operation.strafeLeft);
}
if (((KeyboardShortcut)(ref strafeRight)).IsPressed())
{
ProcessOperation(Operation.strafeRight);
}
}
private void ProcessOperation(Operation request)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: 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_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_0318: Unknown result type (might be due to invalid IL or missing references)
//IL_031d: Unknown result type (might be due to invalid IL or missing references)
//IL_034f: Unknown result type (might be due to invalid IL or missing references)
//IL_0354: Unknown result type (might be due to invalid IL or missing references)
//IL_0355: Unknown result type (might be due to invalid IL or missing references)
//IL_035a: Unknown result type (might be due to invalid IL or missing references)
//IL_0367: Unknown result type (might be due to invalid IL or missing references)
//IL_0377: Unknown result type (might be due to invalid IL or missing references)
//IL_038e: Unknown result type (might be due to invalid IL or missing references)
//IL_0398: Unknown result type (might be due to invalid IL or missing references)
//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
//IL_0401: Unknown result type (might be due to invalid IL or missing references)
//IL_0406: Unknown result type (might be due to invalid IL or missing references)
//IL_0407: Unknown result type (might be due to invalid IL or missing references)
//IL_040c: Unknown result type (might be due to invalid IL or missing references)
//IL_0419: Unknown result type (might be due to invalid IL or missing references)
//IL_0429: Unknown result type (might be due to invalid IL or missing references)
//IL_0440: Unknown result type (might be due to invalid IL or missing references)
//IL_044a: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_0240: Unknown result type (might be due to invalid IL or missing references)
//IL_0245: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
CreatureBoardAsset val = null;
CreaturePresenter.TryGetAsset(LocalClient.SelectedCreatureId, ref val);
if ((Object)(object)val != (Object)null)
{
Quaternion rotation = ((MovableBoardAsset)val).Rotator.rotation;
Vector3 val2 = Quaternion.Euler(0f, ((Quaternion)(ref rotation)).eulerAngles.y, 0f) * new Vector3(-1f, 0f, 0f);
CreatureGuid creatureId;
switch (request)
{
case Operation.moveForward:
{
string[] obj6 = new string[5] { "Moving Asset ", val.Name, " (", null, null };
creatureId = val.CreatureId;
obj6[3] = ((object)(CreatureGuid)(ref creatureId)).ToString();
obj6[4] = ") Forward (Facing Direction)";
LoggingPlugin.LogDebug(string.Concat(obj6));
CreaturePresenter.TeleportCreature(val, float3.op_Implicit(((Component)val).gameObject.transform.position + val2 * advanceSpeed / 10f));
break;
}
case Operation.moveBackward:
{
string[] obj5 = new string[5] { "Moving Asset ", val.Name, " (", null, null };
creatureId = val.CreatureId;
obj5[3] = ((object)(CreatureGuid)(ref creatureId)).ToString();
obj5[4] = ") Backwards (Opposite To Facing Direction)";
LoggingPlugin.LogDebug(string.Concat(obj5));
val2 = Quaternion.Euler(0f, 180f, 0f) * val2;
CreaturePresenter.TeleportCreature(val, float3.op_Implicit(((Component)val).gameObject.transform.position + val2 * advanceSpeed / 10f));
break;
}
case Operation.strafeLeft:
{
string[] obj4 = new string[5] { "Moving Asset ", val.Name, " (", null, null };
creatureId = val.CreatureId;
obj4[3] = ((object)(CreatureGuid)(ref creatureId)).ToString();
obj4[4] = ") Left With Regards To Facing Direction";
LoggingPlugin.LogDebug(string.Concat(obj4));
val2 = Quaternion.Euler(0f, -90f, 0f) * val2;
CreaturePresenter.TeleportCreature(val, float3.op_Implicit(((Component)val).gameObject.transform.position + val2 * advanceSpeed / 10f));
break;
}
case Operation.strafeRight:
{
string[] obj3 = new string[5] { "Moving Asset ", val.Name, " (", null, null };
creatureId = val.CreatureId;
obj3[3] = ((object)(CreatureGuid)(ref creatureId)).ToString();
obj3[4] = ") Right With Regards To Facing Direction";
LoggingPlugin.LogDebug(string.Concat(obj3));
val2 = Quaternion.Euler(0f, 90f, 0f) * val2;
CreaturePresenter.TeleportCreature(val, float3.op_Implicit(((Component)val).gameObject.transform.position + val2 * advanceSpeed / 10f));
break;
}
case Operation.rotateLeft:
{
string[] obj2 = new string[5] { "Rotating Asset ", val.Name, " (", null, null };
creatureId = val.CreatureId;
obj2[3] = ((object)(CreatureGuid)(ref creatureId)).ToString();
obj2[4] = ") Left With Regards To Facing Direction";
LoggingPlugin.LogDebug(string.Concat(obj2));
val2 = Quaternion.Euler(0f, -1f, 0f) * val2;
((MovableBoardAsset)val).Rotator.eulerAngles = new Vector3(((MovableBoardAsset)val).Rotator.eulerAngles.x, ((MovableBoardAsset)val).Rotator.eulerAngles.y - rotateSpeed, ((MovableBoardAsset)val).Rotator.eulerAngles.z);
break;
}
case Operation.rotateRight:
{
string[] obj = new string[5] { "Rotating Asset ", val.Name, " (", null, null };
creatureId = val.CreatureId;
obj[3] = ((object)(CreatureGuid)(ref creatureId)).ToString();
obj[4] = ") Right With Regards To Facing Direction";
LoggingPlugin.LogDebug(string.Concat(obj));
val2 = Quaternion.Euler(0f, 1f, 0f) * val2;
((MovableBoardAsset)val).Rotator.eulerAngles = new Vector3(((MovableBoardAsset)val).Rotator.eulerAngles.x, ((MovableBoardAsset)val).Rotator.eulerAngles.y + rotateSpeed, ((MovableBoardAsset)val).Rotator.eulerAngles.z);
break;
}
}
}
}
}