using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using API;
using Agents;
using BackFix.BepInEx;
using BackFix.Patches;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Enemies;
using GameData;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Analytics;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BackFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e8b60e5fdb539fbf1c9f6049faab0fb07fd86dc5")]
[assembly: AssemblyProduct("BackFix")]
[assembly: AssemblyTitle("BackFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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 BackFix.Patches
{
internal class KnifeFixPatch
{
[HarmonyPatch(typeof(Dam_EnemyDamageLimb), "ApplyDamageFromBehindBonus")]
[HarmonyPrefix]
private static bool Postfix_DamageFromBehind(Dam_EnemyDamageLimb __instance, ref float __result, float dam, Vector3 pos, Vector3 dir, float backstabberMulti)
{
//IL_0025: 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_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
if (__instance.m_base.Owner.EnemyBalancingData.AllowDamgeBonusFromBehind)
{
Vector3 forward = ((Agent)__instance.m_base.Owner).Forward;
float num = Vector3.Dot(dir, forward);
float num2 = num;
num2 = Mathf.Clamp01(num2 + 0.25f) + 1f;
APILogger.Debug($"back: {num} {num2}");
dam *= num2;
if ((double)num > 0.55 && backstabberMulti > 1f)
{
APILogger.Debug("Applied backstabber multi!");
dam *= backstabberMulti;
}
}
__result = dam;
return false;
}
}
internal class BackFixPatches
{
internal class SyncPosition : MonoBehaviour
{
public EnemyAgent? enemy;
private void Update()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)enemy == (Object)null))
{
enemy.Position = ((Component)enemy).transform.position;
((Agent)enemy).Forward = ((Component)enemy).transform.forward;
}
}
}
[HarmonyPatch(typeof(EnemySync), "OnSpawn")]
[HarmonyPostfix]
private static void OnSpawn(EnemySync __instance)
{
if (!Object.op_Implicit((Object)(object)((Component)__instance.m_agent).gameObject.GetComponent<SyncPosition>()))
{
((Component)__instance.m_agent).gameObject.AddComponent<SyncPosition>().enemy = __instance.m_agent;
}
}
}
}
namespace BackFix.BepInEx
{
public static class Module
{
public const string GUID = "randomuserhi.BackFix";
public const string Name = "BackFix";
public const string Version = "0.0.1";
}
internal static class ConfigManager
{
private static ConfigEntry<bool> debug;
public static bool Debug
{
get
{
return debug.Value;
}
set
{
debug.Value = value;
}
}
static ConfigManager()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
debug = new ConfigFile(Path.Combine(Paths.ConfigPath, "BackFix.cfg"), true).Bind<bool>("Debug", "enable", false, "Enables debug messages when true.");
}
}
[BepInPlugin("randomuserhi.BackFix", "BackFix", "0.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
private static Harmony? harmony;
public override void Load()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
APILogger.Log("Plugin is loaded!");
harmony = new Harmony("randomuserhi.BackFix");
APILogger.Log("Debug is " + (ConfigManager.Debug ? "Enabled" : "Disabled"));
ClassInjector.RegisterTypeInIl2Cpp<BackFixPatches.SyncPosition>();
if (((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("Localia.RealBackBonus", out var _))
{
APILogger.Log("Localia's true back mod is installed.");
}
else
{
harmony.PatchAll(typeof(KnifeFixPatch));
}
harmony.PatchAll(typeof(BackFixPatches));
}
}
}
namespace API
{
[HarmonyPatch(typeof(GameDataInit))]
internal class GameDataInit_Patches
{
[HarmonyPatch("Initialize")]
[HarmonyWrapSafe]
[HarmonyPostfix]
public static void Initialize_Postfix()
{
Analytics.enabled = false;
}
}
internal static class APILogger
{
private static readonly ManualLogSource logger;
static APILogger()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
logger = new ManualLogSource("Rand-API");
Logger.Sources.Add((ILogSource)(object)logger);
}
private static string Format(string module, object msg)
{
return $"[{module}]: {msg}";
}
public static void Info(string module, object data)
{
logger.LogMessage((object)Format(module, data));
}
public static void Verbose(string module, object data)
{
}
public static void Log(object data)
{
logger.LogDebug((object)Format("BackFix", data));
}
public static void Debug(object data)
{
if (ConfigManager.Debug)
{
Log(data);
}
}
public static void Warn(object data)
{
logger.LogWarning((object)Format("BackFix", data));
}
public static void Error(object data)
{
logger.LogError((object)Format("BackFix", data));
}
}
}