using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using AIGraph;
using AK;
using Agents;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using CullingSystem;
using Enemies;
using GameData;
using Gear;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LevelGeneration;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
using ToolBugFix.Dependencies;
using ToolBugFix.Patches.Bio;
using ToolBugFix.Patches.Foam;
using ToolBugFix.Patches.Mines;
using ToolBugFix.Utils;
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("ToolBugFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f9ff9ce0defc512de322a53c45613d3ec6169885")]
[assembly: AssemblyProduct("ToolBugFix")]
[assembly: AssemblyTitle("ToolBugFix")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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]
[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 ToolBugFix
{
internal static class DinoLogger
{
private static ManualLogSource logger = Logger.CreateLogSource("ToolBugFix");
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.ToolBugFix", "ToolBugFix", "1.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal sealed class EntryPoint : BasePlugin
{
public const string MODNAME = "ToolBugFix";
public override void Load()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
Harmony val = new Harmony("ToolBugFix");
val.PatchAll();
if (!BSFDep.Installed)
{
Type[] patchTypes = BSFDep.PatchTypes;
foreach (Type type in patchTypes)
{
val.PatchAll(type);
}
}
if (!DEFDep.Installed)
{
Type[] patchTypes = DEFDep.PatchTypes;
foreach (Type type2 in patchTypes)
{
val.PatchAll(type2);
}
}
((BasePlugin)this).Log.LogMessage((object)"Loaded ToolBugFix");
}
}
}
namespace ToolBugFix.Utils
{
public static class DoorUtil
{
private const float PortalCheckBuffer = 0.25f;
private const float MinDotInNode = 0.1f;
private static readonly List<AIG_CoursePortal> _portalCache = new List<AIG_CoursePortal>();
public static bool TryGetNearbyPortal(Vector3 pos, AIG_CourseNode node, [MaybeNullWhen(false)] out AIG_CoursePortal portal)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//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)
float num = float.MaxValue;
portal = null;
Enumerator<AIG_CoursePortal> enumerator = node.m_portals.GetEnumerator();
float num2 = default(float);
float num3 = default(float);
while (enumerator.MoveNext())
{
AIG_CoursePortal current = enumerator.Current;
Vector3 val = pos - current.Position;
float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
current.m_cullPortal.GetShapeWidthHeight(ref num2, ref num3);
num2 /= 2f;
num3 /= 2f;
num2 += 0.25f;
num3 += 0.25f;
if (sqrMagnitude < num && sqrMagnitude < num2 * num2 + num3 * num3)
{
portal = current;
num = sqrMagnitude;
}
}
return portal != null;
}
public static bool TryGetCrossPortal(Vector3 pos, AIG_CourseNode nodeA, AIG_CourseNode nodeB, [MaybeNullWhen(false)] out AIG_CoursePortal portal)
{
//IL_0095: 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_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
int nodeID = nodeB.NodeID;
Enumerator<AIG_CoursePortal> enumerator = nodeA.m_portals.GetEnumerator();
while (enumerator.MoveNext())
{
AIG_CoursePortal current = enumerator.Current;
if (current.GetOppositeNode(nodeA).NodeID == nodeID)
{
_portalCache.Add(current);
}
}
if (_portalCache.Count == 0)
{
portal = null;
return false;
}
if (_portalCache.Count == 1)
{
portal = _portalCache[0];
_portalCache.Clear();
return true;
}
float num = float.MaxValue;
portal = null;
foreach (AIG_CoursePortal item in _portalCache)
{
Vector3 val = pos - item.Position;
float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
if (sqrMagnitude < num)
{
portal = item;
num = sqrMagnitude;
}
}
_portalCache.Clear();
return true;
}
public static bool IsOnSameSide(Vector3 pos, AIG_CourseNode checkNode, AIG_CoursePortal portal)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: 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_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
C_Portal cullPortal = portal.m_cullPortal;
Vector3 val = pos - cullPortal.m_center;
return Vector3.Dot(cullPortal.GetDirIntoNode(checkNode.m_cullNode), val) > 0.1f;
}
public static AIG_CourseNode GetCorrectNode(Vector3 pos, AIG_CourseNode node)
{
//IL_0000: 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)
if (TryGetNearbyPortal(pos, node, out AIG_CoursePortal portal))
{
AIG_CourseNode oppositeNode = portal.GetOppositeNode(node);
if (IsOnSameSide(pos, oppositeNode, portal))
{
return oppositeNode;
}
}
return node;
}
public static bool CanTouchNode(Vector3 pos, AIG_CourseNode node, AIG_CourseNode checkNode)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
if (node.NodeID == checkNode.NodeID)
{
return true;
}
if (!TryGetCrossPortal(pos, node, checkNode, out AIG_CoursePortal portal))
{
return false;
}
if (portal.IsTraversable)
{
return true;
}
return IsOnSameSide(pos, checkNode, portal);
}
public static bool CanTouchNode(Vector3 pos, AIG_CourseNode checkNode)
{
//IL_0000: 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 (!TryGetNearbyPortal(pos, checkNode, out AIG_CoursePortal portal) || portal.IsTraversable)
{
return true;
}
return IsOnSameSide(pos, checkNode, portal);
}
}
}
namespace ToolBugFix.Patches
{
[HarmonyPatch]
internal static class AmmoPatches
{
[HarmonyPatch(typeof(PlayerAmmoStorage), "UpdateBulletsInPack")]
[HarmonyWrapSafe]
[HarmonyPrefix]
private static bool Unclamp_UpdateBullets(PlayerAmmoStorage __instance, AmmoType ammoType, int bulletCount, ref float __result)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Invalid comparison between Unknown and I4
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
if ((int)ammoType != 2)
{
return true;
}
InventorySlotAmmo inventorySlotAmmo = __instance.GetInventorySlotAmmo(ammoType);
float ammoInPack = inventorySlotAmmo.AmmoInPack;
float ammoMaxCap = inventorySlotAmmo.AmmoMaxCap;
float num = (float)bulletCount * inventorySlotAmmo.CostOfBullet;
if (ammoInPack + num < ammoMaxCap)
{
return true;
}
float num4;
if (num > 0f && ammoInPack > 0f)
{
if (ammoInPack >= ammoMaxCap || num >= ammoMaxCap)
{
float num2 = (inventorySlotAmmo.AmmoInPack = Math.Max(ammoInPack, num));
num4 = num2;
}
else
{
float num2 = (inventorySlotAmmo.AmmoInPack = Math.Min(ammoInPack + num, ammoMaxCap));
num4 = num2;
}
}
else
{
float num2 = (inventorySlotAmmo.AmmoInPack += num);
num4 = num2;
}
inventorySlotAmmo.OnBulletsUpdateCallback?.Invoke(inventorySlotAmmo.BulletsInPack);
__instance.NeedsSync = true;
__instance.UpdateSlotAmmoUI(inventorySlotAmmo, 0);
__result = num4;
return false;
}
[HarmonyPatch(typeof(PlayerAmmoStorage), "UpdateAmmoInPack")]
[HarmonyWrapSafe]
[HarmonyPrefix]
private static bool Unclamp_UpdateAmmo(PlayerAmmoStorage __instance, AmmoType ammoType, float delta, ref float __result)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Invalid comparison between Unknown and I4
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
if ((int)ammoType != 2)
{
return true;
}
InventorySlotAmmo inventorySlotAmmo = __instance.GetInventorySlotAmmo(ammoType);
float ammoInPack = inventorySlotAmmo.AmmoInPack;
float ammoMaxCap = inventorySlotAmmo.AmmoMaxCap;
if (ammoInPack + delta < ammoMaxCap)
{
return true;
}
float num3;
if (delta > 0f && ammoInPack > 0f)
{
if (ammoInPack >= ammoMaxCap || delta >= ammoMaxCap)
{
float num = (inventorySlotAmmo.AmmoInPack = Math.Max(ammoInPack, delta));
num3 = num;
}
else
{
float num = (inventorySlotAmmo.AmmoInPack = Math.Min(ammoInPack + delta, ammoMaxCap));
num3 = num;
}
}
else
{
float num = (inventorySlotAmmo.AmmoInPack += delta);
num3 = num;
}
inventorySlotAmmo.OnBulletsUpdateCallback?.Invoke(inventorySlotAmmo.BulletsInPack);
__instance.NeedsSync = true;
__instance.UpdateSlotAmmoUI(inventorySlotAmmo, 0);
__result = num3;
return false;
}
}
}
namespace ToolBugFix.Patches.Sentry
{
[HarmonyPatch]
internal static class BurstCountPatches
{
[HarmonyPatch(typeof(SentryGunInstance_Firing_Bullets), "StartFiring")]
[HarmonyPostfix]
private static void Post_StartFiring(SentryGunInstance_Firing_Bullets __instance)
{
__instance.m_burstClipCurr = __instance.m_archetypeData.BurstShotCount;
}
[HarmonyPatch(typeof(SentryGunInstance_Firing_Bullets), "StopFiring")]
[HarmonyPostfix]
private static void Post_StopFiring(SentryGunInstance_Firing_Bullets __instance)
{
__instance.m_burstTimer = Clock.Time + __instance.m_archetypeData.BurstDelay;
}
}
[HarmonyPatch]
internal static class DetectionPatches
{
private struct EnemyTarget
{
public EnemyAgent EnemyAgent;
public float DistanceToTargetSqr;
public float AngleToTarget;
public bool IsTagged;
}
private static readonly Queue<AIG_CourseNode> s_nodeQueue = new Queue<AIG_CourseNode>();
private static readonly EnemyTarget[] _targetCache = new EnemyTarget[50];
[HarmonyPatch(typeof(SentryGunInstance_Detection), "GetNodesInSight")]
[HarmonyPrefix]
private static bool Pre_GetNodes(ref Il2CppReferenceArray<AIG_CourseNode> __result)
{
__result = null;
return false;
}
[HarmonyPatch(typeof(SentryGunInstance_Detection), "Setup")]
[HarmonyWrapSafe]
[HarmonyPostfix]
private static void Post_Setup(SentryGunInstance_Detection __instance, AIG_CourseNode spawnNode)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
((Il2CppObjectBase)__instance.m_core).Cast<SentryGunInstance>().CourseNode = (spawnNode = DoorUtil.GetCorrectNode(__instance.DetectionSource.position, spawnNode));
__instance.m_nodesToCheck = Il2CppReferenceArray<AIG_CourseNode>.op_Implicit(GetNodesInSight(spawnNode, __instance.DetectionSource, __instance.m_archetypeData.Sentry_DetectionMaxRange, __instance.m_archetypeData.Sentry_DetectionMaxAngle <= 90f));
}
private static AIG_CourseNode[] GetNodesInSight(AIG_CourseNode originNode, Transform detectionSource, float maxRange, bool checkAngle)
{
//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)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
AIG_SearchID.IncrementSearchID();
ushort searchID = AIG_SearchID.SearchID;
float sqrRange = maxRange * maxRange;
Vector3 forward = detectionSource.forward;
Vector3 position = detectionSource.position;
((AIG_CourseGraphMember)originNode).m_searchID = searchID;
s_nodeQueue.Enqueue(originNode);
List<AIG_CourseNode> list = new List<AIG_CourseNode>();
AIG_CourseNode result;
while (s_nodeQueue.TryDequeue(out result))
{
list.Add(result);
Enumerator<AIG_CoursePortal> enumerator = result.m_portals.GetEnumerator();
while (enumerator.MoveNext())
{
AIG_CoursePortal current = enumerator.Current;
AIG_CourseNode oppositeNode = current.GetOppositeNode(result);
if (oppositeNode != null && ((AIG_CourseGraphMember)oppositeNode).m_searchID != searchID && BoundsInRange(current.m_cullPortal.m_portalBounds, position, forward, sqrRange, checkAngle))
{
((AIG_CourseGraphMember)oppositeNode).m_searchID = searchID;
s_nodeQueue.Enqueue(oppositeNode);
}
}
}
return list.ToArray();
}
private static bool BoundsInRange(Bounds bounds, Vector3 origin, Vector3 dir, float sqrRange, bool checkAngle)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: 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)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: 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_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: 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_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = ((Bounds)(ref bounds)).ClosestPoint(origin) - origin;
if (((Vector3)(ref val)).sqrMagnitude >= sqrRange)
{
return false;
}
if (!checkAngle)
{
return true;
}
val = ((Bounds)(ref bounds)).center - origin;
float num = Vector3.Dot(dir, val);
if (num >= 0f)
{
return true;
}
float num2 = ((Bounds)(ref bounds)).extents.x * Math.Abs(dir.x) + ((Bounds)(ref bounds)).extents.y * Math.Abs(dir.y) + ((Bounds)(ref bounds)).extents.z * Math.Abs(dir.z);
return num + num2 >= 0f;
}
[HarmonyPatch(typeof(SentryGunInstance_Detection), "CheckForTarget")]
[HarmonyWrapSafe]
[HarmonyPrefix]
private static bool Pre_CheckForTarget(ArchetypeDataBlock archetypeData, Il2CppReferenceArray<AIG_CourseNode> nodesToCheck, Transform detectionSource, ref EnemyAgent? __result)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//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)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: 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_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
if (nodesToCheck == null)
{
__result = null;
return false;
}
Vector3 forward = detectionSource.forward;
Vector3 position = detectionSource.position;
bool sentry_ForceAimTowardsBody = archetypeData.Sentry_ForceAimTowardsBody;
float sentry_DetectionMaxAngle = archetypeData.Sentry_DetectionMaxAngle;
float num = archetypeData.Sentry_DetectionMaxRange * archetypeData.Sentry_DetectionMaxRange;
bool sentry_FireTagOnly = archetypeData.Sentry_FireTagOnly;
int mASK_SENTRYGUN_DETECTION_BLOCKERS = LayerManager.MASK_SENTRYGUN_DETECTION_BLOCKERS;
int num2 = 0;
foreach (AIG_CourseNode item in (Il2CppArrayBase<AIG_CourseNode>)(object)nodesToCheck)
{
Enumerator<EnemyAgent> enumerator2 = item.m_enemiesInNode.GetEnumerator();
while (enumerator2.MoveNext())
{
EnemyAgent current = enumerator2.Current;
Vector3 val = ((Component)current).transform.position - position;
float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
if (((Vector3)(ref val)).sqrMagnitude > num)
{
continue;
}
float num3 = Vector3.Angle(forward, val);
if (num3 > sentry_DetectionMaxAngle)
{
continue;
}
Vector3 position2 = (sentry_ForceAimTowardsBody ? ((Agent)current).AimTargetBody : ((Agent)current).AimTarget).position;
if (Physics.Linecast(position, position2, mASK_SENTRYGUN_DETECTION_BLOCKERS))
{
continue;
}
bool isTagged = current.IsTagged;
if (((Dam_SyncedDamageBase)current.Damage).Health > 0f && (isTagged || (!sentry_FireTagOnly && !current.RequireTagForDetection)))
{
EnemyTarget enemyTarget = new EnemyTarget
{
EnemyAgent = current,
DistanceToTargetSqr = sqrMagnitude,
AngleToTarget = num3,
IsTagged = isTagged
};
_targetCache[num2++] = enemyTarget;
if (num2 >= _targetCache.Length)
{
break;
}
}
}
if (num2 >= _targetCache.Length)
{
break;
}
}
EnemyTarget enemyTarget2 = default(EnemyTarget);
float num4 = float.MaxValue;
bool sentry_PrioTag = archetypeData.Sentry_PrioTag;
for (int i = 0; i < num2; i++)
{
EnemyTarget enemyTarget3 = _targetCache[i];
float num5 = (enemyTarget3.DistanceToTargetSqr + enemyTarget3.AngleToTarget * enemyTarget3.AngleToTarget) / 2f;
if (sentry_PrioTag && enemyTarget3.IsTagged)
{
num5 *= 0.5f;
}
if (num5 < num4)
{
num4 = num5;
enemyTarget2 = enemyTarget3;
}
}
__result = enemyTarget2.EnemyAgent;
return false;
}
[HarmonyPatch(typeof(SentryGunInstance), "StopFiring")]
[HarmonyWrapSafe]
[HarmonyPostfix]
private static void Post_StopFiring(SentryGunInstance __instance)
{
if (__instance.Ammo < __instance.CostOfBullet)
{
SentryGunInstance_Detection obj = ((Il2CppObjectBase)__instance.m_detection).Cast<SentryGunInstance_Detection>();
obj.Target = null;
obj.TargetAimTrans = null;
obj.HasTarget = false;
obj.TargetIsTagged = false;
}
}
}
[HarmonyPatch]
internal static class InitialTargetPatches
{
[HarmonyPatch(typeof(SentryGunInstance), "_OnGearSpawnComplete_b__65_0")]
[HarmonyPrefix]
private static bool InitialTargetFix(SentryGunInstance __instance)
{
((ItemEquippable)__instance).Sound.Post(EVENTS.SENTRYGUN_DETECT, true);
__instance.m_startFireTimer = Clock.Time + ((ItemEquippable)__instance).ArchetypeData.GetSentryStartFireDelay(((Item)__instance).Owner, __instance.m_detection.TargetIsTagged);
__instance.m_visuals.SetVisualStatus((eSentryGunStatus)2, true);
return false;
}
}
[HarmonyPatch]
internal static class ShotgunTargetPatches
{
private static bool _inShotgunFire;
private static Vector3 _cachedDir;
[HarmonyPatch(typeof(SentryGunInstance_Firing_Bullets), "TriggerSingleFireAudio")]
[HarmonyWrapSafe]
[HarmonyPostfix]
private static void Pre_ShotgunFireBullet(SentryGunInstance_Firing_Bullets __instance)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: 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)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: 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)
Vector3 val = default(Vector3);
if ((int)__instance.m_fireMode == 13 && __instance.m_archetypeData.Sentry_FireTowardsTargetInsteadOfForward && __instance.m_core.TryGetTargetAimPos(ref val))
{
_inShotgunFire = true;
_cachedDir = __instance.MuzzleAlign.forward;
Transform muzzleAlign = __instance.MuzzleAlign;
Vector3 val2 = val - __instance.MuzzleAlign.position;
muzzleAlign.forward = ((Vector3)(ref val2)).normalized;
}
}
[HarmonyPatch(typeof(SentryGunInstance_Firing_Bullets), "UpdateAmmo")]
[HarmonyPostfix]
private static void Post_ShotgunFireBullet(SentryGunInstance_Firing_Bullets __instance)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
if (_inShotgunFire)
{
__instance.MuzzleAlign.forward = _cachedDir;
_inShotgunFire = false;
}
}
}
}
namespace ToolBugFix.Patches.Mines
{
[HarmonyPatch]
internal static class DetectionPatches
{
[HarmonyPatch(typeof(MineDeployerInstance), "OnSpawnData")]
[HarmonyPostfix]
private static void Post_Spawn(MineDeployerInstance __instance)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
__instance.m_courseNode = DoorUtil.GetCorrectNode(((Component)__instance).transform.position, __instance.m_courseNode);
}
[HarmonyPatch(typeof(MineDeployerInstance_Detect_Laser), "UpdateDetection")]
[HarmonyPrefix]
private static bool Pre_Detection(MineDeployerInstance_Detect_Laser __instance)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
iMineDeployerInstanceCore core = __instance.m_core;
float maxLineDistance = __instance.m_maxLineDistance;
if ((int)core.Mode == 0 || maxLineDistance == 0f)
{
return true;
}
Transform lineRendererAlign = __instance.m_lineRendererAlign;
RaycastHit val = default(RaycastHit);
float num;
if (Physics.SphereCast(lineRendererAlign.position, 0.1f, lineRendererAlign.forward, ref val, maxLineDistance, __instance.m_scanMask))
{
num = ((RaycastHit)(ref val)).distance;
Collider collider = ((RaycastHit)(ref val)).collider;
if (CustomExtensions.IsInLayerMask(__instance.m_enemyMask, ((Component)collider).gameObject))
{
Agent baseAgent = ((Component)collider).GetComponent<IDamageable>().GetBaseAgent();
if (!DoorUtil.CanTouchNode(baseAgent.Position, baseAgent.CourseNode, core.CourseNode))
{
return false;
}
Action onTargetDetected = __instance.OnTargetDetected;
if (onTargetDetected != null)
{
onTargetDetected.Invoke();
}
return false;
}
}
else
{
num = maxLineDistance;
}
if (num != __instance.DetectionRange)
{
__instance.UpdateDetectionRange(num);
}
return false;
}
}
}
namespace ToolBugFix.Patches.Foam
{
internal static class CollisionPatches
{
[HarmonyPatch(typeof(GlueGunProjectile), "SetLandedStatic")]
[HarmonyPostfix]
private static void Post_LandStatic(GlueGunProjectile __instance, bool enableCollider)
{
if (!enableCollider)
{
__instance.m_landedOnEnemy = true;
__instance.m_onEnemyVolumeScale = 1f;
}
}
[HarmonyPatch(typeof(GlueGunProjectile), "SetLandedOnEnemy")]
[HarmonyPostfix]
private static void Post_LandEnemy(GlueGunProjectile __instance)
{
((Collider)__instance.m_collider).enabled = false;
}
[HarmonyPatch(typeof(GlueGunProjectile), "CollisionCheck")]
[HarmonyPostfix]
private static void Post_Collision(GlueGunProjectile __instance, ref bool __result)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: 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_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: 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)
if (!__result)
{
return;
}
Collider projLastRayHitCollider = ((StickingProjectileBase)__instance).m_projLastRayHitCollider;
if ((Object)(object)projLastRayHitCollider == (Object)null || ((Component)((StickingProjectileBase)__instance).m_projLastRayHitCollider).gameObject.layer != LayerManager.LAYER_ENEMY_DAMAGABLE)
{
return;
}
Agent baseAgent = ((Component)projLastRayHitCollider).GetComponent<IDamageable>().GetBaseAgent();
if (!DoorUtil.CanTouchNode(((StickingProjectileBase)__instance).m_projTargetPos, baseAgent.CourseNode))
{
int num = ((StickingProjectileBase)__instance).CollisionMask & ~LayerManager.MASK_ENEMY_DAMAGABLE;
Vector3 val = ((StickingProjectileBase)__instance).m_projVelocity * Time.fixedDeltaTime;
RaycastHit val2 = default(RaycastHit);
__result = Physics.SphereCast(((StickingProjectileBase)__instance).m_projTargetPos, __instance.m_sphereCastRadius, val, ref val2, 1f, num);
if (__result)
{
((StickingProjectileBase)__instance).m_projLastRayHitPoint = ((RaycastHit)(ref val2)).point;
((StickingProjectileBase)__instance).m_projLastRayHitNormal = ((RaycastHit)(ref val2)).normal;
((StickingProjectileBase)__instance).m_projLastRayHitCollider = ((RaycastHit)(ref val2)).collider;
}
}
}
}
internal static class MergePatches
{
[HarmonyPatch(typeof(GlueGunProjectile), "SyncMergeToNothing")]
[HarmonyPrefix]
private static bool Pre_MergeToNothing(GlueGunProjectile __instance)
{
((Collider)__instance.m_collider).enabled = false;
__instance.m_expanding = false;
((MonoBehaviour)__instance).StartCoroutine(CollectionExtensions.WrapToIl2Cpp(DecayBlob(__instance)));
return false;
}
[HarmonyPatch(typeof(GlueGunProjectile), "RemoveFromVolume")]
[HarmonyPrefix]
private static bool Pre_RemoveFromVolume(GlueGunProjectile __instance, float volRem, ref float __result)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: 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_0042: Unknown result type (might be due to invalid IL or missing references)
if (!SNet.IsMaster)
{
return true;
}
GlueVolumeDesc volumeDesc = __instance.m_volumeDesc;
float num = volumeDesc.expandVolume + volumeDesc.volume;
if (volRem < num)
{
return true;
}
__result = volRem - num;
volumeDesc.expandVolume = 0f;
volumeDesc.volume = 0f;
__instance.m_volumeDesc = volumeDesc;
ProjectileManager.WantToMergeGlueToNothing(__instance.SyncID);
return false;
}
[HarmonyPatch(typeof(LG_WeakDoor_Destruction), "AddGlue")]
[HarmonyPostfix]
private static void Post_DoorAddGlue(LG_WeakDoor_Destruction __instance, bool isNewProjectile)
{
if (isNewProjectile)
{
float num = __instance.CalcAttachedGlueVolume();
__instance.OnGlueLevelUpdate.Invoke(Mathf.Min(num / RundownManager.ActiveExpeditionBalanceData.GlueVolumeForDoorGlueMaxState, 1f));
}
}
private static IEnumerator DecayBlob(GlueGunProjectile __instance)
{
float elapsed = 0f;
float duration = 0.5f;
float startScale = __instance.m_volumeDesc.currentScale * __instance.m_startScale;
float scaleSpeed = __instance.m_scaleSpeed;
double endValue = Math.Exp((0f - scaleSpeed) * duration);
double endMod = 1.0 / (1.0 - endValue);
yield return null;
for (elapsed += Clock.Delta; elapsed < duration; elapsed += Clock.Delta)
{
if ((Object)(object)__instance == (Object)null)
{
break;
}
float num = (float)((double)startScale * endMod * (Math.Exp((0f - scaleSpeed) * elapsed) - endValue));
__instance.FeedScale(num);
yield return null;
}
if ((Object)(object)__instance != (Object)null && SNet.IsMaster)
{
ProjectileManager.WantToDestroyGlue(__instance.SyncID);
}
}
}
}
namespace ToolBugFix.Patches.Bio
{
internal static class ScanPatches
{
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPostfix]
private static void Postfix_Set_ScannerData(EnemyAgent __instance)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Invalid comparison between Unknown and I4
__instance.m_hasDirtyScannerColor = true;
EnemyScannerDataObject scannerData = __instance.ScannerData;
if ((int)__instance.Locomotion.CurrentStateEnum != 14)
{
scannerData.m_soundIndex = 0;
}
}
}
}
namespace ToolBugFix.Dependencies
{
internal static class BSFDep
{
public const string PLUGIN_GUID = "randomuserhi.BioScannerFix";
public static readonly bool Installed;
internal static readonly Type[] PatchTypes;
static BSFDep()
{
PatchTypes = new Type[1] { typeof(ScanPatches) };
Installed = ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey("randomuserhi.BioScannerFix");
}
}
internal static class DEFDep
{
public const string PLUGIN_GUID = "Localia.DoorEnemyFix";
public static readonly bool Installed;
internal static readonly Type[] PatchTypes;
static DEFDep()
{
PatchTypes = new Type[3]
{
typeof(CollisionPatches),
typeof(MergePatches),
typeof(DetectionPatches)
};
Installed = ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey("Localia.DoorEnemyFix");
}
}
}