Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of REPOCompanions v1.0.0
plugins/REPOCompanions.dll
Decompiled a year agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("BellaModsGames")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("REPOCompanions")] [assembly: AssemblyTitle("REPOCompanions")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace REPOCompanionsMod { [BepInPlugin("com.BellaModsGames.REPOCompanions", "REPO Companions", "1.0.0")] [BepInProcess("repo.exe")] public class REPOCompanionsMod : BaseUnityPlugin { [HarmonyPatch(typeof(PlayerController))] private class PlayerControllerPatches { [HarmonyPatch("Update")] [HarmonyPostfix] private static void Update_Postfix(PlayerController __instance) { //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_0025: Unknown result type (might be due to invalid IL or missing references) if (SpawnKey == null || StaticLogger == null) { return; } KeyCode value = SpawnKey.Value; if (Input.GetKeyDown(value)) { if ((Object)(object)__instance != (Object)null) { SpawnCompanion(__instance); } else { StaticLogger.LogError((object)"Calling SpawnCompanion but PlayerController instance (__instance) is NULL!"); } } } } public static ConfigEntry<KeyCode>? SpawnKey; public static ConfigEntry<int>? CompanionIndex; public static ConfigEntry<float>? FollowDistance; public static ConfigEntry<float>? FollowSpeed; public static ConfigEntry<float>? TeleportDistance; public static ConfigEntry<float>? RotationSpeed; public static ConfigEntry<float>? GroundOffset; private const int MAX_COMPANION_INDEX = 50; private const string COMPANION_BASENAME = "companion_"; private const string CompanionPrefabName = "CompanionPrefab"; public static GameObject? currentCompanionInstance; private const string GUID = "com.BellaModsGames.REPOCompanions"; public static ManualLogSource? StaticLogger { get; private set; } private void Awake() { //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Expected O, but got Unknown StaticLogger = Logger.CreateLogSource("REPOCompanions"); SpawnKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "Spawn Key", (KeyCode)99, "Key to spawn the selected companion."); CompanionIndex = ((BaseUnityPlugin)this).Config.Bind<int>("Selection", "Companion Index", 1, $"Select the index (1-{50}) for the companion bundle."); FollowDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Behaviour", "Follow Distance", 3f, "How close the companion will try to stay."); FollowSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Behaviour", "Follow Speed", 5f, "Movement speed (units per second)."); TeleportDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Behaviour", "Teleport Distance", 25f, "Distance to trigger teleport."); RotationSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Behaviour", "Rotation Speed", 8f, "Turning speed (higher is faster)."); GroundOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Behaviour", "Ground Offset", 0.1f, "How far above detected ground to float."); StaticLogger.LogInfo((object)"Configuration bound."); try { Harmony val = new Harmony("com.BellaModsGames.REPOCompanions"); val.PatchAll(); StaticLogger.LogInfo((object)"Harmony patches applied using ID: com.BellaModsGames.REPOCompanions"); } catch (Exception arg) { StaticLogger.LogError((object)$"Harmony patching failed: {arg}"); } StaticLogger.LogInfo((object)$"REPO Companions v{((BaseUnityPlugin)this).Info.Metadata.Version} initialized."); } public static void SpawnCompanion(PlayerController player) { //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0278: 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_0283: Unknown result type (might be due to invalid IL or missing references) if (StaticLogger == null) { Logger.CreateLogSource("REPOCompanions_Spawn").LogError((object)"SpawnCompanion ERROR: StaticLogger is NULL!"); return; } if ((Object)(object)player == (Object)null) { StaticLogger.LogError((object)"PlayerController NULL!"); return; } if (CompanionIndex == null) { StaticLogger.LogError((object)"CompanionIndex NULL!"); return; } int value = CompanionIndex.Value; if (value <= 0 || value > 50) { StaticLogger.LogError((object)$"Index {value} invalid."); return; } string text = string.Format("{0}{1}", "companion_", value); string text2 = null; GameObject val = null; AssetBundle val2 = null; string text3 = ""; try { string location = Assembly.GetExecutingAssembly().Location; text2 = Path.GetDirectoryName(location); if (string.IsNullOrEmpty(text2)) { StaticLogger.LogError((object)"Could not get plugin directory."); return; } text3 = Path.Combine(text2, text); if (!File.Exists(text3)) { StaticLogger.LogError((object)("Bundle file not found: '" + text3 + "'")); return; } val2 = AssetBundle.LoadFromFile(text3); if ((Object)(object)val2 == (Object)null) { StaticLogger.LogError((object)("Failed to load bundle: '" + text3 + "'")); return; } val = val2.LoadAsset<GameObject>("CompanionPrefab"); if ((Object)(object)val == (Object)null) { StaticLogger.LogError((object)("Prefab 'CompanionPrefab' not found in '" + text + "'.")); val2.Unload(true); return; } if ((Object)(object)val.GetComponentInChildren<Animator>(true) == (Object)null) { StaticLogger.LogWarning((object)"Prefab 'CompanionPrefab' missing Animator."); } if ((Object)(object)val.GetComponentInChildren<Collider>() == (Object)null) { StaticLogger.LogWarning((object)"Prefab 'CompanionPrefab' missing Collider."); } if ((Object)(object)currentCompanionInstance != (Object)null) { Object.Destroy((Object)(object)currentCompanionInstance); currentCompanionInstance = null; } Vector3 val3 = ((Component)player).transform.position - ((Component)player).transform.forward * (FollowDistance?.Value ?? 3f) + Vector3.up * 0.5f; currentCompanionInstance = Object.Instantiate<GameObject>(val, val3, ((Component)player).transform.rotation); if ((Object)(object)currentCompanionInstance == (Object)null) { StaticLogger.LogError((object)"Object.Instantiate returned NULL!"); return; } ((Object)currentCompanionInstance).name = string.Format("{0}{1}_Instance", "companion_", value); CompanionController companionController = currentCompanionInstance.AddComponent<CompanionController>(); if ((Object)(object)companionController == (Object)null) { StaticLogger.LogError((object)"AddComponent<CompanionController> failed!"); Object.Destroy((Object)(object)currentCompanionInstance); currentCompanionInstance = null; } else { companionController.Initialize(player); StaticLogger.LogInfo((object)("Companion '" + ((Object)currentCompanionInstance).name + "' spawned.")); } } catch (Exception arg) { ManualLogSource? staticLogger = StaticLogger; if (staticLogger != null) { staticLogger.LogError((object)$"CRITICAL ERROR during Spawn Process for bundle '{text}': {arg}"); } if ((Object)(object)currentCompanionInstance != (Object)null) { Object.Destroy((Object)(object)currentCompanionInstance); currentCompanionInstance = null; } } finally { if ((Object)(object)val2 != (Object)null) { val2.Unload(false); } } } } public class CompanionController : MonoBehaviour { private PlayerController? targetPlayer; private Animator? animator; private Transform? playerTransform; private Transform? companionTransform; private Rigidbody? companionRigidbody; private float followDistance; private float followDistanceStopSqr; private float followSpeed; private float teleportDistance; private float teleportDistanceSqr; private float rotationSpeed; private float groundOffset; private float groundCheckDistance = 2f; private LayerMask groundMask; private Vector3 lastPosition; private float actualSpeed; private bool shouldBeMoving = false; private int speedParamID = -1; private const string SpeedParamName = "Speed"; public void Initialize(PlayerController player) { //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0329: 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_0075: 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_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) ManualLogSource staticLogger = REPOCompanionsMod.StaticLogger; targetPlayer = player; playerTransform = ((Component)player).transform; companionTransform = ((Component)this).transform; if ((Object)(object)companionTransform == (Object)null) { if (staticLogger != null) { staticLogger.LogError((object)("CC Initialize [" + ((Object)((Component)this).gameObject).name + "]: Failed cache transform!")); } Object.Destroy((Object)(object)this); return; } lastPosition = companionTransform.position; companionRigidbody = ((Component)this).GetComponent<Rigidbody>(); if ((Object)(object)companionRigidbody == (Object)null) { if (staticLogger != null) { staticLogger.LogWarning((object)("Companion '" + ((Object)((Component)this).gameObject).name + "' missing Rigidbody. Adding kinematic one.")); } companionRigidbody = ((Component)this).gameObject.AddComponent<Rigidbody>(); } if ((Object)(object)companionRigidbody != (Object)null) { companionRigidbody.isKinematic = true; companionRigidbody.useGravity = false; companionRigidbody.interpolation = (RigidbodyInterpolation)1; companionRigidbody.collisionDetectionMode = (CollisionDetectionMode)3; } else if (staticLogger != null) { staticLogger.LogError((object)("Failed to get or add Rigidbody to '" + ((Object)((Component)this).gameObject).name + "'!")); } if ((Object)(object)((Component)this).GetComponentInChildren<Collider>() == (Object)null) { if (staticLogger != null) { staticLogger.LogWarning((object)("Companion '" + ((Object)((Component)this).gameObject).name + "' missing Collider. Adding default CapsuleCollider.")); } CapsuleCollider val = ((Component)this).gameObject.AddComponent<CapsuleCollider>(); val.radius = 0.5f; val.height = 1f; val.center = new Vector3(0f, 0.5f, 0f); } animator = ((Component)this).GetComponentInChildren<Animator>(true); if ((Object)(object)animator == (Object)null) { if (staticLogger != null) { staticLogger.LogWarning((object)("Companion '" + ((Object)((Component)this).gameObject).name + "' missing Animator.")); } } else { speedParamID = Animator.StringToHash("Speed"); ((Behaviour)animator).enabled = true; } followDistance = REPOCompanionsMod.FollowDistance?.Value ?? 3f; followSpeed = REPOCompanionsMod.FollowSpeed?.Value ?? 5f; teleportDistance = REPOCompanionsMod.TeleportDistance?.Value ?? 25f; rotationSpeed = REPOCompanionsMod.RotationSpeed?.Value ?? 8f; groundOffset = REPOCompanionsMod.GroundOffset?.Value ?? 0.1f; followDistanceStopSqr = Mathf.Max(0.1f, followDistance * 0.9f); followDistanceStopSqr *= followDistanceStopSqr; teleportDistanceSqr = teleportDistance * teleportDistance; try { groundMask = LayerMask.op_Implicit(LayerMask.GetMask(new string[3] { "Default", "Terrain", "Environment" })); } catch { groundMask = LayerMask.op_Implicit(-5); } if (staticLogger != null) { staticLogger.LogInfo((object)("CompanionController Initialized targeting " + ((Object)player).name + ".")); } } private void Update() { //IL_003e: 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_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_007b: 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_0087: 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) //IL_008d: 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_0094: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)targetPlayer == (Object)null) && !((Object)(object)playerTransform == (Object)null) && !((Object)(object)companionTransform == (Object)null)) { Vector3 val = companionTransform.position - lastPosition; actualSpeed = ((Time.deltaTime > float.Epsilon) ? (((Vector3)(ref val)).magnitude / Time.deltaTime) : 0f); Vector3 position = playerTransform.position; Vector3 position2 = companionTransform.position; Vector3 val2 = position - position2; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; shouldBeMoving = sqrMagnitude > followDistanceStopSqr; UpdateAnimation(actualSpeed, shouldBeMoving); if (sqrMagnitude > teleportDistanceSqr) { TeleportNearPlayer(); return; } HandleMovementAndRotation(shouldBeMoving); StickToGround(); } } private void LateUpdate() { //IL_0019: 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 ((Object)(object)companionTransform != (Object)null) { lastPosition = companionTransform.position; } } private void HandleMovementAndRotation(bool moveThisFrame) { //IL_002f: 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_003b: 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) //IL_0041: 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_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_005d: 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_0066: 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_0077: 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_0079: 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) //IL_00a1: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00c9: 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_00e1: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_0158: 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_0164: 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_013d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)playerTransform == (Object)null || (Object)(object)companionTransform == (Object)null) { return; } Vector3 position = playerTransform.position; Vector3 position2 = companionTransform.position; Vector3 val = position - playerTransform.forward * followDistance; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(position.x, position2.y, position.z); Vector3 val3 = val2 - position2; val3.y = 0f; if (((Vector3)(ref val3)).sqrMagnitude > 0.01f) { Quaternion val4 = Quaternion.LookRotation(val3); companionTransform.rotation = Quaternion.Slerp(companionTransform.rotation, val4, rotationSpeed * Time.deltaTime); } if (moveThisFrame) { Vector3 val5 = val - position2; val5.y = 0f; Vector3 val6 = ((Vector3)(ref val5)).normalized * followSpeed * Time.deltaTime; if (((Vector3)(ref val6)).sqrMagnitude > ((Vector3)(ref val5)).sqrMagnitude && ((Vector3)(ref val5)).sqrMagnitude > 0.01f) { val6 = val5; } Transform? obj = companionTransform; obj.position += new Vector3(val6.x, 0f, val6.z); } } private void StickToGround() { //IL_001c: 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_0022: 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_002d: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0047: 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_0065: 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_0075: 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_007c: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00b6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)companionTransform == (Object)null) { return; } Vector3 position = companionTransform.position; Vector3 val = position + Vector3.up * 0.5f; RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val, Vector3.down, ref val2, groundCheckDistance, LayerMask.op_Implicit(groundMask), (QueryTriggerInteraction)1)) { Vector3 val3 = ((RaycastHit)(ref val2)).point + Vector3.up * groundOffset; if (Mathf.Abs(position.y - val3.y) > 0.001f) { companionTransform.position = new Vector3(position.x, val3.y, position.z); } } } private void TeleportNearPlayer() { //IL_0035: 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) //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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_006b: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_00d5: 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_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) //IL_00ad: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) ManualLogSource staticLogger = REPOCompanionsMod.StaticLogger; if (!((Object)(object)playerTransform == (Object)null) && !((Object)(object)companionTransform == (Object)null)) { Vector3 val = playerTransform.position - playerTransform.forward * followDistance + Vector3.up * 0.5f; Vector3 val2 = val; RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(val + Vector3.up, Vector3.down, ref val3, 5f, LayerMask.op_Implicit(groundMask), (QueryTriggerInteraction)1)) { val2 = ((RaycastHit)(ref val3)).point + Vector3.up * groundOffset; } companionTransform.position = val2; RotateTowardsPlayer(immediate: true); lastPosition = companionTransform.position; actualSpeed = 0f; UpdateAnimation(0f, shouldBeMovingFlag: false); if (staticLogger != null) { staticLogger.LogInfo((object)$"Teleported companion to {val2:F2}."); } } } private void RotateTowardsPlayer(bool immediate = false) { //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_004f: 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_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_006f: 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_0084: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_0099: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)playerTransform == (Object)null || (Object)(object)companionTransform == (Object)null) { return; } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(playerTransform.position.x, companionTransform.position.y, playerTransform.position.z); Vector3 val2 = val - companionTransform.position; if (((Vector3)(ref val2)).sqrMagnitude > 0.01f) { Quaternion val3 = Quaternion.LookRotation(val2); if (immediate) { companionTransform.rotation = val3; } else { companionTransform.rotation = Quaternion.Slerp(companionTransform.rotation, val3, rotationSpeed * Time.deltaTime); } } } private void UpdateAnimation(float currentActualSpeed, bool shouldBeMovingFlag) { if (!((Object)(object)animator == (Object)null) && speedParamID != -1) { float num = 0f; if (shouldBeMovingFlag && currentActualSpeed > 0.1f) { num = ((followSpeed > 0.01f) ? Mathf.Clamp01(currentActualSpeed / followSpeed) : 0f); } animator.SetFloat(speedParamID, num); } } private void OnDestroy() { if ((Object)(object)REPOCompanionsMod.currentCompanionInstance == (Object)(object)((Component)this).gameObject) { ManualLogSource? staticLogger = REPOCompanionsMod.StaticLogger; if (staticLogger != null) { staticLogger.LogInfo((object)"CompanionController clearing static currentCompanionInstance reference."); } REPOCompanionsMod.currentCompanionInstance = null; } } } }