using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AIGraph;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Hook;
using CullingSystem;
using GTFO.API;
using GalaxyBugFix.Patches;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppInterop.Runtime.Runtime;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("GalaxyBugFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f140cab0b13bade282816ab801a11dc93c953b24")]
[assembly: AssemblyProduct("GalaxyBugFix")]
[assembly: AssemblyTitle("GalaxyBugFix")]
[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 GalaxyBugFix
{
internal static class DinoLogger
{
private static ManualLogSource logger = Logger.CreateLogSource("GalaxyBugFix");
public static void Log(string format, params object[] args)
{
Log(string.Format(format, args));
}
public static void Log(string str)
{
if (logger != null)
{
logger.Log((LogLevel)8, (object)str);
}
}
public static void Warning(string format, params object[] args)
{
Warning(string.Format(format, args));
}
public static void Warning(string str)
{
if (logger != null)
{
logger.Log((LogLevel)4, (object)str);
}
}
public static void Error(string format, params object[] args)
{
Error(string.Format(format, args));
}
public static void Error(string str)
{
if (logger != null)
{
logger.Log((LogLevel)2, (object)str);
}
}
public static void Debug(string format, params object[] args)
{
Debug(string.Format(format, args));
}
public static void Debug(string str)
{
if (logger != null)
{
logger.Log((LogLevel)32, (object)str);
}
}
}
[BepInPlugin("Dinorush.GalaxyBugFix", "GalaxyBugFix", "1.0.1")]
internal sealed class EntryPoint : BasePlugin
{
public const string MODNAME = "GalaxyBugFix";
public override void Load()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
VolumeNativePatch.Init();
new Harmony("GalaxyBugFix").PatchAll();
((BasePlugin)this).Log.LogMessage((object)"Loaded GalaxyBugFix");
}
}
}
namespace GalaxyBugFix.Patches
{
[HarmonyPatch]
internal static class PortalPatch
{
[HarmonyPatch(typeof(C_Portal), "SetupEdges")]
[HarmonyPostfix]
private static void FixBottomPlane(C_Portal __instance)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: 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)
Plane val = ((Il2CppArrayBase<Plane>)(object)__instance.m_portalPlanes)[2];
val.m_Distance += 0.5f;
((Il2CppArrayBase<Plane>)(object)__instance.m_portalPlanes)[2] = val;
}
}
internal static class VolumeNativePatch
{
private unsafe delegate bool d_TryGetVoxelNode(IntPtr _this, Vector3 pos, out IntPtr node, Il2CppMethodInfo* methodInfo);
private const float EarlyExitValidDist = 1f;
private static INativeDetour? TryGetVoxelNodeDetour;
private static d_TryGetVoxelNode? orig_TryGetVoxelNode;
public unsafe static void Init()
{
TryGetVoxelNodeDetour = INativeDetour.CreateAndApply<d_TryGetVoxelNode>((IntPtr)(nint)Il2CppAPI.GetIl2CppMethod<AIG_VoxelNodeVolume>("TryGetCloseVoxelNode", typeof(bool).Name, false, new string[2]
{
typeof(Vector3).FullName,
typeof(AIG_INode).MakeByRefType().FullName
}), (d_TryGetVoxelNode)TryGetCloseVoxelNodePatch, ref orig_TryGetVoxelNode);
}
private unsafe static bool TryGetCloseVoxelNodePatch(IntPtr _this, Vector3 pos, [MaybeNullWhen(false)] out IntPtr nodePtr, Il2CppMethodInfo* methodInfo)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: 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_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: 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_010b: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: 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_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: 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_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: 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_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: 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_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
//IL_026b: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
AIG_VoxelNodeVolume val = new AIG_VoxelNodeVolume(_this);
float minHeight = pos.y - 0.5f;
float maxHeight = pos.y + 0.5f;
int num = default(int);
int num2 = default(int);
val.GetGridPosition(pos, ref num, ref num2);
float bestDistSqr = float.MaxValue;
AIG_INode best = null;
AIG_VoxelNodePillar pillar = default(AIG_VoxelNodePillar);
if (val.TryGetPillar(num, num2, ref pillar) && TryGetVoxelNode(pillar, pos, minHeight, maxHeight, out AIG_INode node) && UseBestCheckExit(node.Position - pos, node, ref best, ref bestDistSqr))
{
nodePtr = ((Il2CppObjectBase)best).Pointer;
return true;
}
if (val.TryGetPillar(num + 1, num2, ref pillar) && TryGetVoxelNode(pillar, pos, minHeight, maxHeight, out node) && UseBestCheckExit(node.Position - pos, node, ref best, ref bestDistSqr))
{
nodePtr = ((Il2CppObjectBase)best).Pointer;
return true;
}
if (val.TryGetPillar(num - 1, num2, ref pillar) && TryGetVoxelNode(pillar, pos, minHeight, maxHeight, out node) && UseBestCheckExit(node.Position - pos, node, ref best, ref bestDistSqr))
{
nodePtr = ((Il2CppObjectBase)best).Pointer;
return true;
}
if (val.TryGetPillar(num, num2 + 1, ref pillar) && TryGetVoxelNode(pillar, pos, minHeight, maxHeight, out node) && UseBestCheckExit(node.Position - pos, node, ref best, ref bestDistSqr))
{
nodePtr = ((Il2CppObjectBase)best).Pointer;
return true;
}
if (val.TryGetPillar(num, num2 - 1, ref pillar) && TryGetVoxelNode(pillar, pos, minHeight, maxHeight, out node) && UseBestCheckExit(node.Position - pos, node, ref best, ref bestDistSqr))
{
nodePtr = ((Il2CppObjectBase)best).Pointer;
return true;
}
if (val.TryGetPillar(num + 1, num2 + 1, ref pillar) && TryGetVoxelNode(pillar, pos, minHeight, maxHeight, out node) && UseBestCheckExit(node.Position - pos, node, ref best, ref bestDistSqr))
{
nodePtr = ((Il2CppObjectBase)best).Pointer;
return true;
}
if (val.TryGetPillar(num + 1, num2 - 1, ref pillar) && TryGetVoxelNode(pillar, pos, minHeight, maxHeight, out node) && UseBestCheckExit(node.Position - pos, node, ref best, ref bestDistSqr))
{
nodePtr = ((Il2CppObjectBase)best).Pointer;
return true;
}
if (val.TryGetPillar(num - 1, num2 + 1, ref pillar) && TryGetVoxelNode(pillar, pos, minHeight, maxHeight, out node) && UseBestCheckExit(node.Position - pos, node, ref best, ref bestDistSqr))
{
nodePtr = ((Il2CppObjectBase)best).Pointer;
return true;
}
if (val.TryGetPillar(num - 1, num2 - 1, ref pillar) && TryGetVoxelNode(pillar, pos, minHeight, maxHeight, out node) && UseBestCheckExit(node.Position - pos, node, ref best, ref bestDistSqr))
{
nodePtr = ((Il2CppObjectBase)best).Pointer;
return true;
}
nodePtr = ((best != null) ? ((Il2CppObjectBase)best).Pointer : IntPtr.Zero);
return nodePtr != IntPtr.Zero;
}
private static bool TryGetVoxelNode(AIG_VoxelNodePillar pillar, Vector3 orig, float minHeight, float maxHeight, [MaybeNullWhen(false)] out AIG_INode node)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
List<AIG_VoxelNode> nodes = pillar.m_nodes;
for (int i = 0; i < nodes.Count; i++)
{
AIG_VoxelNode val = nodes[i];
Vector3 position = val.Position;
if (position.y >= minHeight && position.y <= maxHeight)
{
node = ((Il2CppObjectBase)val).Cast<AIG_INode>();
return true;
}
}
node = null;
return false;
}
private static bool UseBestCheckExit<T>(Vector3 diff, T candidate, [NotNullWhen(true)] ref T best, ref float bestDistSqr)
{
float sqrMagnitude = ((Vector3)(ref diff)).sqrMagnitude;
if (sqrMagnitude <= 1f)
{
best = candidate;
return true;
}
if (sqrMagnitude < bestDistSqr)
{
best = candidate;
bestDistSqr = sqrMagnitude;
}
return false;
}
}
}