Decompiled source of ActuallyNoSway v0.1.0

ActuallyNoSway.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Agents;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CellMenu;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ActuallyNoSway")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ActuallyNoSway")]
[assembly: AssemblyTitle("ActuallyNoSway")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace ActuallyNoSway
{
	internal static class CorePatches
	{
		[HarmonyPatch(typeof(PlayerInventoryBase), "OnItemEquippableFlashlightWielded")]
		[HarmonyPostfix]
		private static void PlayerInventoryBase_OnItemEquippableFlashlightWielded_Postfix(PlayerInventoryBase __instance)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)__instance.Owner) && ((Agent)__instance.Owner).IsLocallyOwned && Object.op_Implicit((Object)(object)__instance.Owner.Owner) && !__instance.Owner.Owner.IsBot)
			{
				((Component)__instance.m_flashlight).transform.SetParent(((Component)__instance.WieldedItem).transform.parent);
				((Component)__instance.m_flashlight).transform.localPosition = __instance.WieldedItem.ItemFPSData.localPosHip + new Vector3(0f, 0f, -0.3f);
				((Component)__instance.m_flashlight).transform.localRotation = Quaternion.identity;
			}
		}

		[HarmonyPatch(typeof(PlayerInventoryBase), "UpdateFPSFlashlightAlignment")]
		[HarmonyPrefix]
		private static void PlayerInventoryBase_UpdateFPSFlashlightAlignment_Prefix(ref bool __runOriginal)
		{
			__runOriginal = false;
		}
	}
	internal static class PluginInfo
	{
		public const string GUID = "Andocas.ActuallyNoSway";

		public const string NAME = "ActuallyNoSway";

		public const string VERSION = "0.1.0";
	}
	[BepInPlugin("Andocas.ActuallyNoSway", "ActuallyNoSway", "0.1.0")]
	internal class Plugin : BasePlugin
	{
		public override void Load()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			Utils.LogInfo("Andocas.ActuallyNoSway is loading...");
			Harmony val = new Harmony("Andocas.ActuallyNoSway");
			val.PatchAll(typeof(CorePatches));
			Utils.LogInfo("Andocas.ActuallyNoSway is loaded");
		}
	}
	internal static class Utils
	{
		private static readonly ManualLogSource logger = Logger.CreateLogSource("Andocas.ActuallyNoSway");

		public static void LogInfo(object? o)
		{
			logger.LogInfo((object)GetMessage(o));
		}

		public static void LogError(object? o)
		{
			logger.LogError((object)GetMessage(o));
		}

		private static string GetMessage(object? o)
		{
			if (o == null)
			{
				return "No string representation for <null>";
			}
			return o.ToString() ?? $"No string representation for <{o.GetType()}>";
		}

		public static void SendLocalMessage(string text)
		{
			LogInfo("SendLocalMessage: " + text);
			GuiManager.PlayerLayer.m_gameEventLog.AddLogItem(text, (eGameEventChatLogType)2);
			CM_PageLoadout.Current.m_gameEventLog.AddLogItem(text, (eGameEventChatLogType)2);
		}
	}
}