using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("JotunnModStub")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JotunnModStub")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
namespace AutoFollowPath
{
internal enum GroundType
{
Terrain,
Path,
Unknown
}
[BepInPlugin("org.bepinex.plugins.bid.autofollowpath", "AutoFollowPath", "1.6.7")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
internal class AutoFollowPath : BaseUnityPlugin
{
internal class DebugObject
{
public Vector3 source;
public Vector3 target;
public float weight;
public bool colorError;
public bool slopeError;
public Color targetColor;
public float targetHeight;
public bool collission;
public bool onStructure;
public bool isCheck;
public bool succeeded;
}
public const string PluginGUID = "org.bepinex.plugins.bid.autofollowpath";
public const string PluginName = "AutoFollowPath";
public const string PluginVersion = "1.6.7";
public static ConfigEntry<bool> GlobalSprintToggleConfig;
public static ConfigEntry<float> StaminaMinThresholdConfig;
public static ConfigEntry<int> UpdateTimeMillisConfig;
public static ConfigEntry<int> MaxAngleConfig;
public static ConfigEntry<int> NumAnglesConfig;
public static ConfigEntry<int> MaxDistanceConfig;
public static ConfigEntry<int> PathPointsConfig;
public static ConfigEntry<float> PathToleranceConfig;
public static ConfigEntry<float> AngleWeightFactorConfig;
public static ConfigEntry<float> DistanceWeightFactorConfig;
public static ConfigEntry<float> MaxInclineConfig;
public static ConfigEntry<bool> PavedOnlyConfig;
public static ConfigEntry<bool> EnabledConfig;
public static ConfigEntry<bool> VisualDebugConfig;
public static ConfigEntry<float> HeightmapSearchRadiusConfig;
public static ConfigEntry<float> RaycastHeightConfig;
public static ConfigEntry<float> CollissionHeightIncreaseConfig;
public static ConfigEntry<float> CollissionRayLengthDownConfig;
public static ConfigEntry<float> NearCollissionDetectionAngleConfig;
public static ConfigEntry<float> NearCollissionCorrectionAngleConfig;
public static ConfigEntry<float> NearCollissionDetectionLengthScaleConfig;
public static ConfigEntry<float> RidingDistanceFactorConfig;
public static ConfigEntry<bool> NearCollissionDetectionEnabledConfig;
public static ConfigEntry<bool> EvadeJumpEnabledConfig;
public static ConfigEntry<float> MountSpeedModifierFactorConfig;
public static ConfigEntry<float> MountSpeedGroupModifierFactorConfig;
public static ConfigEntry<float> MaxMountSpeedGroupModifierFactorConfig;
public static ConfigEntry<float> MountStaminaModifierFactorConfig;
public static ConfigEntry<float> MountStaminaGroupModifierFactorConfig;
public static ConfigEntry<float> MaxMountStaminaGroupModifierFactorConfig;
public static ConfigEntry<int> FellowRiderDistanceConfig;
public static ConfigEntry<KeyboardShortcut> AutoSprintShortcut;
public static ButtonConfig AutoSprintButtonConfig;
private static Shader LegacyShader = null;
private static Material LineMaterial = null;
public static bool IsSprint = false;
public static bool IsExhausted = false;
public static Vector3 InitialMoveDir = Vector3.zero;
public static float WaterHeight = 0f;
public static LiquidVolume LiquidVolume = null;
public static Vector3 LastPos = Vector3.zero;
public static GroundType StartType = GroundType.Unknown;
public static string[] mask_default = new string[9] { "piece", "terrain", "piece_nonsolid", "static_solid", "Default", "vehicle", "pathblocker", "character", "Default_small" };
public static string[] mask_riding = new string[7] { "piece", "terrain", "piece_nonsolid", "static_solid", "Default", "vehicle", "pathblocker" };
private float m_updateTimer;
private readonly Harmony harmony = new Harmony("org.bepinex.plugins.bid.autofollowpath");
public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization();
private static SortedList<float, SortedList<int, DebugObject>> rayCasts = new SortedList<float, SortedList<int, DebugObject>>();
private static List<LineRenderer> lineRendrerList = new List<LineRenderer>();
private static List<GameObject> textList = new List<GameObject>();
public static Character m_mount = null;
public static int m_fellowRiderCount = 0;
private static bool IsPath(Color color)
{
//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_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
if (ColorsAreEqual(color, Heightmap.m_paintMaskPaved))
{
return true;
}
if (PavedOnlyConfig.Value)
{
return false;
}
if (ColorsAreEqual(color, Heightmap.m_paintMaskDirt))
{
return true;
}
return false;
}
private static bool ColorsAreEqual(Color color1, Color color2)
{
//IL_000b: 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_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: 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)
//IL_004a: 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)
float value = PathToleranceConfig.Value;
if (Mathf.Abs(color1.r - color2.r) <= value && Mathf.Abs(color1.g - color2.g) <= value && Mathf.Abs(color1.b - color2.b) <= value)
{
return Mathf.Abs(color1.a - color2.a) <= value;
}
return false;
}
private static bool CollissionDetected(Vector3 targetPosition, float lastHeight, float targetHeight, Vector3 lastPosition, Vector3 direction, float pathLength, out float heightDiff, DebugObject dobj)
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: 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_0056: 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)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: 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_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: 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_00a3: 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_00a7: 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_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: 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_018b: 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_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: 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_026d: 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_0275: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_027b: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
//IL_0224: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: Unknown result type (might be due to invalid IL or missing references)
//IL_0326: Unknown result type (might be due to invalid IL or missing references)
//IL_032b: Unknown result type (might be due to invalid IL or missing references)
//IL_0364: Unknown result type (might be due to invalid IL or missing references)
//IL_0369: Unknown result type (might be due to invalid IL or missing references)
//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
int mask = LayerMask.GetMask(mask_default);
if (IsRiding())
{
mask = LayerMask.GetMask(mask_riding);
}
heightDiff = 0f;
float value = RaycastHeightConfig.Value;
lastPosition.y = lastHeight + value;
targetPosition.y = targetHeight + value;
direction = targetPosition - lastPosition;
((Vector3)(ref direction)).Normalize();
pathLength = Vector3.Distance(lastPosition, targetPosition);
RaycastHit val = default(RaycastHit);
bool flag = Physics.Raycast(lastPosition, direction, ref val, pathLength, mask);
Vector3 val2 = targetPosition;
if (flag)
{
val2 = ((RaycastHit)(ref val)).point;
}
val2.y += CollissionHeightIncreaseConfig.Value;
val2 += direction * 0.005f;
RaycastHit val3 = default(RaycastHit);
bool num = Physics.Raycast(val2, Vector3.down, ref val3, CollissionRayLengthDownConfig.Value, mask);
if (VisualDebugConfig.Value)
{
LineRenderer val4 = new GameObject("Line").AddComponent<LineRenderer>();
((Renderer)val4).material = LineMaterial;
val4.startColor = Color.black;
val4.endColor = Color.black;
val4.startWidth = 0.02f;
val4.endWidth = 0.02f;
val4.positionCount = 2;
val4.useWorldSpace = true;
val4.SetPosition(0, val2);
val4.SetPosition(1, val2 + Vector3.down * CollissionRayLengthDownConfig.Value);
lineRendrerList.Add(val4);
}
if (!num)
{
dobj.slopeError = true;
dobj.target.y -= CollissionRayLengthDownConfig.Value;
return true;
}
if (((RaycastHit)(ref val3)).point.y < ((RaycastHit)(ref val)).point.y)
{
((RaycastHit)(ref val3)).point = val2;
}
heightDiff = ((RaycastHit)(ref val3)).point.y - (lastPosition.y - value);
float num2 = pathLength;
if (flag)
{
num2 = ((RaycastHit)(ref val)).distance;
}
if ((((Component)((RaycastHit)(ref val3)).collider).gameObject.layer != 11 || !((Character)Player.m_localPlayer).m_running || heightDiff < -0.5f) && heightDiff != 0f && num2 / Math.Abs(heightDiff) < MaxInclineConfig.Value)
{
dobj.target = ((RaycastHit)(ref val3)).point;
dobj.targetHeight = dobj.target.y;
if (heightDiff < 0f)
{
dobj.slopeError = true;
}
return true;
}
if (((Component)((RaycastHit)(ref val3)).collider).gameObject.layer == 11)
{
Heightmap h;
Color color = (dobj.targetColor = GetHitColor(targetPosition, out h));
float num3 = default(float);
Heightmap.GetHeight(targetPosition, ref num3);
if ((Object)(object)h != (Object)null && h.GetLava(targetPosition) > 0.2f)
{
dobj.colorError = true;
return true;
}
if (num3 <= GetLiquidHeight(targetPosition))
{
dobj.colorError = true;
return true;
}
if (num3 + ((Character)Player.m_localPlayer).m_swimDepth / 2f <= WaterHeight)
{
dobj.colorError = true;
return true;
}
if (StartType == GroundType.Path && !IsPath(color))
{
dobj.colorError = true;
return true;
}
return false;
}
if ((Object)(object)((Component)((RaycastHit)(ref val3)).collider).gameObject.GetComponentInParent<Piece>() == (Object)null && StartType == GroundType.Path)
{
dobj.target = ((RaycastHit)(ref val3)).point;
dobj.targetHeight = dobj.target.y;
dobj.slopeError = true;
return true;
}
if (StartType == GroundType.Terrain && !((Character)Player.m_localPlayer).m_running)
{
dobj.target = ((RaycastHit)(ref val3)).point;
dobj.targetHeight = dobj.target.y;
dobj.slopeError = true;
return true;
}
return false;
}
private static float CountPathWeight(Vector3 startPoint, Vector3 direction, float angle, out DebugObject dobj, int to = 0, bool isCheck = false)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: 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_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: 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_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: 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_023a: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Unknown result type (might be due to invalid IL or missing references)
int num = to;
int value = PathPointsConfig.Value;
if (num == 0)
{
num = PathPointsConfig.Value;
if (IsRiding() && !isCheck)
{
num = (int)((float)num * RidingDistanceFactorConfig.Value);
}
}
float num2 = 0f;
float num3 = (float)PathPointsConfig.Value / (float)value;
Vector3 lastPosition = startPoint;
float y = startPoint.y;
float lastHeight = y;
float num4 = 0f;
dobj = new DebugObject();
if (isCheck)
{
num3 *= NearCollissionDetectionLengthScaleConfig.Value;
}
int i;
for (i = 1; i <= num; i++)
{
Vector3 val = startPoint + direction * ((float)i * num3);
y = (val.y += num4);
dobj = new DebugObject();
if (isCheck)
{
dobj.isCheck = true;
}
dobj.target = val;
dobj.weight = 0f;
dobj.targetHeight = y;
if (CollissionDetected(val, lastHeight, y, lastPosition, direction, num3, out var heightDiff, dobj))
{
if (VisualDebugConfig.Value)
{
if (!dobj.slopeError && !dobj.colorError)
{
dobj.collission = true;
}
if (rayCasts[angle].ContainsKey(i))
{
rayCasts[angle].Remove(i);
}
rayCasts[angle].Add(i, dobj);
}
break;
}
dobj.target.y += heightDiff;
y += heightDiff;
num4 += heightDiff;
float num5 = Mathf.Clamp01(1f - Mathf.Abs(Vector3.Angle(direction, ((Component)Player.m_localPlayer).transform.forward)) / (float)MaxAngleConfig.Value * AngleWeightFactorConfig.Value);
float num6 = Mathf.Clamp01(1f - (float)i * num3 / (float)MaxDistanceConfig.Value * DistanceWeightFactorConfig.Value);
num2 += num5 + num6;
if (VisualDebugConfig.Value)
{
dobj.weight = num2;
if (rayCasts[angle].ContainsKey(i))
{
rayCasts[angle].Remove(i);
}
rayCasts[angle].Add(i, dobj);
}
lastHeight = y;
lastPosition = val;
}
return i;
}
public static bool IsRiding(IDoodadController dobj = null)
{
if (dobj == null)
{
dobj = Player.m_localPlayer.m_doodadController;
}
if (dobj == null)
{
return false;
}
if (dobj is Sadle)
{
return true;
}
return false;
}
private static Vector3 GetStartPoint(out Vector3 lookDir)
{
//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_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
StartType = GroundType.Unknown;
Vector3 position = ((Component)Player.m_localPlayer).transform.position;
lookDir = ((Component)Player.m_localPlayer).transform.forward;
if (IsRiding())
{
Component controlledComponent = Player.m_localPlayer.m_doodadController.GetControlledComponent();
position = controlledComponent.transform.position;
lookDir = controlledComponent.transform.forward;
}
Vector3 val = position;
val.y += 0.1f;
RaycastHit val2 = default(RaycastHit);
if (Physics.Raycast(val, Vector3.down, ref val2, CollissionRayLengthDownConfig.Value, LayerMask.GetMask(mask_default)))
{
position.y = ((RaycastHit)(ref val2)).point.y;
if (((Component)((RaycastHit)(ref val2)).collider).gameObject.layer == 11)
{
StartType = GroundType.Terrain;
if (IsPath(GetHitColor(((RaycastHit)(ref val2)).point, out var _)))
{
StartType = GroundType.Path;
}
}
else if ((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<Piece>() != (Object)null)
{
StartType = GroundType.Path;
}
}
if (InitialMoveDir != Vector3.zero && StartType == GroundType.Terrain)
{
lookDir = InitialMoveDir;
}
return position;
}
private static Vector3 CalculateMoveDir()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: 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_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: 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_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: 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)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: 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_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
Vector3 lookDir;
Vector3 startPoint = GetStartPoint(out lookDir);
Vector3 val = lookDir;
float num = 0f;
float angle = 0f;
DebugObject debugObject = null;
int num2 = PathPointsConfig.Value;
rayCasts.Clear();
if (IsRiding())
{
num2 = (int)((float)num2 * RidingDistanceFactorConfig.Value);
}
float num3 = (float)MaxAngleConfig.Value / (float)NumAnglesConfig.Value;
for (int i = 0; i < NumAnglesConfig.Value; i++)
{
for (int j = -1; j <= 1; j += 2)
{
float num4 = (float)i * num3 * (float)j;
Vector3 val2 = Quaternion.Euler(0f, num4, 0f) * lookDir;
val2.y = 0f;
((Vector3)(ref val2)).Normalize();
if (VisualDebugConfig.Value)
{
rayCasts.Add(num4, new SortedList<int, DebugObject>());
}
DebugObject dobj;
float num5 = CountPathWeight(startPoint, val2, num4, out dobj);
if (num5 > num)
{
num = num5;
val = val2;
angle = num4;
debugObject = dobj;
if (num > (float)num2)
{
break;
}
}
if (i == 0)
{
break;
}
}
if (num > (float)num2)
{
break;
}
}
if (val == lookDir && debugObject.colorError)
{
CheckPath(startPoint, val, angle);
return lookDir;
}
return CheckPath(startPoint, val, angle);
}
private static Vector3 CalcDirection(Vector3 direction, float angle)
{
//IL_000b: 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_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)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
Vector3 result = Quaternion.Euler(0f, angle, 0f) * direction;
result.y = 0f;
((Vector3)(ref result)).Normalize();
return result;
}
private static Vector3 CheckPath(Vector3 startPoint, Vector3 direction, float angle)
{
//IL_002a: 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)
//IL_0032: 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_0039: 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_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: 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_008f: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: 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_0100: Unknown result type (might be due to invalid IL or missing references)
if (!NearCollissionDetectionEnabledConfig.Value)
{
return direction;
}
float num = -1f * NearCollissionDetectionAngleConfig.Value;
float value = NearCollissionDetectionAngleConfig.Value;
Vector3 direction2 = CalcDirection(direction, num);
Vector3 direction3 = CalcDirection(direction, value);
if (VisualDebugConfig.Value)
{
if (!rayCasts.ContainsKey(num))
{
rayCasts.Add(num, new SortedList<int, DebugObject>());
}
if (!rayCasts.ContainsKey(value))
{
rayCasts.Add(value, new SortedList<int, DebugObject>());
}
}
DebugObject dobj;
float num2 = CountPathWeight(startPoint, direction2, num, out dobj, 1, isCheck: true);
float num3 = CountPathWeight(startPoint, direction3, value, out dobj, 1, isCheck: true);
if (num2 <= 1f && num3 > 1f)
{
return CalcDirection(direction, angle + NearCollissionCorrectionAngleConfig.Value);
}
if (num3 <= 1f && num2 > 1f)
{
return CalcDirection(direction, angle - NearCollissionCorrectionAngleConfig.Value);
}
if (num3 <= 1f && num2 <= 1f)
{
return CalcDirection(direction, angle - 180f);
}
return direction;
}
private static Color GetHitColor(Vector3 point, out Heightmap h)
{
//IL_0006: 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_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: 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_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
List<Heightmap> list = new List<Heightmap>();
Heightmap.FindHeightmap(point, HeightmapSearchRadiusConfig.Value, list);
Color val = Heightmap.m_paintMaskNothing;
h = null;
int num = default(int);
int num2 = default(int);
foreach (Heightmap item in list)
{
item.WorldToVertex(point, ref num, ref num2);
val = item.GetPaintMask(num, num2);
h = item;
if (IsPath(val))
{
return val;
}
}
return val;
}
private void Awake()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
Logger.LogInfo((object)"AutoFollowPath has landed");
CreateConfigValues();
AddInputs();
new Harmony("org.bepinex.plugins.bid.autofollowpath").PatchAll();
CreatureManager.OnVanillaCreaturesAvailable += ModifyAndCloneVanillaCreatures;
}
private void OnDestroy()
{
harmony.UnpatchSelf();
}
private void AddInputs()
{
//IL_001a: 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_0034: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: 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_005f: 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_0072: Expected O, but got Unknown
AutoSprintShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Client config", "AutoSprint", new KeyboardShortcut((KeyCode)304, Array.Empty<KeyCode>()), new ConfigDescription("keycode to toggle sprint", (AcceptableValueBase)null, Array.Empty<object>()));
AutoSprintButtonConfig = new ButtonConfig
{
Name = "AutoSprint",
ShortcutConfig = AutoSprintShortcut,
HintToken = "sprint",
ActiveInCustomGUI = true,
ActiveInGUI = true
};
InputManager.Instance.AddButton("org.bepinex.plugins.bid.autofollowpath", AutoSprintButtonConfig);
}
private void CreateConfigValues()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Expected O, but got Unknown
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Expected O, but got Unknown
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Expected O, but got Unknown
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Expected O, but got Unknown
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Expected O, but got Unknown
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Expected O, but got Unknown
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Expected O, but got Unknown
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Expected O, but got Unknown
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Expected O, but got Unknown
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Expected O, but got Unknown
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Expected O, but got Unknown
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Expected O, but got Unknown
//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
//IL_02ab: Expected O, but got Unknown
//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
//IL_02da: Expected O, but got Unknown
//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0309: Expected O, but got Unknown
//IL_032e: Unknown result type (might be due to invalid IL or missing references)
//IL_0338: Expected O, but got Unknown
//IL_035d: Unknown result type (might be due to invalid IL or missing references)
//IL_0367: Expected O, but got Unknown
//IL_038c: Unknown result type (might be due to invalid IL or missing references)
//IL_0396: Expected O, but got Unknown
//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
//IL_03c5: Expected O, but got Unknown
//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
//IL_03f4: Expected O, but got Unknown
//IL_0415: Unknown result type (might be due to invalid IL or missing references)
//IL_041f: Expected O, but got Unknown
//IL_0440: Unknown result type (might be due to invalid IL or missing references)
//IL_044a: Expected O, but got Unknown
//IL_0472: Unknown result type (might be due to invalid IL or missing references)
//IL_0477: Unknown result type (might be due to invalid IL or missing references)
//IL_047f: Expected O, but got Unknown
//IL_047f: Unknown result type (might be due to invalid IL or missing references)
//IL_0489: Expected O, but got Unknown
//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
//IL_04be: Expected O, but got Unknown
//IL_04be: Unknown result type (might be due to invalid IL or missing references)
//IL_04c8: Expected O, but got Unknown
//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
//IL_04fa: Expected O, but got Unknown
//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0504: Expected O, but got Unknown
//IL_052c: Unknown result type (might be due to invalid IL or missing references)
//IL_0531: Unknown result type (might be due to invalid IL or missing references)
//IL_0539: Expected O, but got Unknown
//IL_0539: Unknown result type (might be due to invalid IL or missing references)
//IL_0543: Expected O, but got Unknown
//IL_056b: Unknown result type (might be due to invalid IL or missing references)
//IL_0570: Unknown result type (might be due to invalid IL or missing references)
//IL_0578: Expected O, but got Unknown
//IL_0578: Unknown result type (might be due to invalid IL or missing references)
//IL_0582: Expected O, but got Unknown
//IL_05aa: Unknown result type (might be due to invalid IL or missing references)
//IL_05af: Unknown result type (might be due to invalid IL or missing references)
//IL_05b7: Expected O, but got Unknown
//IL_05b7: Unknown result type (might be due to invalid IL or missing references)
//IL_05c1: Expected O, but got Unknown
//IL_05e9: Unknown result type (might be due to invalid IL or missing references)
//IL_05ee: Unknown result type (might be due to invalid IL or missing references)
//IL_05f6: Expected O, but got Unknown
//IL_05f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0600: Expected O, but got Unknown
((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
GlobalSprintToggleConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Client config", "GlobalSprintToggle", false, new ConfigDescription("Only sprint in autorun mode, or also in normal run mode (global)", (AcceptableValueBase)null, Array.Empty<object>()));
StaminaMinThresholdConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Client config", "StaminaMinThreshold", 30f, new ConfigDescription("Stop sprinting if stamina is below this value", (AcceptableValueBase)null, Array.Empty<object>()));
UpdateTimeMillisConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Client config", "UpdateMillis", 200, new ConfigDescription("Update direction every x milliseconds", (AcceptableValueBase)null, Array.Empty<object>()));
MaxAngleConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Client config", "MaxAngle", 90, new ConfigDescription("Max angle to look for a path", (AcceptableValueBase)null, Array.Empty<object>()));
NumAnglesConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Client config", "NumAngles", 10, new ConfigDescription("Number of angles to check a path between current forward direction and MaxAngle", (AcceptableValueBase)null, Array.Empty<object>()));
MaxDistanceConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Client config", "MaxDistance", 8, new ConfigDescription("Max distance ahead of player to check for a path per angle", (AcceptableValueBase)null, Array.Empty<object>()));
PathPointsConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Client config", "PathPoints", 10, new ConfigDescription("Number of points to check between player position and MaxDistance per angle", (AcceptableValueBase)null, Array.Empty<object>()));
PathToleranceConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Client config", "PathTolerance", 0.3f, new ConfigDescription("Tolerance a point is still considered a path (0-1)", (AcceptableValueBase)null, Array.Empty<object>()));
AngleWeightFactorConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Client config", "AngleWeightFactor", 0.3f, new ConfigDescription("weight higher angles less (0-1)", (AcceptableValueBase)null, Array.Empty<object>()));
MaxInclineConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Client config", "MaxInclineRatio", 1f, new ConfigDescription("maximum ratio forward/height", (AcceptableValueBase)null, Array.Empty<object>()));
DistanceWeightFactorConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Client config", "DistanceWeightFactor", 0.5f, new ConfigDescription("weight path farer away less (0-1)", (AcceptableValueBase)null, Array.Empty<object>()));
PavedOnlyConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Client config", "PavedOnly", false, new ConfigDescription("Only consider paved roads as paths", (AcceptableValueBase)null, Array.Empty<object>()));
EnabledConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Client config", "enabled", true, new ConfigDescription("enable or disable the mod", (AcceptableValueBase)null, Array.Empty<object>()));
VisualDebugConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Client config", "VisualDebug", false, new ConfigDescription("enable or disable visual debugging", (AcceptableValueBase)null, Array.Empty<object>()));
HeightmapSearchRadiusConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Client config", "HeightmapSearchRadius", 0.5f, new ConfigDescription("radius to look for heightmaps (internal)", (AcceptableValueBase)null, Array.Empty<object>()));
RaycastHeightConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Client config", "RaycastHeight", 0.5f, new ConfigDescription("height of the raycast for horizontal collission detection", (AcceptableValueBase)null, Array.Empty<object>()));
CollissionHeightIncreaseConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Client config", "CollissionHeightIncrease", 1.25f, new ConfigDescription("height of the vertical collission detectcion line = hitpoint height + CollissionHeightIncrease ", (AcceptableValueBase)null, Array.Empty<object>()));
CollissionRayLengthDownConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Client config", "CollissonRayLengthDown", 4f, new ConfigDescription("length of the vertical raycast for collission detection going down", (AcceptableValueBase)null, Array.Empty<object>()));
NearCollissionDetectionAngleConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Client config", "NearCollissionDetectionAngle", 30f, new ConfigDescription("angle for near collission detection", (AcceptableValueBase)null, Array.Empty<object>()));
NearCollissionCorrectionAngleConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Client config", "NearCollissionCorrectionAngle", 30f, new ConfigDescription("if near collissin is detected, correct found path by this angle", (AcceptableValueBase)null, Array.Empty<object>()));
NearCollissionDetectionLengthScaleConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Client config", "NearCollissionDetectionLengthScale", 1f, new ConfigDescription("scale factor of the length of the near collission detection ray", (AcceptableValueBase)null, Array.Empty<object>()));
RidingDistanceFactorConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Client config", "RidingDistanceFactor", 2f, new ConfigDescription("increase MaxDistance by this multiplier when riding", (AcceptableValueBase)null, Array.Empty<object>()));
NearCollissionDetectionEnabledConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Client config", "NearCollissionDetectionEnabledDeprecated", false, new ConfigDescription("Near collission detection enabled (replaced by evade jump)", (AcceptableValueBase)null, Array.Empty<object>()));
EvadeJumpEnabledConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Client config", "EvadeJumpEnabled", true, new ConfigDescription("Jump if stuck somewhere - if disabled, enable NearCollissionDetectionEnabledDeprecated instead.", (AcceptableValueBase)null, Array.Empty<object>()));
MountSpeedModifierFactorConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Server config", "MountSpeedBaseModifier", 1f, new ConfigDescription("Mount run speed base modifier factor", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true
} }));
MountStaminaModifierFactorConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Server config", "MountStaminaUsageBaseModifier", 1f, new ConfigDescription("Stamina usage modifier factor for mounts", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true
} }));
FellowRiderDistanceConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Server config", "FellowRiderDistance", 70, new ConfigDescription("Radius to search fellow riders", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true
} }));
MountSpeedGroupModifierFactorConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Server config", "MountSpeedGroupModifier", 0.1f, new ConfigDescription("Modify mount speed per fellow rider", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true
} }));
MaxMountSpeedGroupModifierFactorConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Server config", "MaxMountSpeedGroupModifier", 1f, new ConfigDescription("Maximum mount speed group bonus", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true
} }));
MountStaminaGroupModifierFactorConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Server config", "MountStaminaUsageGroupModifier", 0.1f, new ConfigDescription("Modify stamina usage per fellow rider", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true
} }));
MaxMountStaminaGroupModifierFactorConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Server config", "MaxMountStaminaUsageGroupModifier", 0.9f, new ConfigDescription("Maximum stamina usage group reduction", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true
} }));
}
public static float GetWaterHeight(Vector3 position)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
int mask = LayerMask.GetMask(new string[1] { "WaterVolume" });
Collider[] array = Physics.OverlapSphere(position, 2f, mask);
float result = 0f;
Collider[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
WaterVolume component = ((Component)array2[i]).GetComponent<WaterVolume>();
if ((Object)(object)component != (Object)null)
{
result = component.GetWaterSurface(position, 1f);
break;
}
}
return result;
}
public static LiquidVolume GetLiquidVolume(Vector3 position)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
int mask = LayerMask.GetMask(new string[1] { "WaterVolume" });
Collider[] array = Physics.OverlapSphere(position, 2f, mask);
for (int i = 0; i < array.Length; i++)
{
Transform parent = ((Component)array[i]).transform.parent;
LiquidVolume val = ((parent != null) ? ((Component)parent).GetComponentInChildren<LiquidVolume>() : null);
if ((Object)(object)val != (Object)null)
{
return val;
}
}
return null;
}
public static float GetLiquidHeight(Vector3 position)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)LiquidVolume == (Object)null)
{
return 0f;
}
return LiquidVolume.GetSurface(position);
}
private static void VisualDebug()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: 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)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: 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_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_0237: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
CalculateMoveDir();
foreach (KeyValuePair<float, SortedList<int, DebugObject>> rayCast in rayCasts)
{
Vector3 lookDir;
Vector3 val = GetStartPoint(out lookDir);
if (Player.m_localPlayer.m_doodadController != null)
{
val = Player.m_localPlayer.m_doodadController.GetControlledComponent().transform.position;
}
val.y += RaycastHeightConfig.Value;
foreach (KeyValuePair<int, DebugObject> item in rayCast.Value)
{
Vector3 target = item.Value.target;
if (!item.Value.collission)
{
target.y += RaycastHeightConfig.Value;
}
LineRenderer val2 = new GameObject("Line").AddComponent<LineRenderer>();
((Renderer)val2).material = LineMaterial;
val2.startColor = Color.green;
val2.endColor = Color.green;
val2.startWidth = 0.02f;
val2.endWidth = 0.02f;
val2.positionCount = 2;
val2.useWorldSpace = true;
if (item.Value.colorError)
{
val2.startColor = Color.red;
val2.endColor = Color.red;
}
if (item.Value.slopeError)
{
val2.startColor = Color.magenta;
val2.endColor = Color.magenta;
}
if (item.Value.collission)
{
val2.startColor = Color.blue;
val2.endColor = Color.blue;
}
if (item.Value.succeeded)
{
val2.startWidth = 0.05f;
val2.endWidth = 0.05f;
}
if (item.Value.isCheck)
{
val2.startColor = Color.yellow;
val2.endColor = Color.yellow;
if (item.Value.collission)
{
val2.startWidth = 0.04f;
val2.endWidth = 0.04f;
val2.startColor = new Color(1f, 0.271f, 0f);
val2.endColor = new Color(1f, 0.271f, 0f);
}
}
val2.SetPosition(0, val);
val2.SetPosition(1, target);
val = target;
lineRendrerList.Add(val2);
}
}
}
private int GetFellowRiderCount()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
int num = 0;
int mask = LayerMask.GetMask(new string[2] { "character", "character_net" });
Collider[] array = Physics.OverlapSphere(((Component)Player.m_localPlayer).transform.position, (float)FellowRiderDistanceConfig.Value, mask);
for (int i = 0; i < array.Length; i++)
{
Sadle componentInChildren = ((Component)array[i]).GetComponentInChildren<Sadle>();
if (!((Object)(object)componentInChildren == (Object)null) && componentInChildren.GetUser() != 0L)
{
num++;
}
}
return num - 1;
}
private void Update()
{
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: 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_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
if (!EnabledConfig.Value)
{
return;
}
foreach (LineRenderer lineRendrer in lineRendrerList)
{
Object.Destroy((Object)(object)lineRendrer);
}
foreach (GameObject text in textList)
{
Object.Destroy((Object)(object)text);
}
lineRendrerList.Clear();
textList.Clear();
if ((Object)(object)Player.m_localPlayer != (Object)null && VisualDebugConfig.Value)
{
VisualDebug();
}
if (!((Object)(object)Player.m_localPlayer != (Object)null) || ((Character)Player.m_localPlayer).IsDebugFlying() || (!Player.m_localPlayer.m_autoRun && !IsRiding()))
{
return;
}
if (ZInput.GetMouseButtonDown(1) || ZInput.GetMouseButtonUp(1))
{
InitialMoveDir = ((Character)Player.m_localPlayer).m_lookDir;
}
m_updateTimer -= Time.fixedDeltaTime;
if (!(m_updateTimer < 0f))
{
return;
}
WaterHeight = GetWaterHeight(((Component)Player.m_localPlayer).transform.position);
LiquidVolume = GetLiquidVolume(((Component)Player.m_localPlayer).transform.position);
if (LastPos != Vector3.zero)
{
Vector3 val = LastPos - ((Component)Player.m_localPlayer).transform.position;
float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
if (EvadeJumpEnabledConfig.Value && sqrMagnitude < 0.02f && Player.m_localPlayer.m_stamina > StaminaMinThresholdConfig.Value)
{
((Character)Player.m_localPlayer).Jump(true);
}
}
Vector3 val2 = CalculateMoveDir();
m_mount = null;
m_fellowRiderCount = GetFellowRiderCount();
IDoodadController doodadController = Player.m_localPlayer.m_doodadController;
if (doodadController != null)
{
if (doodadController is Sadle)
{
Sadle val3 = (Sadle)doodadController;
m_mount = val3.m_character;
val3.m_controlDir = val2;
}
}
else
{
((Character)Player.m_localPlayer).m_moveDir = val2;
}
m_updateTimer = (float)UpdateTimeMillisConfig.Value / 1000f;
LastPos = ((Component)Player.m_localPlayer).transform.position;
}
private void ModifyAndCloneVanillaCreatures()
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
Shader[] array = Resources.FindObjectsOfTypeAll<Shader>();
foreach (Shader val in array)
{
if (((Object)val).name == "Legacy Shaders/Particles/Alpha Blended Premultiply")
{
LegacyShader = val;
break;
}
}
if ((Object)(object)LegacyShader == (Object)null)
{
MonoBehaviour.print((object)"legacy shader not found");
}
else
{
LineMaterial = new Material(LegacyShader);
}
CreatureManager.OnVanillaCreaturesAvailable -= ModifyAndCloneVanillaCreatures;
}
}
}
namespace AutoFollowPath.Patches
{
[HarmonyPatch(typeof(Player), "SetControls")]
public class Player_SetControls_patch
{
private static void Prefix(Player __instance, ref bool run, Vector3 movedir, bool autoRun)
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: 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_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
if (AutoFollowPath.IsSprint && (AutoFollowPath.GlobalSprintToggleConfig.Value || __instance.m_autoRun))
{
if (AutoFollowPath.IsExhausted && __instance.m_stamina >= __instance.m_maxStamina)
{
AutoFollowPath.IsExhausted = false;
}
if (!AutoFollowPath.IsExhausted && __instance.m_stamina > AutoFollowPath.StaminaMinThresholdConfig.Value)
{
run = true;
}
else
{
AutoFollowPath.IsExhausted = true;
}
}
if (autoRun)
{
if (AutoFollowPath.InitialMoveDir == Vector3.zero)
{
AutoFollowPath.InitialMoveDir = ((Character)__instance).m_lookDir;
}
}
else if (!__instance.m_autoRun && !AutoFollowPath.IsRiding())
{
AutoFollowPath.InitialMoveDir = Vector3.zero;
AutoFollowPath.LastPos = Vector3.zero;
}
}
}
[HarmonyPatch(typeof(Player), "Update")]
public class Player_Update_patch
{
private static void Prefix(Player __instance)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
KeyboardShortcut value = AutoFollowPath.AutoSprintShortcut.Value;
if ((((KeyboardShortcut)(ref value)).IsDown() || ZInput.GetButtonDown(AutoFollowPath.AutoSprintButtonConfig.Name)) && (AutoFollowPath.GlobalSprintToggleConfig.Value || __instance.m_autoRun))
{
if (AutoFollowPath.IsSprint)
{
AutoFollowPath.IsExhausted = false;
}
AutoFollowPath.IsSprint = !AutoFollowPath.IsSprint;
}
}
}
[HarmonyPatch(typeof(Sadle), "UseStamina")]
internal class Sadle_UseStamina_patch
{
private static void Prefix(ref float v)
{
v *= AutoFollowPath.MountStaminaModifierFactorConfig.Value;
float num = AutoFollowPath.MountStaminaGroupModifierFactorConfig.Value * (float)AutoFollowPath.m_fellowRiderCount;
if (num > AutoFollowPath.MaxMountStaminaGroupModifierFactorConfig.Value)
{
num = AutoFollowPath.MountStaminaGroupModifierFactorConfig.Value;
}
v *= 1f - num;
}
}
[HarmonyPatch(typeof(Sadle), "ApplyControlls")]
internal class Sadle_ApplyControlls_patch
{
private static void Prefix(Vector3 moveDir, Vector3 lookDir, bool run, bool autoRun, bool block, ref Sadle __instance)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: 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)
if (moveDir.z > 0f)
{
AutoFollowPath.InitialMoveDir = lookDir;
}
}
}
[HarmonyPatch(typeof(Character), "GetRunSpeedFactor")]
internal class Character_GetRunSpeedFactor_patch
{
private static void Postfix(Character __instance, ref float __result)
{
if ((Object)(object)__instance == (Object)(object)AutoFollowPath.m_mount && __instance.HaveRider())
{
__result *= AutoFollowPath.MountSpeedModifierFactorConfig.Value;
float num = AutoFollowPath.MountSpeedGroupModifierFactorConfig.Value * (float)AutoFollowPath.m_fellowRiderCount;
if (num > AutoFollowPath.MaxMountSpeedGroupModifierFactorConfig.Value)
{
num = AutoFollowPath.MaxMountSpeedGroupModifierFactorConfig.Value;
}
__result *= 1f + num;
}
}
}
}