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 UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
[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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("REPARIO")]
[assembly: AssemblyTitle("REPARIO")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 REPO.Side2D
{
[BepInPlugin("repo.side2d.movement", "REPO – Sideways 2D Movement", "1.3.0")]
public sealed class Side2DPlugin : BaseUnityPlugin
{
internal static Side2DPlugin I;
internal static Harmony Harmony;
internal static ManualLogSource Log;
internal static ConfigEntry<bool> Enabled;
internal static ConfigEntry<KeyCode> ToggleKey;
internal static ConfigEntry<float> SideYawDeg;
internal static ConfigEntry<float> ZoomFOV;
internal static ConfigEntry<bool> ForceCameraEveryFrame;
internal static ConfigEntry<float> CamOffsetX;
internal static ConfigEntry<float> CamOffsetY;
internal static ConfigEntry<float> CamOffsetZ;
internal static ConfigEntry<bool> LockFacing;
internal static ConfigEntry<float> FacingYawDeg;
internal static ConfigEntry<bool> FacingHotkeys;
internal static ConfigEntry<float> FacingStepSmall;
internal static ConfigEntry<float> FacingStepLarge;
internal static ConfigEntry<KeyCode> FacingLeftKey;
internal static ConfigEntry<KeyCode> FacingRightKey;
internal static ConfigEntry<bool> BlockEnergyDrain;
internal static ConfigEntry<bool> AutoAdvanceOnExtractComplete;
private void Awake()
{
//IL_025d: Unknown result type (might be due to invalid IL or missing references)
//IL_0267: Expected O, but got Unknown
I = this;
Log = ((BaseUnityPlugin)this).Logger;
Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable the 2D movement + camera side view.");
ToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ToggleKey", (KeyCode)288, "Toggle 2D movement at runtime (avoids Flat2D's F8).");
SideYawDeg = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "SideYawDegrees", 90f, "Camera YAW for side view. 90 = right side, -90 = left.");
ZoomFOV = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "ZoomFOV", 85f, "Field-of-view while 2D mode is ON (larger = more zoomed out).");
ForceCameraEveryFrame = ((BaseUnityPlugin)this).Config.Bind<bool>("Camera", "ForceEveryFrame", true, "Re-apply yaw/FOV/offset every frame to win script wars.");
CamOffsetX = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "OffsetX", -4f, "Camera local X offset when 2D mode is ON (side shift). Negative = left of player.");
CamOffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "OffsetY", 1.6f, "Camera local Y offset when 2D mode is ON (height).");
CamOffsetZ = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "OffsetZ", -6f, "Camera local Z offset when 2D mode is ON (back/forward). Negative pulls camera back.");
LockFacing = ((BaseUnityPlugin)this).Config.Bind<bool>("Facing", "LockFacing", true, "Lock the avatar to a fixed yaw instead of auto-flipping.");
FacingYawDeg = ((BaseUnityPlugin)this).Config.Bind<float>("Facing", "FacingYawDeg", 0f, "Absolute world yaw for the avatar when LockFacing is true.");
FacingHotkeys = ((BaseUnityPlugin)this).Config.Bind<bool>("Facing", "Hotkeys", true, "Enable in-game rotate hotkeys.");
FacingStepSmall = ((BaseUnityPlugin)this).Config.Bind<float>("Facing", "StepSmall", 5f, "Small rotation step (degrees) for facing hotkeys.");
FacingStepLarge = ((BaseUnityPlugin)this).Config.Bind<float>("Facing", "StepLarge", 30f, "Large rotation step when holding Shift (degrees).");
FacingLeftKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Facing", "RotateLeftKey", (KeyCode)91, "Hotkey: rotate avatar left by StepSmall (hold Shift for StepLarge).");
FacingRightKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Facing", "RotateRightKey", (KeyCode)93, "Hotkey: rotate avatar right by StepSmall (hold Shift for StepLarge).");
BlockEnergyDrain = ((BaseUnityPlugin)this).Config.Bind<bool>("Cheats", "BlockEnergyDrain", true, "When ON, stamina/energy will not drain while Side2D is enabled (local-only).");
AutoAdvanceOnExtractComplete = ((BaseUnityPlugin)this).Config.Bind<bool>("Flow", "AutoAdvanceOnExtractionComplete", true, "When ON, the run advances to the next level as soon as extraction completes (host/singleplayer only).");
Harmony = new Harmony("repo.side2d.movement");
Harmony.PatchAll(Assembly.GetExecutingAssembly());
Log.LogInfo((object)"[Side2D] Harmony patches applied.");
Side2DLevelGate.Init(((BaseUnityPlugin)this).Config, Log);
}
private void Update()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(ToggleKey.Value))
{
Enabled.Value = !Enabled.Value;
}
}
}
[HarmonyPatch(typeof(RenderTextureMain), "Awake")]
internal static class Patch_RenderTextureMain_Awake
{
private static void Postfix(RenderTextureMain __instance)
{
if (Object.op_Implicit((Object)(object)__instance) && !Object.op_Implicit((Object)(object)((Component)__instance).gameObject.GetComponent<Side2DDriver>()))
{
((Component)__instance).gameObject.AddComponent<Side2DDriver>();
}
}
}
public sealed class Side2DDriver : MonoBehaviour
{
private Quaternion _origLocalCamRot;
private Vector3 _origLocalCamPos;
private Vector3 _origCamPosOffset;
private bool _hasOrig;
private bool _facingInit;
private void LateUpdate()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Invalid comparison between Unknown and I4
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: 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_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_02db: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: 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_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
if (!Side2DPlugin.Enabled.Value)
{
TryRestore();
return;
}
if ((Object)(object)GameDirector.instance == (Object)null || (int)GameDirector.instance.currentState != 2)
{
TryRestore();
return;
}
PlayerController instance = PlayerController.instance;
if ((Object)(object)instance == (Object)null)
{
return;
}
GameObject val = (((Object)(object)instance.cameraGameObject != (Object)null) ? instance.cameraGameObject : instance.cameraGameObjectLocal);
GameObject val2 = (((Object)(object)instance.cameraGameObjectLocal != (Object)null) ? instance.cameraGameObjectLocal : instance.cameraGameObject);
if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
{
return;
}
Transform transform = val.transform;
Transform transform2 = val2.transform;
if (!_hasOrig)
{
_origLocalCamRot = transform.localRotation;
_origLocalCamPos = transform2.localPosition;
if ((Object)(object)CameraPosition.instance != (Object)null)
{
_origCamPosOffset = CameraPosition.instance.playerOffset;
}
_hasOrig = true;
}
if ((Object)(object)CameraAim.Instance != (Object)null)
{
CameraAim.Instance.OverrideAimStop();
}
float value = Side2DPlugin.SideYawDeg.Value;
float num = Mathf.Repeat(value, 360f);
Quaternion localRotation = Quaternion.Euler(0f, num, 0f);
transform.localRotation = localRotation;
if (Side2DPlugin.LockFacing.Value && !_facingInit && (Object)(object)instance != (Object)null)
{
ConfigEntry<float> facingYawDeg = Side2DPlugin.FacingYawDeg;
Quaternion rotation = ((Component)instance).transform.rotation;
facingYawDeg.Value = ((Quaternion)(ref rotation)).eulerAngles.y;
_facingInit = true;
}
if (Side2DPlugin.FacingHotkeys.Value)
{
float num2 = ((Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) ? Side2DPlugin.FacingStepLarge.Value : Side2DPlugin.FacingStepSmall.Value);
if (Input.GetKeyDown(Side2DPlugin.FacingLeftKey.Value))
{
Side2DPlugin.FacingYawDeg.Value = Mathf.Repeat(Side2DPlugin.FacingYawDeg.Value - num2, 360f);
}
if (Input.GetKeyDown(Side2DPlugin.FacingRightKey.Value))
{
Side2DPlugin.FacingYawDeg.Value = Mathf.Repeat(Side2DPlugin.FacingYawDeg.Value + num2, 360f);
}
}
if ((Object)(object)CameraPosition.instance != (Object)null)
{
CameraPosition.instance.playerOffset = new Vector3(Side2DPlugin.CamOffsetX.Value, Side2DPlugin.CamOffsetY.Value, Side2DPlugin.CamOffsetZ.Value);
}
transform2.localPosition = new Vector3(Side2DPlugin.CamOffsetX.Value, Side2DPlugin.CamOffsetY.Value, Side2DPlugin.CamOffsetZ.Value);
if ((Object)(object)CameraZoom.Instance != (Object)null)
{
CameraZoom.Instance.OverrideZoomSet(Side2DPlugin.ZoomFOV.Value, 0.2f, 6f, 6f, ((Component)this).gameObject, 1);
}
}
private void OnDisable()
{
TryRestore();
}
private void OnDestroy()
{
TryRestore();
}
private void TryRestore()
{
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
PlayerController instance = PlayerController.instance;
if ((Object)(object)instance == (Object)null)
{
return;
}
GameObject val = (((Object)(object)instance.cameraGameObject != (Object)null) ? instance.cameraGameObject : instance.cameraGameObjectLocal);
GameObject val2 = (((Object)(object)instance.cameraGameObjectLocal != (Object)null) ? instance.cameraGameObjectLocal : instance.cameraGameObject);
if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null) && _hasOrig)
{
val.transform.localRotation = _origLocalCamRot;
val2.transform.localPosition = _origLocalCamPos;
if ((Object)(object)CameraPosition.instance != (Object)null)
{
CameraPosition.instance.playerOffset = _origCamPosOffset;
}
}
}
}
internal static class TwoDInputGate
{
public static bool BlockInputsNow()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
if (!Side2DPlugin.Enabled.Value)
{
return false;
}
if ((Object)(object)GameDirector.instance == (Object)null || (int)GameDirector.instance.currentState != 2)
{
return false;
}
return true;
}
public static float ReadOnlyAD()
{
Keyboard current = Keyboard.current;
float num = 0f;
if (current != null)
{
if (((ButtonControl)current.aKey).isPressed)
{
num -= 1f;
}
if (((ButtonControl)current.dKey).isPressed)
{
num += 1f;
}
}
if (num > 0f)
{
return 1f;
}
if (num < 0f)
{
return -1f;
}
return 0f;
}
public static Vector2 ReadADProjected2D()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: 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_006f: 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)
float num = ReadOnlyAD();
if (Mathf.Approximately(num, 0f))
{
return Vector2.zero;
}
Vector3 right = Vector3.right;
PlayerController instance = PlayerController.instance;
if ((Object)(object)instance != (Object)null)
{
GameObject val = (((Object)(object)instance.cameraGameObject != (Object)null) ? instance.cameraGameObject : instance.cameraGameObjectLocal);
if ((Object)(object)val != (Object)null)
{
right = val.transform.right;
}
}
right.y = 0f;
if (((Vector3)(ref right)).sqrMagnitude < 0.0001f)
{
float num2 = Side2DPlugin.SideYawDeg.Value * (MathF.PI / 180f);
((Vector3)(ref right))..ctor(Mathf.Cos(num2), 0f, 0f - Mathf.Sin(num2));
}
((Vector3)(ref right)).Normalize();
return new Vector2(right.z * num, (0f - right.x) * num);
}
}
[HarmonyPatch(typeof(InputManager), "GetMovementX")]
internal static class Patch_Input_GetMovementX
{
private static void Postfix(ref float __result)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
if (TwoDInputGate.BlockInputsNow())
{
__result = TwoDInputGate.ReadADProjected2D().x;
}
}
}
[HarmonyPatch(typeof(InputManager), "GetMovementY")]
internal static class Patch_Input_GetMovementY
{
private static void Postfix(ref float __result)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
if (TwoDInputGate.BlockInputsNow())
{
__result = TwoDInputGate.ReadADProjected2D().y;
}
}
}
[HarmonyPatch(typeof(InputManager), "GetMovement")]
internal static class Patch_Input_GetMovement
{
private static void Postfix(ref Vector2 __result)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
if (TwoDInputGate.BlockInputsNow())
{
__result = TwoDInputGate.ReadADProjected2D();
}
}
}
[HarmonyPatch(typeof(InputManager), "KeyDown")]
internal static class Patch_KeyDown
{
private static void Postfix(InputKey key, ref bool __result)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Invalid comparison between Unknown and I4
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Invalid comparison between Unknown and I4
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Invalid comparison between Unknown and I4
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Invalid comparison between Unknown and I4
if (TwoDInputGate.BlockInputsNow() && (int)key != 1 && (int)key != 15 && (int)key != 6 && (int)key != 18)
{
__result = false;
}
}
}
[HarmonyPatch(typeof(InputManager), "KeyHold")]
internal static class Patch_KeyHold
{
private static void Postfix(InputKey key, ref bool __result)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Invalid comparison between Unknown and I4
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Invalid comparison between Unknown and I4
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Invalid comparison between Unknown and I4
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Invalid comparison between Unknown and I4
if (TwoDInputGate.BlockInputsNow() && (int)key != 1 && (int)key != 15 && (int)key != 6 && (int)key != 18)
{
__result = false;
}
}
}
[HarmonyPatch(typeof(InputManager), "KeyUp")]
internal static class Patch_KeyUp
{
private static void Postfix(InputKey key, ref bool __result)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Invalid comparison between Unknown and I4
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Invalid comparison between Unknown and I4
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Invalid comparison between Unknown and I4
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Invalid comparison between Unknown and I4
if (TwoDInputGate.BlockInputsNow() && (int)key != 1 && (int)key != 15 && (int)key != 6 && (int)key != 18)
{
__result = false;
}
}
}
[HarmonyPatch(typeof(InputManager), "InputToggleGet")]
internal static class Patch_InputToggleGet
{
private static void Postfix(InputKey key, ref bool __result)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Invalid comparison between Unknown and I4
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Invalid comparison between Unknown and I4
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Invalid comparison between Unknown and I4
if (TwoDInputGate.BlockInputsNow() && (int)key != 15 && (int)key != 6 && (int)key != 18)
{
__result = false;
}
}
}
[HarmonyPatch(typeof(PlayerController), "FixedUpdate")]
internal static class Patch_Player_FixedUpdate_Facing
{
private static void Prefix(PlayerController __instance, ref Quaternion __state)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
__state = default(Quaternion);
if (TwoDInputGate.BlockInputsNow() && !((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.cameraGameObject == (Object)null))
{
Transform transform = __instance.cameraGameObject.transform;
__state = transform.localRotation;
float num = (Side2DPlugin.LockFacing.Value ? Mathf.Repeat(Side2DPlugin.FacingYawDeg.Value, 360f) : Mathf.Repeat(Side2DPlugin.SideYawDeg.Value + ((TwoDInputGate.ReadOnlyAD() < 0f) ? (-90f) : 90f), 360f));
transform.localRotation = Quaternion.Euler(0f, num, 0f);
}
}
private static void Postfix(PlayerController __instance, Quaternion __state)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: 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_004b: Unknown result type (might be due to invalid IL or missing references)
if (TwoDInputGate.BlockInputsNow() && !((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.cameraGameObject == (Object)null) && __state != default(Quaternion))
{
__instance.cameraGameObject.transform.localRotation = __state;
}
}
}
[HarmonyPatch(typeof(PlayerAvatarVisuals), "Start")]
internal static class Patch_PlayerAvatarVisuals_Start_ShowLocal
{
private static void Postfix(PlayerAvatarVisuals __instance)
{
if ((Object)(object)__instance == (Object)null || __instance.isMenuAvatar || !Side2DPlugin.Enabled.Value)
{
return;
}
PlayerAvatar playerAvatar = __instance.playerAvatar;
if (!((Object)(object)playerAvatar == (Object)null) && !((Object)(object)playerAvatar.photonView == (Object)null) && playerAvatar.photonView.IsMine)
{
if ((Object)(object)__instance.animator != (Object)null)
{
((Behaviour)__instance.animator).enabled = true;
}
if ((Object)(object)__instance.meshParent != (Object)null)
{
__instance.meshParent.SetActive(true);
}
}
}
}
[HarmonyPatch(typeof(PlayerAvatarVisuals), "Update")]
internal static class Patch_PlayerAvatarVisuals_Update_KeepShown
{
private static void Postfix(PlayerAvatarVisuals __instance)
{
if ((Object)(object)__instance == (Object)null || __instance.isMenuAvatar || !Side2DPlugin.Enabled.Value)
{
return;
}
PlayerAvatar playerAvatar = __instance.playerAvatar;
if (!((Object)(object)playerAvatar == (Object)null) && !((Object)(object)playerAvatar.photonView == (Object)null) && playerAvatar.photonView.IsMine)
{
if ((Object)(object)__instance.animator != (Object)null && !((Behaviour)__instance.animator).enabled)
{
((Behaviour)__instance.animator).enabled = true;
}
if ((Object)(object)__instance.meshParent != (Object)null && !__instance.meshParent.activeSelf)
{
__instance.meshParent.SetActive(true);
}
}
}
}
internal static class Side2DLevelGate
{
[HarmonyPatch(typeof(LevelGenerator), "GenerateDone")]
private static class Patch_LevelGenerator_GenerateDone_Post
{
private static void Postfix()
{
try
{
RecomputeAndApply("LevelGenerator.GenerateDone");
}
catch (Exception ex)
{
ManualLogSource log = _log;
if (log != null)
{
log.LogError((object)ex);
}
}
}
}
[HarmonyPatch(typeof(SemiFunc), "OnSceneSwitch")]
private static class Patch_SemiFunc_OnSceneSwitch_Post
{
private static void Postfix(bool _gameOver, bool _leaveGame)
{
try
{
if (AutoEnableOnGen.Value)
{
Side2DPlugin.Enabled.Value = false;
_log.LogInfo((object)"[Side2D] Scene switch -> DISABLED (gate reset).");
}
}
catch (Exception ex)
{
ManualLogSource log = _log;
if (log != null)
{
log.LogError((object)ex);
}
}
}
}
private static ManualLogSource _log;
internal static ConfigEntry<bool> AutoEnableOnGen;
internal static ConfigEntry<string> MarkerObjectName;
internal static void Init(ConfigFile cfg, ManualLogSource logger)
{
_log = logger;
AutoEnableOnGen = cfg.Bind<bool>("LevelGate", "AutoEnableOnGeneration", true, "If true, the mod auto-enables only after level generation AND the marker object exists; resets to OFF on scene switch.");
MarkerObjectName = cfg.Bind<string>("LevelGate", "MarkerObjectName", "__SIDE2D__", "Exact GameObject name to look for after generation. Place this object in your level to activate the mod.");
if (AutoEnableOnGen.Value)
{
Side2DPlugin.Enabled.Value = false;
_log.LogInfo((object)"[Side2D] LevelGate armed (marker mode). Waiting for generation…");
}
}
private static bool MarkerPresent()
{
string text = (MarkerObjectName.Value ?? "").Trim();
if (string.IsNullOrEmpty(text))
{
return false;
}
GameObject val = GameObject.Find(text);
return (Object)(object)val != (Object)null;
}
private static void RecomputeAndApply(string reason)
{
if (!AutoEnableOnGen.Value)
{
_log.LogInfo((object)("[Side2D] Gate check @ " + reason + ": AutoEnable disabled."));
return;
}
bool flag = MarkerPresent();
Side2DPlugin.Enabled.Value = flag;
_log.LogInfo((object)("[Side2D] Gate decision @ " + reason + ": " + (flag ? "ENABLED (marker found)" : "DISABLED (marker missing)") + " (Marker='" + MarkerObjectName.Value + "')"));
}
}
[HarmonyPatch(typeof(PlayerController), "Update")]
internal static class Patch_PlayerController_Update_BlockEnergyDrain
{
private static void Postfix(PlayerController __instance)
{
if (!((Object)(object)__instance == (Object)null) && TwoDInputGate.BlockInputsNow() && Side2DPlugin.BlockEnergyDrain.Value && __instance.EnergyCurrent < __instance.EnergyStart)
{
__instance.EnergyCurrent = __instance.EnergyStart;
}
}
}
[HarmonyPatch(typeof(RoundDirector), "ExtractionCompletedAllRPC")]
internal static class Patch_RoundDirector_ExtractionCompletedAllRPC_AutoAdvance
{
private static void Postfix()
{
if (!Side2DPlugin.AutoAdvanceOnExtractComplete.Value || !Side2DPlugin.Enabled.Value || !SemiFunc.IsMasterClientOrSingleplayer())
{
return;
}
try
{
RunManager.instance.ChangeLevel(true, false, (ChangeLevelType)0);
}
catch (Exception arg)
{
ManualLogSource log = Side2DPlugin.Log;
if (log != null)
{
log.LogError((object)$"[Side2D] AutoAdvance failed: {arg}");
}
}
}
}
}
namespace REPARIO
{
[HarmonyPatch(typeof(PlayerController))]
internal static class ExamplePlayerControllerPatch
{
[HarmonyPrefix]
[HarmonyPatch("Start")]
private static void Start_Prefix(PlayerController __instance)
{
REPARIO.Logger.LogDebug((object)$"{__instance} Start Prefix");
}
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void Start_Postfix(PlayerController __instance)
{
REPARIO.Logger.LogDebug((object)$"{__instance} Start Postfix");
}
}
[BepInPlugin("Omniscye.REPARIO", "REPARIO", "1.0")]
public class REPARIO : BaseUnityPlugin
{
internal static REPARIO Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
private void Awake()
{
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Patch();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
internal void Patch()
{
//IL_001a: 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_0021: Expected O, but got Unknown
//IL_0026: Expected O, but got Unknown
if (Harmony == null)
{
Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony val2 = val;
Harmony = val;
}
Harmony.PatchAll();
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void Update()
{
}
}
}