Decompiled source of AttackDirectionFix v1.1.1

plugins/AttackDirectionFix/AttackDirectionFix.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AttackDirectionFix.Patches;
using AttackDirectionFix.Utils;
using BepInEx;
using BepInEx.Logging;
using HG.Reflection;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using On.RoR2;
using On.RoR2.Projectile;
using R2API.Utils;
using RoR2;
using RoR2.ConVar;
using RoR2.Projectile;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("AttackDirectionFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+8be960d5bbc062a8f56343a12296c118c8a2a125")]
[assembly: AssemblyProduct("AttackDirectionFix")]
[assembly: AssemblyTitle("AttackDirectionFix")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AttackDirectionFix
{
	public class FireProjectileInfoTracker : MonoBehaviour
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_InitializeProjectile <>9__0_0;

			internal void <InitPatch>b__0_0(orig_InitializeProjectile orig, ProjectileController projectileController, FireProjectileInfo fireProjectileInfo)
			{
				//IL_0002: 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)
				orig.Invoke(projectileController, fireProjectileInfo);
				((Component)projectileController).gameObject.AddComponent<FireProjectileInfoTracker>().FireInfo = fireProjectileInfo;
			}
		}

		public FireProjectileInfo FireInfo { get; private set; }

		public static void InitPatch()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				hook_InitializeProjectile val = delegate(orig_InitializeProjectile orig, ProjectileController projectileController, FireProjectileInfo fireProjectileInfo)
				{
					//IL_0002: 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)
					orig.Invoke(projectileController, fireProjectileInfo);
					((Component)projectileController).gameObject.AddComponent<FireProjectileInfoTracker>().FireInfo = fireProjectileInfo;
				};
				<>c.<>9__0_0 = val;
				obj = (object)val;
			}
			ProjectileManager.InitializeProjectile += (hook_InitializeProjectile)obj;
		}
	}
	internal static class Log
	{
		internal static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		private static string getLogPrefix(string callerPath, string callerMemberName, int callerLineNumber)
		{
			int num = callerPath.LastIndexOf("AttackDirectionFix");
			if (num >= 0)
			{
				callerPath = callerPath.Substring(num + "AttackDirectionFix".Length + 1);
			}
			return $"{callerPath}:{callerLineNumber} ({callerMemberName}) ";
		}

		internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogError((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Error_NoCallerPrefix(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogFatal((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Fatal_NoCallerPrefix(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogInfo((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Info_NoCallerPrefix(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogMessage((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Message_NoCallerPrefix(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogWarning((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Warning_NoCallerPrefix(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("Gorakh.AttackDirectionFix", "AttackDirectionFix", "1.1.1")]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "Gorakh.AttackDirectionFix";

		public const string PluginAuthor = "Gorakh";

		public const string PluginName = "AttackDirectionFix";

		public const string PluginVersion = "1.1.1";

		private void Awake()
		{
			Stopwatch stopwatch = Stopwatch.StartNew();
			Log.Init(((BaseUnityPlugin)this).Logger);
			AimOriginOverridePatch.Init();
			FireProjectileInfoTracker.InitPatch();
			ProjectileGhostOffsetPatch.Init();
			PlayerAimVisualizer.Init();
			stopwatch.Stop();
			Log.Info_NoCallerPrefix($"Initialized in {stopwatch.Elapsed.TotalSeconds:F2} seconds");
		}
	}
	internal static class PlayerAimVisualizer
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static SceneCameraDelegate <0>__SceneCameraPreCull;
		}

		private static GameObject _aimOriginVisualizer;

		private static GameObject _cameraPivotVisualizer;

		private static readonly BoolConVar _cvEnableAimVisualization = new BoolConVar("debug_aim_visualization", (ConVarFlags)0, "0", "Enables/Disables player aim visualization. Green=Aim Origin, Red=Camera Pivot");

		public static void Init()
		{
			//IL_0034: 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_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_00a4: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			_aimOriginVisualizer = GameObject.CreatePrimitive((PrimitiveType)0);
			Object.DontDestroyOnLoad((Object)(object)_aimOriginVisualizer);
			_aimOriginVisualizer.GetComponent<Collider>().enabled = false;
			_aimOriginVisualizer.GetComponent<Renderer>().material.color = Color.green;
			_aimOriginVisualizer.transform.localScale = Vector3.one * 0.1f;
			_cameraPivotVisualizer = GameObject.CreatePrimitive((PrimitiveType)0);
			Object.DontDestroyOnLoad((Object)(object)_cameraPivotVisualizer);
			_cameraPivotVisualizer.GetComponent<Collider>().enabled = false;
			_cameraPivotVisualizer.GetComponent<Renderer>().material.color = Color.red;
			_cameraPivotVisualizer.transform.localScale = Vector3.one * 0.1f;
			object obj = <>O.<0>__SceneCameraPreCull;
			if (obj == null)
			{
				SceneCameraDelegate val = SceneCameraPreCull;
				<>O.<0>__SceneCameraPreCull = val;
				obj = (object)val;
			}
			SceneCamera.onSceneCameraPreCull += (SceneCameraDelegate)obj;
		}

		private static void SceneCameraPreCull(SceneCamera sceneCamera)
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)_aimOriginVisualizer))
			{
				_aimOriginVisualizer.SetActive(false);
			}
			if (Object.op_Implicit((Object)(object)_cameraPivotVisualizer))
			{
				_cameraPivotVisualizer.SetActive(false);
			}
			if (!_cvEnableAimVisualization.value)
			{
				return;
			}
			CameraRigController cameraRigController = sceneCamera.cameraRigController;
			if (Object.op_Implicit((Object)(object)cameraRigController) && cameraRigController.localUserViewer != null)
			{
				CharacterBody targetBody = cameraRigController.targetBody;
				if (Object.op_Implicit((Object)(object)targetBody) && Object.op_Implicit((Object)(object)_aimOriginVisualizer))
				{
					_aimOriginVisualizer.SetActive(true);
					_aimOriginVisualizer.transform.position = targetBody.inputBank.aimOrigin;
				}
				CameraTargetParams targetParams = cameraRigController.targetParams;
				if (Object.op_Implicit((Object)(object)targetParams) && Object.op_Implicit((Object)(object)targetParams.cameraPivotTransform) && Object.op_Implicit((Object)(object)_cameraPivotVisualizer))
				{
					_cameraPivotVisualizer.SetActive(true);
					_cameraPivotVisualizer.transform.position = targetParams.cameraPivotTransform.position;
				}
			}
		}
	}
	public class ProjectileInitialOffset : MonoBehaviour
	{
		public Vector3 InitialPositionOffset;

		public Quaternion InitialRotationOffset = Quaternion.identity;

		public float InterpolationTime;

		private float _age;

		private float interpolationFraction => Mathf.Pow(Mathf.Clamp01(_age / InterpolationTime), 1f / 3f);

		public Vector3 CurrentPositionOffset => Vector3.Lerp(InitialPositionOffset, Vector3.zero, interpolationFraction);

		public Quaternion CurrentRotationOffset => Quaternion.Lerp(InitialRotationOffset, Quaternion.identity, interpolationFraction);

		private void FixedUpdate()
		{
			if (_age < InterpolationTime)
			{
				_age += Time.fixedDeltaTime;
			}
			else
			{
				Object.Destroy((Object)(object)this);
			}
		}
	}
}
namespace AttackDirectionFix.Utils
{
	public static class CameraRigUtils
	{
		public static CameraRigController FindCameraRigControllerForBody(CharacterBody body)
		{
			return ((IEnumerable<CameraRigController>)CameraRigController.readOnlyInstancesList).FirstOrDefault((Func<CameraRigController, bool>)((CameraRigController c) => (Object)(object)c.targetBody == (Object)(object)body));
		}
	}
	public static class VectorUtils
	{
		public static Vector3 ClosestPointAlongRay(Ray ray, Vector3 target)
		{
			//IL_0002: 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_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_0018: 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_0027: 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)
			return ((Ray)(ref ray)).origin + ((Ray)(ref ray)).direction * Vector3.Dot(((Ray)(ref ray)).direction, target - ((Ray)(ref ray)).origin);
		}
	}
}
namespace AttackDirectionFix.Patches
{
	internal static class AimOriginOverridePatch
	{
		private delegate Vector3 orig_get_aimOrigin(InputBankTest self);

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_FindBestInteractableObject <>9__1_0;

			internal GameObject <Init>b__1_0(orig_FindBestInteractableObject orig, InteractionDriver self)
			{
				_tempDisablePatch = true;
				try
				{
					return orig.Invoke(self);
				}
				finally
				{
					_tempDisablePatch = false;
				}
			}
		}

		private static bool _tempDisablePatch;

		public static void Init()
		{
			//IL_0034: 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_0065: Expected O, but got Unknown
			MethodInfo methodInfo = AccessTools.DeclaredPropertyGetter(typeof(InputBankTest), "aimOrigin");
			if ((object)methodInfo != null)
			{
				new Hook((MethodBase)methodInfo, (Delegate)new Func<orig_get_aimOrigin, InputBankTest, Vector3>(InputBankTest_get_aimOrigin));
			}
			else
			{
				Log.Error_NoCallerPrefix("Unable to find InputBankTest.aimOrigin getter");
			}
			object obj = <>c.<>9__1_0;
			if (obj == null)
			{
				hook_FindBestInteractableObject val = delegate(orig_FindBestInteractableObject orig, InteractionDriver self)
				{
					_tempDisablePatch = true;
					try
					{
						return orig.Invoke(self);
					}
					finally
					{
						_tempDisablePatch = false;
					}
				};
				<>c.<>9__1_0 = val;
				obj = (object)val;
			}
			InteractionDriver.FindBestInteractableObject += (hook_FindBestInteractableObject)obj;
		}

		public static Vector3 GetUnalteredAimOrigin(this InputBankTest inputBankTest)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			_tempDisablePatch = true;
			try
			{
				return inputBankTest.aimOrigin;
			}
			finally
			{
				_tempDisablePatch = false;
			}
		}

		private static Vector3 InputBankTest_get_aimOrigin(orig_get_aimOrigin orig, InputBankTest self)
		{
			//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_0077: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_0055: 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_005c: 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_0066: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			Vector3 result = orig(self);
			if (!_tempDisablePatch)
			{
				CameraRigController val = CameraRigUtils.FindCameraRigControllerForBody(self.characterBody);
				if (Object.op_Implicit((Object)(object)val))
				{
					CameraTargetParams targetParams = val.targetParams;
					if (Object.op_Implicit((Object)(object)targetParams) && Object.op_Implicit((Object)(object)targetParams.cameraPivotTransform))
					{
						Vector3 position = targetParams.cameraPivotTransform.position;
						CameraState currentCameraState = val.currentCameraState;
						return VectorUtils.ClosestPointAlongRay(new Ray(currentCameraState.position, currentCameraState.rotation * Vector3.forward), position);
					}
				}
			}
			return result;
		}
	}
	internal static class ProjectileGhostOffsetPatch
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Start <0>__ProjectileController_Start;

			public static hook_LerpTransform <1>__ProjectileGhostController_LerpTransform;

			public static hook_CopyTransform <2>__ProjectileGhostController_CopyTransform;

			public static hook_TrySticking <3>__ProjectileStickOnImpact_TrySticking;
		}

		private static readonly FloatConVar _cvProjectileInterpolationTime = new FloatConVar("projectile_visual_interp", (ConVarFlags)0, "0.7", "");

		public static void Init()
		{
			//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_001b: Expected O, but got Unknown
			//IL_0030: 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: Expected O, but got Unknown
			//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_005b: Expected O, but got Unknown
			//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_007b: Expected O, but got Unknown
			object obj = <>O.<0>__ProjectileController_Start;
			if (obj == null)
			{
				hook_Start val = ProjectileController_Start;
				<>O.<0>__ProjectileController_Start = val;
				obj = (object)val;
			}
			ProjectileController.Start += (hook_Start)obj;
			object obj2 = <>O.<1>__ProjectileGhostController_LerpTransform;
			if (obj2 == null)
			{
				hook_LerpTransform val2 = ProjectileGhostController_LerpTransform;
				<>O.<1>__ProjectileGhostController_LerpTransform = val2;
				obj2 = (object)val2;
			}
			ProjectileGhostController.LerpTransform += (hook_LerpTransform)obj2;
			object obj3 = <>O.<2>__ProjectileGhostController_CopyTransform;
			if (obj3 == null)
			{
				hook_CopyTransform val3 = ProjectileGhostController_CopyTransform;
				<>O.<2>__ProjectileGhostController_CopyTransform = val3;
				obj3 = (object)val3;
			}
			ProjectileGhostController.CopyTransform += (hook_CopyTransform)obj3;
			object obj4 = <>O.<3>__ProjectileStickOnImpact_TrySticking;
			if (obj4 == null)
			{
				hook_TrySticking val4 = ProjectileStickOnImpact_TrySticking;
				<>O.<3>__ProjectileStickOnImpact_TrySticking = val4;
				obj4 = (object)val4;
			}
			ProjectileStickOnImpact.TrySticking += (hook_TrySticking)obj4;
		}

		private static void ProjectileController_Start(orig_Start orig, ProjectileController self)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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_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_0082: 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_00a9: 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)
			orig.Invoke(self);
			ProjectileGhostController ghost = self.ghost;
			CharacterBody val = default(CharacterBody);
			if (!Object.op_Implicit((Object)(object)ghost) || !Object.op_Implicit((Object)(object)self.owner) || !self.owner.TryGetComponent<CharacterBody>(ref val))
			{
				return;
			}
			InputBankTest inputBank = val.inputBank;
			FireProjectileInfoTracker fireProjectileInfoTracker = default(FireProjectileInfoTracker);
			if (!Object.op_Implicit((Object)(object)inputBank) || !((Component)self).TryGetComponent<FireProjectileInfoTracker>(ref fireProjectileInfoTracker))
			{
				return;
			}
			FireProjectileInfo fireInfo = fireProjectileInfoTracker.FireInfo;
			Vector3 val2 = inputBank.aimOrigin - fireInfo.position;
			if (!(((Vector3)(ref val2)).sqrMagnitude > 1.3225f))
			{
				Vector3 initialPositionOffset = inputBank.GetUnalteredAimOrigin() - fireInfo.position;
				if (!(((Vector3)(ref initialPositionOffset)).sqrMagnitude < 0.0625f))
				{
					ProjectileInitialOffset projectileInitialOffset = ((Component)ghost).gameObject.AddComponent<ProjectileInitialOffset>();
					projectileInitialOffset.InitialPositionOffset = initialPositionOffset;
					projectileInitialOffset.InterpolationTime = _cvProjectileInterpolationTime.value;
				}
			}
		}

		private static void ProjectileGhostController_LerpTransform(orig_LerpTransform orig, ProjectileGhostController self, Transform a, Transform b, float t)
		{
			orig.Invoke(self, a, b, t);
			tryApplyOffset(self);
		}

		private static void ProjectileGhostController_CopyTransform(orig_CopyTransform orig, ProjectileGhostController self, Transform src)
		{
			orig.Invoke(self, src);
			tryApplyOffset(self);
		}

		private static void tryApplyOffset(ProjectileGhostController ghostController)
		{
			//IL_0012: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			ProjectileInitialOffset projectileInitialOffset = default(ProjectileInitialOffset);
			if (((Component)ghostController).TryGetComponent<ProjectileInitialOffset>(ref projectileInitialOffset))
			{
				Transform transform = ghostController.transform;
				transform.position += projectileInitialOffset.CurrentPositionOffset;
				transform.rotation *= projectileInitialOffset.CurrentRotationOffset;
			}
		}

		private static bool ProjectileStickOnImpact_TrySticking(orig_TrySticking orig, ProjectileStickOnImpact self, Collider hitCollider, Vector3 impactNormal)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			bool num = orig.Invoke(self, hitCollider, impactNormal);
			ProjectileController val = default(ProjectileController);
			if (num && ((Component)self).TryGetComponent<ProjectileController>(ref val))
			{
				ProjectileGhostController ghost = val.ghost;
				ProjectileInitialOffset projectileInitialOffset = default(ProjectileInitialOffset);
				if (Object.op_Implicit((Object)(object)ghost) && ((Component)ghost).TryGetComponent<ProjectileInitialOffset>(ref projectileInitialOffset))
				{
					Object.Destroy((Object)(object)projectileInitialOffset);
				}
			}
			return num;
		}
	}
}