using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("LaserAim")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+fef0403ecc6d6506e329f14caadcab6191494af4")] [assembly: AssemblyProduct("LaserAim")] [assembly: AssemblyTitle("LaserAim")] [assembly: AssemblyVersion("1.0.0.0")] [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 LaserAim { [BepInPlugin("com.out_pu22led.LaserAim", "Laser Aim", "1.1.0")] public class Plugin : BaseUnityPlugin { internal static ConfigEntry LaserWidth; internal static ConfigEntry LaserAlpha; internal static ConfigEntry LaserColor; internal static ConfigEntry DotSize; internal static ConfigEntry DotOffset; internal static ConfigEntry DotColor; internal static ConfigEntry ShotgunMode; internal static ConfigEntry ConeRayCount; internal static ConfigEntry ShotgunAlpha; public static ManualLogSource Log; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; LaserColor = ((BaseUnityPlugin)this).Config.Bind("General", "LaserColor", "255,0,0", "Laser color as R,G,B (0-255)"); LaserWidth = ((BaseUnityPlugin)this).Config.Bind("General", "LaserWidth", 0.01f, "Laser beam width in world units"); LaserAlpha = ((BaseUnityPlugin)this).Config.Bind("General", "LaserAlpha", 0.8f, "Laser opacity (0-1)"); DotColor = ((BaseUnityPlugin)this).Config.Bind("General", "DotColor", "255,0,0", "Hit indicator color as R,G,B (0-255)"); DotSize = ((BaseUnityPlugin)this).Config.Bind("General", "DotSize", 0.1f, "Laser dot sphere size in world units"); DotOffset = ((BaseUnityPlugin)this).Config.Bind("General", "DotOffset", 0.1f, "Pull the dot back from the hit point by this distance to avoid clipping into the model"); ShotgunMode = ((BaseUnityPlugin)this).Config.Bind("Shotgun", "ShotgunMode", "Cone3D", "Spread visualization for shotguns: Cone3D (solid transparent cone mesh), Cone (line ring), Off (single ray)"); ConeRayCount = ((BaseUnityPlugin)this).Config.Bind("Shotgun", "ConeRayCount", 36, "Number of rays / mesh segments for Cone and Cone3D modes (3-36)"); ShotgunAlpha = ((BaseUnityPlugin)this).Config.Bind("Shotgun", "ShotgunAlpha", 0.05f, "Opacity of shotgun spread visualization (0-1)"); Harmony.CreateAndPatchAll(typeof(ItemGunPatches), (string)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Laser Aim Loaded!"); } public static Color GetLaserColor() { //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_007c: 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_0084: Unknown result type (might be due to invalid IL or missing references) try { string[] array = LaserColor.Value.Split(','); float num = float.Parse(array[0].Trim()) / 255f; float num2 = float.Parse(array[1].Trim()) / 255f; float num3 = float.Parse(array[2].Trim()) / 255f; return new Color(num, num2, num3, LaserAlpha.Value); } catch { return new Color(1f, 0f, 0f, LaserAlpha.Value); } } } [HarmonyPatch] public class ItemGunPatches { [HarmonyPostfix] [HarmonyPatch(typeof(ItemGun), "Start")] private static void Start_Postfix(ItemGun __instance) { ((Component)__instance).gameObject.AddComponent().Setup(__instance); } [HarmonyPostfix] [HarmonyPatch(typeof(ItemCartCannon), "Start")] private static void CartCannon_Start_Postfix(ItemCartCannon __instance) { ((Component)__instance).gameObject.AddComponent().Setup(__instance); } [HarmonyPostfix] [HarmonyPatch(typeof(ItemCartLaser), "Start")] private static void CartLaser_Start_Postfix(ItemCartLaser __instance) { ((Component)__instance).gameObject.AddComponent().Setup(__instance); } } public class LaserDot { private static GameObject? _sphere; public static void Show(Vector3 worldPos) { //IL_001c: 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_003b: 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) if ((Object)(object)_sphere == (Object)null) { CreateDot(); } _sphere.transform.position = worldPos; _sphere.transform.localScale = Vector3.one * Plugin.DotSize.Value; _sphere.GetComponent().material.color = GetDotColor(); _sphere.SetActive(true); } private static Color GetDotColor() { //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_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_007a: Unknown result type (might be due to invalid IL or missing references) try { string[] array = Plugin.DotColor.Value.Split(','); float num = float.Parse(array[0].Trim()) / 255f; float num2 = float.Parse(array[1].Trim()) / 255f; float num3 = float.Parse(array[2].Trim()) / 255f; return new Color(num, num2, num3, 1f); } catch { return new Color(1f, 0f, 0f, 1f); } } public static void Hide() { if ((Object)(object)_sphere != (Object)null) { _sphere.SetActive(false); } } private static void CreateDot() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) _sphere = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)_sphere).name = "LaserDot"; Object.DontDestroyOnLoad((Object)(object)_sphere); Object.DestroyImmediate((Object)(object)_sphere.GetComponent()); Material val = new Material(Shader.Find("Unlit/Color") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Standard")); val.color = GetDotColor(); _sphere.GetComponent().material = val; _sphere.SetActive(false); } } public class LaserAimBehaviour : MonoBehaviour { private const int MaxSpreadLines = 36; private ItemGun _gun; private PhysGrabObject _physGrabObject; private LineRenderer _line; private LineRenderer[] _spreadLines; private GameObject? _coneMeshObj; private Mesh? _coneMesh; private MeshRenderer? _coneMeshRenderer; private int _coneMeshSegments = -1; private string _cachedColorStr = ""; private float _cachedAlpha = -1f; private float _cachedWidth = -1f; private bool _wasShowingLaser; public void Setup(ItemGun gun) { _gun = gun; _physGrabObject = ((Component)gun).GetComponent(); _line = CreateLineRenderer(((Component)gun).transform, "LaserAimLine"); _spreadLines = (LineRenderer[])(object)new LineRenderer[36]; for (int i = 0; i < 36; i++) { _spreadLines[i] = CreateLineRenderer(((Component)gun).transform, $"LaserSpreadLine{i}"); } } private LineRenderer CreateLineRenderer(Transform parent, string name) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0067: Expected O, but got Unknown GameObject val = new GameObject(name); val.transform.SetParent(parent, false); LineRenderer obj = val.AddComponent(); obj.positionCount = 2; obj.useWorldSpace = true; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; Shader val2 = Shader.Find("Unlit/Color") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Standard"); ((Renderer)obj).material = new Material(val2); ((Renderer)obj).enabled = false; return obj; } private void ApplyStyleToLine(LineRenderer lr, float alpha) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_003c: Unknown result type (might be due to invalid IL or missing references) Color laserColor = Plugin.GetLaserColor(); lr.startColor = new Color(laserColor.r, laserColor.g, laserColor.b, alpha); lr.endColor = new Color(laserColor.r, laserColor.g, laserColor.b, 0f); lr.startWidth = Plugin.LaserWidth.Value; lr.endWidth = Plugin.LaserWidth.Value * 0.5f; } private void ApplyStyle() { string value = Plugin.LaserColor.Value; float value2 = Plugin.LaserAlpha.Value; float value3 = Plugin.LaserWidth.Value; if (!(value == _cachedColorStr) || value2 != _cachedAlpha || value3 != _cachedWidth) { _cachedColorStr = value; _cachedAlpha = value2; _cachedWidth = value3; ApplyStyleToLine(_line, value2); LineRenderer[] spreadLines = _spreadLines; foreach (LineRenderer lr in spreadLines) { ApplyStyleToLine(lr, Plugin.ShotgunAlpha.Value); } } } private void DisableSpreadLines() { LineRenderer[] spreadLines = _spreadLines; for (int i = 0; i < spreadLines.Length; i++) { ((Renderer)spreadLines[i]).enabled = false; } } private void HideConeMesh() { if ((Object)(object)_coneMeshObj != (Object)null) { _coneMeshObj.SetActive(false); } } private void Update() { if (!((Object)(object)_physGrabObject != (Object)null) || !_physGrabObject.grabbedLocal) { ((Renderer)_line).enabled = false; DisableSpreadLines(); HideConeMesh(); if (_wasShowingLaser) { LaserDot.Hide(); } _wasShowingLaser = false; return; } _wasShowingLaser = true; ApplyStyle(); Transform gunMuzzle = _gun.gunMuzzle; float gunRange = _gun.gunRange; bool num = _gun.numberOfBullets > 1 && _gun.gunRandomSpread > 0f; string value = Plugin.ShotgunMode.Value; if (num && value != "Off") { if (value == "Cone3D") { DisableSpreadLines(); DrawCone3D(gunMuzzle, gunRange); } else { HideConeMesh(); DrawSpread(gunMuzzle, gunRange); } } else { DisableSpreadLines(); HideConeMesh(); DrawSingle(gunMuzzle, gunRange); } } private void DrawSingle(Transform muzzle, float range) { //IL_0000: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) int num = LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()); int mask = LayerMask.GetMask(new string[1] { "Enemy" }); int num2 = num | mask; Vector3 val = muzzle.position + muzzle.forward * range; RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(muzzle.position, muzzle.forward, ref val2, range, num2)) { val = ((RaycastHit)(ref val2)).point; if ((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent() != (Object)null) { LaserDot.Show(((RaycastHit)(ref val2)).point - muzzle.forward * Plugin.DotOffset.Value); } else { LaserDot.Hide(); } } else { LaserDot.Hide(); } _line.SetPosition(0, muzzle.position); _line.SetPosition(1, val); ((Renderer)_line).enabled = true; } private void DrawSpread(Transform muzzle, float range) { //IL_0005: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0063: 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_006b: 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) //IL_0076: 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_0093: 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_00bc: 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) LaserDot.Hide(); int mask = LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()); float num = _gun.gunRandomSpread / 2f; int num2 = Mathf.Clamp(Plugin.ConeRayCount.Value, 3, 36); Vector3[] array = (Vector3[])(object)new Vector3[num2]; for (int i = 0; i < num2; i++) { Vector3 val = Quaternion.AngleAxis(360f / (float)num2 * (float)i, muzzle.forward) * muzzle.right; array[i] = Quaternion.AngleAxis(num, val) * muzzle.forward; } DrawRay(_line, muzzle.position, muzzle.forward, range, mask); for (int j = 0; j < 36; j++) { if (j < array.Length) { DrawRay(_spreadLines[j], muzzle.position, array[j], range, mask); } else { ((Renderer)_spreadLines[j]).enabled = false; } } } private void DrawCone3D(Transform muzzle, float range) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0079: 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_007e: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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_012e: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) LaserDot.Hide(); int num = LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()); float num2 = _gun.gunRandomSpread / 2f; int num3 = Mathf.Clamp(Plugin.ConeRayCount.Value, 3, 36); EnsureConeMesh(num3); Vector3[] array = (Vector3[])(object)new Vector3[num3 + 1]; array[0] = muzzle.position; RaycastHit val3 = default(RaycastHit); for (int i = 0; i < num3; i++) { Vector3 val = Quaternion.AngleAxis(360f / (float)num3 * (float)i, muzzle.forward) * muzzle.right; Vector3 val2 = Quaternion.AngleAxis(num2, val) * muzzle.forward; float num4 = (Physics.Raycast(muzzle.position, val2, ref val3, range, num) ? ((RaycastHit)(ref val3)).distance : range); array[i + 1] = muzzle.position + val2 * num4; } _coneMesh.vertices = array; _coneMesh.RecalculateNormals(); _coneMesh.RecalculateBounds(); Color laserColor = Plugin.GetLaserColor(); ((Renderer)_coneMeshRenderer).material.color = new Color(laserColor.r, laserColor.g, laserColor.b, Plugin.ShotgunAlpha.Value); DrawRay(_line, muzzle.position, muzzle.forward, range, num); _coneMeshObj.SetActive(true); } private void EnsureConeMesh(int segments) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //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_0042: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_coneMeshObj == (Object)null) { _coneMeshObj = new GameObject("LaserCone"); Object.DontDestroyOnLoad((Object)(object)_coneMeshObj); _coneMesh = new Mesh { name = "LaserConeMesh" }; _coneMeshObj.AddComponent().mesh = _coneMesh; _coneMeshRenderer = _coneMeshObj.AddComponent(); ((Renderer)_coneMeshRenderer).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)_coneMeshRenderer).receiveShadows = false; Material val = new Material(Shader.Find("Sprites/Default") ?? Shader.Find("Standard")); val.color = new Color(1f, 0f, 0f, Plugin.ShotgunAlpha.Value); ((Renderer)_coneMeshRenderer).material = val; _coneMeshObj.SetActive(false); _coneMeshSegments = -1; } if (_coneMeshSegments != segments) { _coneMeshSegments = segments; _coneMesh.vertices = (Vector3[])(object)new Vector3[segments + 1]; int[] array = new int[segments * 6]; for (int i = 0; i < segments; i++) { int num = 0; int num2 = i + 1; int num3 = (i + 1) % segments + 1; array[i * 6] = num; array[i * 6 + 1] = num2; array[i * 6 + 2] = num3; array[i * 6 + 3] = num; array[i * 6 + 4] = num3; array[i * 6 + 5] = num2; } _coneMesh.triangles = array; } } private void DrawRay(LineRenderer lr, Vector3 origin, Vector3 dir, float range, int mask) { //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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); Vector3 val2 = (Physics.Raycast(origin, dir, ref val, range, mask) ? ((RaycastHit)(ref val)).point : (origin + dir * range)); lr.SetPosition(0, origin); lr.SetPosition(1, val2); ((Renderer)lr).enabled = true; } } public class CartCannonAimBehaviour : MonoBehaviour { private static readonly FieldInfo _stateField = AccessTools.Field(typeof(ItemCartCannonMain), "stateCurrent"); private ItemCartCannonMain _cannonMain; private PhysGrabObject _physGrabObject; private LineRenderer _line; private string _cachedColorStr = ""; private float _cachedAlpha = -1f; private float _cachedWidth = -1f; private bool _wasShowingLaser; public void Setup(ItemCartCannon cannon) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown _cannonMain = ((Component)cannon).GetComponent(); _physGrabObject = ((Component)cannon).GetComponent(); GameObject val = new GameObject("CartCannonLaserLine"); val.transform.SetParent(((Component)cannon).transform, false); _line = val.AddComponent(); _line.positionCount = 2; _line.useWorldSpace = true; ((Renderer)_line).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)_line).receiveShadows = false; Shader val2 = Shader.Find("Unlit/Color") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Standard"); ((Renderer)_line).material = new Material(val2); ((Renderer)_line).enabled = false; } private void ApplyStyle() { //IL_0057: 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_0063: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_009d: Unknown result type (might be due to invalid IL or missing references) string value = Plugin.LaserColor.Value; float value2 = Plugin.LaserAlpha.Value; float value3 = Plugin.LaserWidth.Value; if (!(value == _cachedColorStr) || value2 != _cachedAlpha || value3 != _cachedWidth) { _cachedColorStr = value; _cachedAlpha = value2; _cachedWidth = value3; Color laserColor = Plugin.GetLaserColor(); _line.startColor = new Color(laserColor.r, laserColor.g, laserColor.b, value2); _line.endColor = new Color(laserColor.r, laserColor.g, laserColor.b, 0f); _line.startWidth = value3; _line.endWidth = value3 * 0.5f; } } private void Update() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Invalid comparison between Unknown and I4 //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00d2: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_cannonMain == (Object)null) { ((Renderer)_line).enabled = false; return; } bool num = (Object)(object)_physGrabObject != (Object)null && _physGrabObject.grabbedLocal; bool flag = (int)(state)_stateField.GetValue(_cannonMain) > 0; if (!num || !flag) { ((Renderer)_line).enabled = false; if (_wasShowingLaser) { LaserDot.Hide(); } _wasShowingLaser = false; return; } _wasShowingLaser = true; ApplyStyle(); Transform muzzle = _cannonMain.muzzle; float num2 = 25f; int num3 = LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()); int mask = LayerMask.GetMask(new string[1] { "Enemy" }); int num4 = num3 | mask; Vector3 val = muzzle.position + muzzle.forward * num2; RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(muzzle.position, muzzle.forward, ref val2, num2, num4)) { val = ((RaycastHit)(ref val2)).point; if ((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent() != (Object)null) { LaserDot.Show(((RaycastHit)(ref val2)).point - muzzle.forward * Plugin.DotOffset.Value); } else { LaserDot.Hide(); } } else { LaserDot.Hide(); } _line.SetPosition(0, muzzle.position); _line.SetPosition(1, val); ((Renderer)_line).enabled = true; } } public class CartLaserAimBehaviour : MonoBehaviour { private static readonly FieldInfo _stateField = AccessTools.Field(typeof(ItemCartCannonMain), "stateCurrent"); private Transform _muzzle; private ItemCartCannonMain _cannonMain; private PhysGrabObject _physGrabObject; private LineRenderer _line; private string _cachedColorStr = ""; private float _cachedAlpha = -1f; private float _cachedWidth = -1f; private bool _wasShowingLaser; public void Setup(ItemCartLaser laser) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown _muzzle = laser.muzzleTransform; _cannonMain = ((Component)laser).GetComponent(); _physGrabObject = ((Component)laser).GetComponent(); GameObject val = new GameObject("CartLaserAimLine"); val.transform.SetParent(((Component)laser).transform, false); _line = val.AddComponent(); _line.positionCount = 2; _line.useWorldSpace = true; ((Renderer)_line).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)_line).receiveShadows = false; Shader val2 = Shader.Find("Unlit/Color") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Standard"); ((Renderer)_line).material = new Material(val2); ((Renderer)_line).enabled = false; } private void ApplyStyle() { //IL_0057: 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_0063: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_009d: Unknown result type (might be due to invalid IL or missing references) string value = Plugin.LaserColor.Value; float value2 = Plugin.LaserAlpha.Value; float value3 = Plugin.LaserWidth.Value; if (!(value == _cachedColorStr) || value2 != _cachedAlpha || value3 != _cachedWidth) { _cachedColorStr = value; _cachedAlpha = value2; _cachedWidth = value3; Color laserColor = Plugin.GetLaserColor(); _line.startColor = new Color(laserColor.r, laserColor.g, laserColor.b, value2); _line.endColor = new Color(laserColor.r, laserColor.g, laserColor.b, 0f); _line.startWidth = value3; _line.endWidth = value3 * 0.5f; } } private void Update() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Invalid comparison between Unknown and I4 //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_cannonMain == (Object)null) { ((Renderer)_line).enabled = false; return; } bool num = (Object)(object)_physGrabObject != (Object)null && _physGrabObject.grabbedLocal; bool flag = (int)(state)_stateField.GetValue(_cannonMain) > 0; if (!num || !flag) { ((Renderer)_line).enabled = false; if (_wasShowingLaser) { LaserDot.Hide(); } _wasShowingLaser = false; return; } _wasShowingLaser = true; ApplyStyle(); float num2 = 15f; int num3 = LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()); int mask = LayerMask.GetMask(new string[1] { "Enemy" }); int num4 = num3 | mask; Vector3 val = _muzzle.position + _muzzle.forward * num2; RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(_muzzle.position, _muzzle.forward, ref val2, num2, num4)) { val = ((RaycastHit)(ref val2)).point; if ((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent() != (Object)null) { LaserDot.Show(((RaycastHit)(ref val2)).point - _muzzle.forward * Plugin.DotOffset.Value); } else { LaserDot.Hide(); } } else { LaserDot.Hide(); } _line.SetPosition(0, _muzzle.position); _line.SetPosition(1, val); ((Renderer)_line).enabled = true; } } }