using System;
using System.Collections.Generic;
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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using ClientSidePrediction.BepInEx;
using Enemies;
using GameData;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using Netstat;
using Player;
using SNetwork;
using ShaderValueAnimation;
using TMPro;
using UnityEngine;
using UnityEngine.AI;
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("ClientSidePrediction")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+0411363f707cf1a32102780d7052221c8816e32e")]
[assembly: AssemblyProduct("ClientSidePrediction")]
[assembly: AssemblyTitle("ClientSidePrediction")]
[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 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("ClientSidePrediction", data));
}
public static void Debug(object data)
{
if (ConfigManager.Debug)
{
Log(data);
}
}
public static void Warn(object data)
{
logger.LogWarning((object)Format("ClientSidePrediction", data));
}
public static void Error(object data)
{
logger.LogError((object)Format("ClientSidePrediction", data));
}
}
}
namespace ClientSidePrediction
{
[HarmonyPatch]
internal class Forecast
{
private static Vector3 sentPos = Vector3.zero;
private static Vector3 prevPos = Vector3.zero;
private static Vector3 oldVel = Vector3.zero;
private static CharacterController? characterController = null;
private static long prevTimestamp = 0L;
[HarmonyPatch(typeof(PlayerSync), "SendLocomotion")]
[HarmonyPrefix]
private static void Prefix_SendLocomotion(PlayerSync __instance, PLOC_State state, ref Vector3 pos, Vector3 lookDir, float velFwd, float velRight)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Invalid comparison between Unknown and I4
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Invalid comparison between Unknown and I4
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Invalid comparison between Unknown and I4
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: 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_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_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
if (SNet.IsMaster || (Object)(object)SNet.Master == (Object)null || (int)state == 7 || (int)state == 9 || (int)state == 15)
{
return;
}
long now = Plugin.Now;
float num = Mathf.Min((float)(now - prevTimestamp), 1000f) / 1000f;
Vector3 val = (pos - prevPos) / num;
prevPos = pos;
prevTimestamp = now;
float num2 = Mathf.Min(NetstatAPI.Ping, 0.25f) / 2f;
if (num2 <= 0f)
{
return;
}
Vector3 val2 = __instance.m_agent.Locomotion.m_input;
if ((double)((Vector3)(ref val2)).sqrMagnitude <= 0.01)
{
sentPos = pos;
return;
}
val2 = pos - prevPos;
if (((Vector3)(ref val2)).sqrMagnitude > 9f)
{
sentPos = pos;
return;
}
oldVel = val;
sentPos = pos + val * num2;
if ((Object)(object)characterController == (Object)null)
{
characterController = ((Il2CppObjectBase)__instance.m_agent).Cast<LocalPlayerAgent>().m_playerCharacterController.m_characterController;
}
if (!((Object)(object)characterController == (Object)null))
{
Vector3 position = ((Component)characterController).transform.position;
if (!characterController.isGrounded)
{
sentPos.y = pos.y;
}
characterController.Move(sentPos - pos);
sentPos = ((Component)characterController).transform.position;
((Component)characterController).transform.position = position;
pos = sentPos;
}
}
[HarmonyPatch(typeof(PUI_LocalPlayerStatus), "UpdateBPM")]
[HarmonyWrapSafe]
[HarmonyPostfix]
private static void Initialize_Postfix(PUI_LocalPlayerStatus __instance)
{
if (ConfigManager.PingOnStamina)
{
TextMeshPro pulseText = __instance.m_pulseText;
((TMP_Text)pulseText).text = ((TMP_Text)pulseText).text + " | " + (SNet.IsMaster ? "IsHost" : (NetstatAPI.IsDesynced ? "Desynced" : $"{NetstatAPI.PingMs} ms"));
}
}
}
[HarmonyPatch]
internal class Prediction
{
public class EnemyPredict : MonoBehaviour
{
public EnemyAgent agent;
public NavMeshAgent navMeshAgent;
public EnemyAI ai;
public int lastAnimIndex;
public float lastReceivedAttack;
public float triggeredTongue;
public float lastSound;
public bool predictTongue;
public AgentAbility type = (AgentAbility)1;
public Vector3 targetPos;
public long prevTimestamp;
public uint lastReceivedTick = uint.MaxValue;
public Vector3 vel = Vector3.zero;
public void Setup(EnemyAgent agent)
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: 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)
this.agent = agent;
ai = agent.AI;
navMeshAgent = ((Il2CppObjectBase)((AgentAI)agent.AI).m_navMeshAgent).Cast<NavMeshAgentProxy>().m_agent;
predictTongue = CheckAbilityTypeHasTongue((AgentAbility)1);
if (!predictTongue)
{
predictTongue = CheckAbilityTypeHasTongue((AgentAbility)2);
type = (AgentAbility)2;
}
if (predictTongue && ConfigManager.DisableTonguePredictOnEnemiesWithMelee && (CheckAbilityTypeHasMelee((AgentAbility)1) || CheckAbilityTypeHasMelee((AgentAbility)2)))
{
predictTongue = false;
APILogger.Debug("Disabled tongue for enemy as it has a melee ability.");
}
targetPos = ((Component)agent).transform.position;
}
private void FixedUpdate()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Invalid comparison between Unknown and I4
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: 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_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
if ((int)agent.Locomotion.CurrentStateEnum != 2)
{
((Component)agent).transform.position = NavMeshMove(navMeshAgent, ((Component)agent).transform.position, ExpDecay(((Component)agent).transform.position, targetPos, 2.5f, Time.fixedDeltaTime));
}
}
private bool CheckAbilityTypeHasTongue(AgentAbility type)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Invalid comparison between Unknown and I4
EnemyAbility ability = agent.Abilities.GetAbility(type, 0);
if ((Object)(object)ability == (Object)null)
{
return false;
}
EAB_MovingEnemeyTentacle val = ((Il2CppObjectBase)ability).TryCast<EAB_MovingEnemeyTentacle>();
if ((Object)(object)val == (Object)null)
{
return false;
}
return (int)val.m_type == 0;
}
private bool CheckAbilityTypeHasMelee(AgentAbility type)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
EnemyAbility ability = agent.Abilities.GetAbility(type, 0);
if ((Object)(object)ability == (Object)null)
{
return false;
}
if ((Object)(object)((Il2CppObjectBase)ability).TryCast<EAB_StrikerMelee>() == (Object)null)
{
return false;
}
return true;
}
}
public static Dictionary<IntPtr, EnemyPredict> map = new Dictionary<IntPtr, EnemyPredict>();
[HarmonyPatch(typeof(RundownManager), "EndGameSession")]
[HarmonyPrefix]
private static void EndGameSession()
{
map.Clear();
}
[HarmonyPatch(typeof(SNet_SessionHub), "LeaveHub")]
[HarmonyPrefix]
private static void LeaveHub()
{
map.Clear();
}
[HarmonyPatch(typeof(Vector4Transition), "FeedMaterial")]
[HarmonyPrefix]
private static void FeedMaterial(Vector4Transition __instance, List<ISVA_MaterialHolder> mats, Vector4 value, ref float t)
{
if (float.IsNaN(t))
{
t = 0f;
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Vector3 ExpDecay(Vector3 a, Vector3 b, float decay, float dt)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//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_0011: 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)
return b + (a - b) * Mathf.Exp((0f - decay) * dt);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static float ExpDecay(float a, float b, float decay, float dt)
{
return b + (a - b) * Mathf.Exp((0f - decay) * dt);
}
private static Vector3 NavMeshMove(NavMeshAgent agent, Vector3 start, Vector3 target, float maxDistance = 5f)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: 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_0018: 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_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
NavMeshHit val = default(NavMeshHit);
if (NavMesh.SamplePosition(target, ref val, maxDistance, agent.areaMask))
{
Vector3 position = ((NavMeshHit)(ref val)).position;
if (NavMesh.Raycast(start, position, ref val, agent.areaMask))
{
position = ((NavMeshHit)(ref val)).position;
}
return position;
}
return start;
}
[HarmonyPatch(typeof(ES_EnemyAttackBase), "RecieveAttackStart")]
[HarmonyPrefix]
private static void ES_StrikerAttack_RecieveAttackStart(ES_EnemyAttackBase __instance, pES_EnemyAttackData attackData)
{
if (SNet.IsMaster || ((Il2CppObjectBase)__instance).TryCast<ES_StrikerAttack>() == null)
{
return;
}
ES_PathMove val = ((Il2CppObjectBase)((ES_Base)__instance).m_enemyAgent.Locomotion.PathMove).TryCast<ES_PathMove>();
if (val == null)
{
return;
}
IntPtr pointer = ((Il2CppObjectBase)val.m_positionBuffer).Pointer;
if (map.ContainsKey(pointer))
{
EnemyPredict enemyPredict = map[pointer];
if (!(enemyPredict.lastReceivedAttack < 0f))
{
enemyPredict.lastReceivedAttack = Clock.Time;
}
}
}
[HarmonyPatch(typeof(ES_StrikerAttack), "OnAttackWindUp")]
[HarmonyPrefix]
private static bool ES_StrikerAttack_OnAttackWindUp(ES_StrikerAttack __instance, int attackIndex, AgentAbility abilityType, int abilityIndex)
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
if (SNet.IsMaster)
{
return true;
}
ES_PathMove val = ((Il2CppObjectBase)((ES_Base)__instance).m_enemyAgent.Locomotion.PathMove).TryCast<ES_PathMove>();
if (val == null)
{
return true;
}
IntPtr pointer = ((Il2CppObjectBase)val.m_positionBuffer).Pointer;
if (!map.ContainsKey(pointer))
{
return true;
}
EAB_MovingEnemeyTentacle val2 = ((Il2CppObjectBase)((ES_Base)__instance).m_ai.m_enemyAgent.Abilities.GetAbility(abilityType, 0)).TryCast<EAB_MovingEnemeyTentacle>();
if ((Object)(object)val2 == (Object)null)
{
return true;
}
EnemyPredict enemyPredict = map[pointer];
if (Clock.Time < enemyPredict.lastSound + 0.5f)
{
__instance.m_tentacleAbility = val2;
((ES_Base)__instance).m_locomotion.m_animator.CrossFadeInFixedTime(((Il2CppArrayBase<int>)(object)EnemyLocomotion.s_hashAbilityFires)[attackIndex], ((ES_Base)__instance).m_enemyAgent.EnemyMovementData.BlendIntoAttackAnim);
((ES_Base)__instance).m_enemyAgent.Appearance.InterpolateGlow(Color.op_Implicit(__instance.m_attackGlowColor), __instance.m_attackGlowLocationEnd, ((ES_EnemyAttackBase)__instance).m_attackWindupDuration * 1.2f);
return false;
}
enemyPredict.lastSound = Clock.Time;
return true;
}
[HarmonyPatch(typeof(EnemySync), "OnSpawn")]
[HarmonyPostfix]
private static void OnSpawn(EnemySync __instance)
{
if (!SNet.IsMaster && ((Il2CppObjectBase)__instance.m_agent.Locomotion.PathMove).TryCast<ES_PathMove>() != null)
{
EnemyPredict enemyPredict = ((Component)__instance.m_agent).gameObject.AddComponent<EnemyPredict>();
enemyPredict.Setup(__instance.m_agent);
map.Add(((Il2CppObjectBase)((Il2CppObjectBase)__instance.m_agent.Locomotion.PathMove).Cast<ES_PathMove>().m_positionBuffer).Pointer, enemyPredict);
}
}
[HarmonyPatch(typeof(EnemySync), "OnDespawn")]
[HarmonyPostfix]
private static void OnDespawn(EnemySync __instance)
{
if (!SNet.IsMaster)
{
ES_PathMove val = ((Il2CppObjectBase)__instance.m_agent.Locomotion.PathMove).TryCast<ES_PathMove>();
if (val != null)
{
map.Remove(((Il2CppObjectBase)val.m_positionBuffer).Pointer);
}
}
}
[HarmonyPatch(typeof(EnemyBehaviour), "ChangeState", new Type[] { typeof(EB_States) })]
[HarmonyPrefix]
private static void Behaviour_ChangeState(EnemyBehaviour __instance, EB_States state)
{
//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_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Invalid comparison between Unknown and I4
if (!SNet.IsMaster && __instance.m_currentStateName != state && (int)state == 19)
{
ES_PathMove val = ((Il2CppObjectBase)__instance.m_ai.m_enemyAgent.Locomotion.PathMove).TryCast<ES_PathMove>();
if (val != null)
{
map.Remove(((Il2CppObjectBase)val.m_positionBuffer).Pointer);
}
}
}
[HarmonyPatch(typeof(ES_PathMove), "RecieveStateData")]
[HarmonyPrefix]
private static bool ES_PathMove_RecieveStateData(ES_PathMove __instance, pES_PathMoveData incomingData)
{
//IL_005d: 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)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: 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)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
if (SNet.IsMaster || (Object)(object)SNet.Master == (Object)null)
{
return true;
}
float num = Mathf.Min(NetstatAPI.Ping, 1f);
if (num <= 0f)
{
return true;
}
IntPtr pointer = ((Il2CppObjectBase)__instance.m_positionBuffer).Pointer;
if (!map.ContainsKey(pointer))
{
return true;
}
EnemyPredict enemyPredict = map[pointer];
if (enemyPredict.lastReceivedTick != incomingData.Tick)
{
enemyPredict.lastReceivedTick = incomingData.Tick;
long now = Plugin.Now;
if (enemyPredict.prevTimestamp == 0L)
{
enemyPredict.prevTimestamp = now;
}
float num2 = (float)(now - enemyPredict.prevTimestamp) / 1000f;
if (num2 > 0f)
{
enemyPredict.vel = (incomingData.Position - enemyPredict.targetPos) / num2;
enemyPredict.prevTimestamp = now;
}
}
enemyPredict.targetPos = incomingData.Position;
float num3 = enemyPredict.agent.Locomotion.AnimHandle.TentacleAttackWindUpLen / enemyPredict.agent.Locomotion.AnimSpeedOrg;
float num4 = enemyPredict.triggeredTongue + num3;
if (Clock.Time < num4)
{
if (enemyPredict.lastReceivedAttack < 0f && Clock.Time - enemyPredict.triggeredTongue > num)
{
APILogger.Debug("Mispredicted tongue animation!");
enemyPredict.triggeredTongue = num4;
enemyPredict.lastReceivedAttack = 0f;
return true;
}
__instance.m_positionBuffer.Push(incomingData);
return false;
}
return true;
}
[HarmonyPatch(typeof(ES_PathMove), "SyncUpdate")]
[HarmonyPostfix]
private static void ES_PathMove_SyncUpdate(ES_PathMove __instance)
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Invalid comparison between Unknown and I4
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: 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_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: 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 (SNet.IsMaster || (Object)(object)SNet.Master == (Object)null || NetstatAPI.PingMs < ConfigManager.TonguePredictThreshold)
{
return;
}
IntPtr pointer = ((Il2CppObjectBase)__instance.m_positionBuffer).Pointer;
if (!map.ContainsKey(pointer))
{
return;
}
EnemyPredict enemyPredict = map[pointer];
if (!enemyPredict.predictTongue)
{
return;
}
PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent();
float num = (((int)enemyPredict.type == 1) ? enemyPredict.agent.EnemyBehaviorData.MeleeAttackDistance.Max : enemyPredict.agent.EnemyBehaviorData.RangedAttackDistance.Max);
float num2 = Mathf.Min(NetstatAPI.Ping, 1f) / 2f;
Vector3 val = ((Agent)enemyPredict.agent).EyePosition + enemyPredict.vel * num2;
Vector3 val2 = ((Agent)localPlayerAgent).AimTarget.position - val;
float num3 = num * 1.05f;
if (((Vector3)(ref val2)).sqrMagnitude > num3 * num3 && enemyPredict.triggeredTongue != 0f)
{
enemyPredict.triggeredTongue = 0f;
}
if (enemyPredict.triggeredTongue == 0f && !((AgentAI)enemyPredict.ai).m_navMeshAgent.isOnOffMeshLink && ((AgentAI)enemyPredict.ai).m_target != null && (Object)(object)((AgentAI)enemyPredict.ai).m_target.m_agent == (Object)(object)localPlayerAgent && ((Vector3)(ref val2)).sqrMagnitude < num * num)
{
val2.y = 0.0001f;
((Vector3)(ref val2)).Normalize();
float num4 = Vector3.Dot(((Vector3)(ref val2)).normalized, ((Component)enemyPredict.agent).transform.forward);
bool flag = Physics.Linecast(val, ((Agent)localPlayerAgent).EyePosition, LayerManager.MASK_WORLD);
if ((((Vector3)(ref val2)).sqrMagnitude < 4f || num4 > 0.45f) && !flag)
{
pES_EnemyAttackData val3 = default(pES_EnemyAttackData);
val3.Position = enemyPredict.agent.Position;
val3.TargetPosition = ((Agent)localPlayerAgent).AimTarget.position;
((pAgent)(ref val3.TargetAgent)).Set((Agent)(object)localPlayerAgent);
val3.AnimIndex = (byte)enemyPredict.agent.Locomotion.GetUniqueAnimIndex(EnemyLocomotion.s_hashAbilityFires, ref enemyPredict.lastAnimIndex);
val3.AbilityType = (AgentAbility)1;
enemyPredict.lastReceivedAttack = -1f;
((ES_EnemyAttackBase)enemyPredict.agent.Locomotion.StrikerAttack).RecieveAttackStart(val3);
enemyPredict.triggeredTongue = Clock.Time;
}
}
}
}
}
namespace ClientSidePrediction.BepInEx
{
public static class Module
{
public const string GUID = "randomuserhi.ClientSidePrediction";
public const string Name = "ClientSidePrediction";
public const string Version = "0.2.5";
}
public static class ConfigManager
{
public static ConfigFile configFile;
private static ConfigEntry<bool> debug;
private static ConfigEntry<int> tonguePredictThreshold;
private static ConfigEntry<bool> disableTonguePredictOnEnemiesWithMelee;
private static ConfigEntry<bool> pingOnStamina;
public static bool Debug
{
get
{
return debug.Value;
}
set
{
debug.Value = value;
}
}
public static int TonguePredictThreshold
{
get
{
return tonguePredictThreshold.Value;
}
set
{
tonguePredictThreshold.Value = value;
}
}
public static bool DisableTonguePredictOnEnemiesWithMelee
{
get
{
return disableTonguePredictOnEnemiesWithMelee.Value;
}
set
{
disableTonguePredictOnEnemiesWithMelee.Value = value;
}
}
public static bool PingOnStamina
{
get
{
return pingOnStamina.Value;
}
set
{
pingOnStamina.Value = value;
}
}
static ConfigManager()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
configFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "ClientSidePrediction.cfg"), true);
debug = configFile.Bind<bool>("Debug", "enable", false, "Enables debug messages when true.");
tonguePredictThreshold = configFile.Bind<int>("Settings", "TonguePredictThreshold", 150, "When ping (in ms) exceeds this value enemy tongue windup animations are predicted.");
disableTonguePredictOnEnemiesWithMelee = configFile.Bind<bool>("Settings", "DisableTonguePredictOnEnemiesWithMelee", false, "Disables tongue prediction on enemies that have melee abilities to mitigate desync on mispredict.");
pingOnStamina = configFile.Bind<bool>("Settings", "PingOnStamina", false, "Display ping next to stamina");
}
}
[BepInPlugin("randomuserhi.ClientSidePrediction", "ClientSidePrediction", "0.2.5")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
private const string NetstatGUID = "food.randomuser.gtfo.Netstat";
private static Harmony? harmony;
public static long Now => ((DateTimeOffset)DateTime.Now).ToUnixTimeMilliseconds();
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.ClientSidePrediction");
harmony.PatchAll();
APILogger.Log("Debug is " + (ConfigManager.Debug ? "Enabled" : "Disabled"));
ClassInjector.RegisterTypeInIl2Cpp<Prediction.EnemyPredict>();
new Prediction();
}
}
}