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 Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.Kirshoo.MovableChessboard")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+5fae42a6a02cd071ea4c9a7e1a907fc20696a9c0")]
[assembly: AssemblyProduct("com.github.Kirshoo.MovableChessboard")]
[assembly: AssemblyTitle("MovableChessboard")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace MovableChessboard
{
internal class BoardManager
{
private static BoardManager? _instance;
public static bool lockAfterLoad;
private bool _isLocked;
private GameObject _board;
private Vector3 _position;
private Quaternion _rotation;
private Vector3 _scale;
public const string AIRPORT_SCENE_NAME = "Airport";
public static BoardManager Instance
{
get
{
if (_instance == null)
{
_instance = new BoardManager();
}
return _instance;
}
}
public static event Action OnBoardLoaded;
public static event Action<Vector3> OnBoardChangedPosition;
public static event Action<Quaternion> OnBoardChangedRotation;
public static event Action<Vector3> OnBoardChangedScale;
public GameObject? FindChessBoard()
{
GameObject val = GameObject.Find("Chess");
if ((Object)(object)val == (Object)null)
{
Plugin.Log.LogError((object)"Unable to find a chess set in current scene.");
return null;
}
Transform val2 = val.transform.Find("Plane");
if ((Object)(object)val2 == (Object)null)
{
Plugin.Log.LogError((object)"Unable to find chessboard game object.");
return null;
}
return ((Component)val2).gameObject;
}
public bool TryFindChessBoard(out GameObject chessboard)
{
chessboard = FindChessBoard();
if ((Object)(object)chessboard == (Object)null)
{
return false;
}
return true;
}
private void LoadChessboard()
{
//IL_002d: 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_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
if (!TryFindChessBoard(out GameObject chessboard))
{
Plugin.Log.LogError((object)"Unable to load the chess board. See previous errors for more detail.");
return;
}
_board = chessboard;
_position = _board.transform.position;
_rotation = _board.transform.rotation;
_scale = _board.transform.localScale;
BoardManager.OnBoardLoaded?.Invoke();
if (lockAfterLoad)
{
_isLocked = true;
}
}
public void Init()
{
SubscribeToSceneChanges();
}
private void SubscribeToSceneChanges()
{
SceneManager.activeSceneChanged += UpdateBoardPosition;
}
public bool ToggleChessboardLock()
{
_isLocked = !_isLocked;
return _isLocked;
}
private void UpdateBoardPosition(Scene _, Scene next)
{
if (((Scene)(ref next)).name != "Airport")
{
return;
}
Plugin.Log.LogDebug((object)"Updating references to objects...");
LoadChessboard();
if (PhotonNetwork.IsMasterClient && !((Object)(object)_board == (Object)null))
{
Plugin.Log.LogDebug((object)"Updating the view on the chessboard.");
PhotonView val = _board.GetComponent<PhotonView>();
if ((Object)(object)val == (Object)null)
{
val = _board.AddComponent<PhotonView>();
}
if (!PhotonNetwork.AllocateViewID(val))
{
Plugin.Log.LogError((object)"Failed to allocate viewID!");
return;
}
val.RPC("SetViewOnChessboard", (RpcTarget)4, new object[1] { val.ViewID });
}
}
[PunRPC]
public void SetViewOnChessboard(int viewID)
{
if (!TryFindChessBoard(out GameObject chessboard))
{
Plugin.Log.LogError((object)$"Error setting viewID {viewID} to a chessboard.");
return;
}
PhotonView val = chessboard.GetComponent<PhotonView>();
if ((Object)(object)val == (Object)null)
{
val = chessboard.AddComponent<PhotonView>();
}
if (val.ViewID != viewID)
{
val.ViewID = viewID;
}
}
public void MoveChessboard(Vector3 newPosition)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: 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_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
if (!_isLocked && PhotonNetwork.IsMasterClient)
{
_position = newPosition;
_board.transform.position = _position;
Plugin.Log.LogDebug((object)$"New board position: {newPosition}");
BoardManager.OnBoardChangedPosition?.Invoke(newPosition);
}
}
public void RotateChessboard(Quaternion newRotation)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: 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_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
if (!_isLocked && PhotonNetwork.IsMasterClient)
{
_rotation = newRotation;
_board.transform.rotation = _rotation;
Plugin.Log.LogDebug((object)$"New board rotation: {newRotation}");
BoardManager.OnBoardChangedRotation?.Invoke(newRotation);
}
}
public void ScaleChessboard(Vector3 newScale)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: 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_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
if (!_isLocked && PhotonNetwork.IsMasterClient)
{
_scale = newScale;
_board.transform.localScale = _scale;
Plugin.Log.LogDebug((object)$"New board scale: {newScale}");
BoardManager.OnBoardChangedScale?.Invoke(newScale);
}
}
public GameObject GetBoard()
{
return _board;
}
public Vector3 GetBoardPosition()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return _position;
}
public Quaternion GetBoardRotation()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return _rotation;
}
public Vector3 GetBoardScale()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return _scale;
}
public bool IsLocked()
{
return _isLocked;
}
}
[BepInPlugin("com.github.Kirshoo.MovableChessboard", "MovableChessboard", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
private static ConfigEntry<KeyCode> ModifierKey;
private static ConfigEntry<KeyCode> LockToggle;
private static ConfigEntry<KeyCode> MoveRight;
private static ConfigEntry<KeyCode> MoveUp;
private static ConfigEntry<KeyCode> MoveForward;
private static ConfigEntry<KeyCode> RotateClockwise;
private static ConfigEntry<KeyCode> ScaleUp;
private static ConfigEntry<float> Amount;
private static ConfigEntry<KeyCode> MagnitudeUp;
private static ConfigEntry<KeyCode> DebugInfo;
private bool showDebug;
public const string Id = "com.github.Kirshoo.MovableChessboard";
internal static ManualLogSource Log { get; private set; }
public static string Name => "MovableChessboard";
public static string Version => "1.1.0";
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
BindConfig();
Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
}
private void BindConfig()
{
Amount = ((BaseUnityPlugin)this).Config.Bind<float>("Controls", "Magnitude", 1f, "Scalar, to determine how much change to apply.\r\nCan be any number, but negatives will result in inversed controls.");
MagnitudeUp = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "IncreaseMagnitude", (KeyCode)289, "Will increase Magnitude of chess movement controls.\r\nIf pressed in conjunction with ModifierKey, will decrease Magnitude instead.");
ModifierKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "ModifierKey", (KeyCode)304, "When holding, will inverse chessboard movement controls.\r\nIf before button moved the board to the right, now it would go left instead.");
LockToggle = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "ChessboardLockToggle", (KeyCode)288, "In combination with ModifierKey - will lock chessboard in place, ignoring any attempts to move it around with controls.\r\nThis is a toggle, so you can press combination again to unlock the board.");
MoveRight = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "ChessboardRight", (KeyCode)283, "Will move the chessboard towards global right (east).\r\nIf pressed in conjunction with ModifierKey, will move chessboard towards global left (west) instead.");
MoveUp = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "ChessboardUp", (KeyCode)284, "Will move the chessboard up.\r\nIf pressed in conjunction with ModifierKey, will move chessboard down instead.");
MoveForward = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "ChessboardForward", (KeyCode)285, "Will move the chessboard towards global forward (north).\r\nIf pressed in conjunction with ModifierKey, will move chessboard towards global backward (south) instead.");
RotateClockwise = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "ChessboardRotateClockwise", (KeyCode)286, "Will rotate the chessboard a few degrees clockwise (when looking top-down) around its center.\r\nIf pressed in conjunction with ModifierKey, will rotate chessboard a few degrees counter-clockwise instead.");
ScaleUp = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "ChessboardScaleUp", (KeyCode)287, "Will scale the chessboard up a few units.\r\nIf pressed in conjunction with ModifierKey, will scale chessboard a few units down instead.");
DebugInfo = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "DebugInfo", (KeyCode)290, "Will toggle on screen information about position of the board.");
}
private void CreateLabelWithBorder(Rect rect, string text, int borderSize = 1)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Expected O, but got Unknown
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
GUIStyle val = new GUIStyle();
val.normal.textColor = Color.black;
for (int i = -borderSize; i <= borderSize; i++)
{
for (int j = -borderSize; j <= borderSize; j++)
{
if (i != 0 || j != 0)
{
GUI.Label(new Rect(((Rect)(ref rect)).x + (float)i, ((Rect)(ref rect)).y + (float)j, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height), text, val);
}
}
}
val.normal.textColor = Color.white;
GUI.Label(rect, text, val);
}
private void CreateDebugLabels()
{
//IL_0015: 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_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
CreateLabelWithBorder(new Rect(40f, 20f, 500f, 20f), $"Position: {BoardManager.Instance.GetBoardPosition()}");
Rect rect = new Rect(40f, 40f, 500f, 20f);
Quaternion boardRotation = BoardManager.Instance.GetBoardRotation();
CreateLabelWithBorder(rect, $"Rotation: {((Quaternion)(ref boardRotation)).eulerAngles}");
CreateLabelWithBorder(new Rect(40f, 60f, 500f, 20f), $"Scale: {BoardManager.Instance.GetBoardScale()}");
CreateLabelWithBorder(new Rect(40f, 80f, 500f, 20f), $"Magnitude: {Amount.Value:F4}");
CreateLabelWithBorder(new Rect(40f, 100f, 500f, 20f), "LockStatus: " + (BoardManager.Instance.IsLocked() ? "active" : "inactive"));
}
private void OnGUI()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
if (!(((Scene)(ref activeScene)).name != "Airport") && showDebug)
{
CreateDebugLabels();
}
}
private void Update()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0269: 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_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_0293: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Unknown result type (might be due to invalid IL or missing references)
//IL_029f: 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_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_0255: Unknown result type (might be due to invalid IL or missing references)
//IL_025a: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_0314: Unknown result type (might be due to invalid IL or missing references)
//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name != "Airport")
{
return;
}
if (Input.GetKeyDown(MagnitudeUp.Value))
{
float num = 0.1f;
if (Input.GetKey(ModifierKey.Value))
{
ConfigEntry<float> amount = Amount;
amount.Value -= num;
return;
}
ConfigEntry<float> amount2 = Amount;
amount2.Value += num;
}
if (Input.GetKeyDown(MoveRight.Value))
{
Vector3 val = new Vector3(1f, 0f, 0f) * Amount.Value;
if (Input.GetKey(ModifierKey.Value))
{
BoardManager.Instance.MoveChessboard(BoardManager.Instance.GetBoardPosition() - val);
return;
}
BoardManager.Instance.MoveChessboard(BoardManager.Instance.GetBoardPosition() + val);
}
if (Input.GetKeyDown(MoveForward.Value))
{
Vector3 val2 = new Vector3(0f, 0f, 1f) * Amount.Value;
if (Input.GetKey(ModifierKey.Value))
{
BoardManager.Instance.MoveChessboard(BoardManager.Instance.GetBoardPosition() - val2);
return;
}
BoardManager.Instance.MoveChessboard(BoardManager.Instance.GetBoardPosition() + val2);
}
if (Input.GetKeyDown(MoveUp.Value))
{
Vector3 val3 = new Vector3(0f, 1f, 0f) * Amount.Value;
if (Input.GetKey(ModifierKey.Value))
{
BoardManager.Instance.MoveChessboard(BoardManager.Instance.GetBoardPosition() - val3);
return;
}
BoardManager.Instance.MoveChessboard(BoardManager.Instance.GetBoardPosition() + val3);
}
if (Input.GetKeyDown(RotateClockwise.Value))
{
if (Input.GetKey(ModifierKey.Value))
{
BoardManager.Instance.RotateChessboard(BoardManager.Instance.GetBoardRotation() * Quaternion.AngleAxis(5f * Amount.Value, Vector3.forward));
return;
}
BoardManager.Instance.RotateChessboard(BoardManager.Instance.GetBoardRotation() * Quaternion.AngleAxis(-5f * Amount.Value, Vector3.forward));
}
if (Input.GetKeyDown(ScaleUp.Value))
{
Vector3 val4 = new Vector3(0.2f, 0.2f, 0.2f) * Amount.Value;
if (Input.GetKey(ModifierKey.Value))
{
BoardManager.Instance.ScaleChessboard(BoardManager.Instance.GetBoardScale() - val4);
return;
}
BoardManager.Instance.ScaleChessboard(BoardManager.Instance.GetBoardScale() + val4);
}
if (Input.GetKeyDown(LockToggle.Value) && Input.GetKey(ModifierKey.Value))
{
BoardManager.Instance.ToggleChessboardLock();
}
if (Input.GetKeyDown(DebugInfo.Value))
{
showDebug = !showDebug;
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}