using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; using BepInEx; using BepInEx.Logging; using HarmonyLib; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] namespace CigaretteMod; [BepInPlugin("com.trae.cigarette", "Cigarette Smoke", "2.0.0")] public class CigarettePlugin : BaseUnityPlugin { internal static ManualLogSource Log; private void Awake() { //IL_0010: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; new Harmony("com.trae.cigarette").PatchAll(); SoundSwap.Init(); GameObject val = new GameObject("CigaretteMeshReplacer"); Object.DontDestroyOnLoad((Object)val); val.AddComponent(); Log.LogInfo((object)"[CigaretteMod] loaded: 手持香烟按使用键即可抽烟"); } } internal class MeshReplacer : MonoBehaviour { private struct Band { public float z; public float r; public string zone; public Band(float z, float r, string zone) { this.z = z; this.r = r; this.zone = zone; } } [StructLayout(LayoutKind.Explicit, Size = 48)] private struct Vtx48 { [FieldOffset(0)] public Vector3 pos; [FieldOffset(12)] public ushort nx; [FieldOffset(14)] public ushort ny; [FieldOffset(16)] public ushort nz; [FieldOffset(18)] public ushort nw; [FieldOffset(20)] public ushort tx; [FieldOffset(22)] public ushort ty; [FieldOffset(24)] public ushort tz; [FieldOffset(26)] public ushort tw; [FieldOffset(28)] public ushort u0; [FieldOffset(30)] public ushort v0; [FieldOffset(32)] public Vector2 uv1; [FieldOffset(40)] public ushort u2; [FieldOffset(42)] public ushort v2; [FieldOffset(44)] public ushort u3; [FieldOffset(46)] public ushort v3; } private static readonly Dictionary ZoneUV = new Dictionary { { "ember_core", Pc(1f, 0f) }, { "ember", Pc(2f, 0f) }, { "ember_edge", Pc(3f, 0f) }, { "charred", Pc(31f, 23f) }, { "charred2", Pc(31f, 22f) }, { "paper", Pc(31f, 0f) }, { "filter", Pc(31f, 17f) } }; private static readonly Band[] CigBands = new Band[13] { new Band(-0.066f, 0.0032f, "ember_core"), new Band(-0.061f, 0.0049f, "ember_core"), new Band(-0.061f, 0.0049f, "ember"), new Band(-0.056f, 0.0055f, "ember"), new Band(-0.056f, 0.0055f, "ember_edge"), new Band(-0.051f, 0.0055f, "ember_edge"), new Band(-0.051f, 0.0055f, "charred"), new Band(-0.044f, 0.0055f, "charred"), new Band(-0.044f, 0.0055f, "paper"), new Band(0.037f, 0.0055f, "paper"), new Band(0.037f, 0.0056f, "filter"), new Band(0.055f, 0.0056f, "filter"), new Band(0.074f, 0.0056f, "filter") }; private Mesh _cigMesh; private Mesh _buttMesh; private Mesh _buttNpcMesh; private float _timer; private static Vector2 Pc(float col, float row) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) return new Vector2((col + 0.5f) / 32f, 1f - (row + 0.5f) / 32f); } private static Band[] ButtBands(float z0, float z1) { float num = z1 - z0; return new Band[9] { new Band(z0, 0.0046f, "charred"), new Band(z0 + 0.07f * num, 0.0053f, "charred"), new Band(z0 + 0.07f * num, 0.0055f, "charred2"), new Band(z0 + 0.15f * num, 0.0055f, "charred2"), new Band(z0 + 0.15f * num, 0.0055f, "paper"), new Band(z0 + 0.48f * num, 0.0056f, "paper"), new Band(z0 + 0.48f * num, 0.0056f, "filter"), new Band(z0 + 0.72f * num, 0.0056f, "filter"), new Band(z1, 0.0056f, "filter") }; } private void Update() { _timer -= Time.deltaTime; if (_timer > 0f) { return; } _timer = 0.5f; if ((Object)(object)_cigMesh == (Object)null) { _cigMesh = MakeMesh("Cigarette", CigBands); _buttMesh = MakeMesh("CigButt", ButtBands(0.012f, 0.068f)); _buttNpcMesh = MakeMesh("CigButtNPC", ButtBands(-0.038f, 0.018f)); CigarettePlugin.Log.LogInfo((object)("[CigaretteMod] 香烟网格已生成: " + _cigMesh.vertexCount + " 顶点")); } int num = 0; MeshFilter[] array = Resources.FindObjectsOfTypeAll(); foreach (MeshFilter val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.sharedMesh == (Object)null)) { string name = ((Object)val.sharedMesh).name; Mesh val2 = null; switch (name) { case "BeerCan": val2 = _cigMesh; break; case "EmptyBeerCan": val2 = _buttMesh; break; case "NPCEmptyBeerCan": val2 = _buttNpcMesh; break; } if ((Object)(object)val2 != (Object)null) { val.sharedMesh = val2; num++; } } } if (num > 0) { CigarettePlugin.Log.LogInfo((object)("[CigaretteMod] 换装 " + num + " 个网格引用")); } } private static Mesh MakeMesh(string name, Band[] bands) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0016: Expected O, but got Unknown Mesh val = new Mesh { name = name }; BuildCylinder(val, bands, 20); return val; } private static void BuildCylinder(Mesh mesh, Band[] bands, int nSeg) { //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_011b: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: 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_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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_0583: Unknown result type (might be due to invalid IL or missing references) //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_0593: Unknown result type (might be due to invalid IL or missing references) //IL_0598: Unknown result type (might be due to invalid IL or missing references) //IL_05a3: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_05b3: Unknown result type (might be due to invalid IL or missing references) //IL_05b8: Unknown result type (might be due to invalid IL or missing references) //IL_05c3: Unknown result type (might be due to invalid IL or missing references) //IL_05c8: Unknown result type (might be due to invalid IL or missing references) //IL_05d3: Unknown result type (might be due to invalid IL or missing references) //IL_05d8: Unknown result type (might be due to invalid IL or missing references) //IL_05e3: Unknown result type (might be due to invalid IL or missing references) //IL_05e8: Unknown result type (might be due to invalid IL or missing references) //IL_0630: Unknown result type (might be due to invalid IL or missing references) //IL_0635: Unknown result type (might be due to invalid IL or missing references) List list = new List(); List list2 = new List(); List list3 = new List(); List list4 = new List(); List list5 = new List(); for (int i = 0; i < bands.Length; i++) { Vector2 item = ZoneUV[bands[i].zone]; list5.Add(list.Count); for (int j = 0; j < nSeg; j++) { float num = (float)Math.PI * 2f * (float)j / (float)nSeg; float num2 = Mathf.Cos(num); float num3 = Mathf.Sin(num); list.Add(new Vector3(num2 * bands[i].r, num3 * bands[i].r, bands[i].z)); list2.Add(new Vector3(num2, num3, 0f)); list3.Add(new Vector4(0f - num3, num2, 0f, -1f)); list4.Add(item); } } int count = list.Count; list.Add(new Vector3(0f, 0f, bands[0].z)); list2.Add(new Vector3(0f, 0f, -1f)); list3.Add(new Vector4(1f, 0f, 0f, -1f)); list4.Add(ZoneUV[bands[0].zone]); int count2 = list.Count; list.Add(new Vector3(0f, 0f, bands[^1].z)); list2.Add(new Vector3(0f, 0f, 1f)); list3.Add(new Vector4(1f, 0f, 0f, -1f)); list4.Add(ZoneUV[bands[^1].zone]); List list6 = new List(); for (int k = 0; k < bands.Length - 1; k++) { if (!(Mathf.Abs(bands[k].z - bands[k + 1].z) < 1E-09f)) { for (int l = 0; l < nSeg; l++) { int num4 = (l + 1) % nSeg; int item2 = list5[k] + l; int item3 = list5[k] + num4; int item4 = list5[k + 1] + l; int item5 = list5[k + 1] + num4; list6.Add(item2); list6.Add(item4); list6.Add(item5); list6.Add(item2); list6.Add(item5); list6.Add(item3); } } } int num5 = list5[bands.Length - 1]; for (int m = 0; m < nSeg; m++) { int num6 = (m + 1) % nSeg; list6.Add(count); list6.Add(list5[0] + m); list6.Add(list5[0] + num6); list6.Add(count2); list6.Add(num5 + m); list6.Add(num5 + num6); } FixWinding(list, list6); int count3 = list.Count; Vtx48[] array = new Vtx48[count3]; for (int n = 0; n < count3; n++) { array[n].pos = list[n]; array[n].nx = ToHalf(list2[n].x); array[n].ny = ToHalf(list2[n].y); array[n].nz = ToHalf(list2[n].z); array[n].nw = ToHalf(0f); array[n].tx = ToHalf(list3[n].x); array[n].ty = ToHalf(list3[n].y); array[n].tz = ToHalf(list3[n].z); array[n].tw = ToHalf(-1f); array[n].u0 = ToHalf(list4[n].x); array[n].v0 = ToHalf(list4[n].y); array[n].uv1 = new Vector2(0.02f, 0.25f); array[n].u2 = ToHalf(0.015f); array[n].v2 = ToHalf(0.012f); array[n].u3 = ToHalf(0.5f); array[n].v3 = ToHalf(0.494f); } ushort[] array2 = new ushort[list6.Count]; for (int num7 = 0; num7 < list6.Count; num7++) { array2[num7] = (ushort)list6[num7]; } VertexAttributeDescriptor[] array3 = (VertexAttributeDescriptor[])(object)new VertexAttributeDescriptor[7] { new VertexAttributeDescriptor((VertexAttribute)0, (VertexAttributeFormat)0, 3, 0), new VertexAttributeDescriptor((VertexAttribute)1, (VertexAttributeFormat)1, 4, 0), new VertexAttributeDescriptor((VertexAttribute)2, (VertexAttributeFormat)1, 4, 0), new VertexAttributeDescriptor((VertexAttribute)4, (VertexAttributeFormat)1, 2, 0), new VertexAttributeDescriptor((VertexAttribute)5, (VertexAttributeFormat)0, 2, 0), new VertexAttributeDescriptor((VertexAttribute)6, (VertexAttributeFormat)1, 2, 0), new VertexAttributeDescriptor((VertexAttribute)7, (VertexAttributeFormat)1, 2, 0) }; mesh.SetVertexBufferParams(count3, array3); mesh.SetVertexBufferData(array, 0, 0, count3, 0, (MeshUpdateFlags)0); mesh.SetIndexBufferParams(array2.Length, (IndexFormat)0); mesh.SetIndexBufferData(array2, 0, 0, array2.Length, (MeshUpdateFlags)0); mesh.SetSubMeshes((SubMeshDescriptor[])(object)new SubMeshDescriptor[1] { new SubMeshDescriptor(0, array2.Length, (MeshTopology)0) }, (MeshUpdateFlags)0); mesh.RecalculateBounds(); } private static ushort ToHalf(float f) { byte[] bytes = BitConverter.GetBytes(f); int num = bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24); uint num2 = (uint)((num >>> 16) & 0x8000); int num3 = (num >>> 23) & 0xFF; uint num4 = (uint)(num & 0x7FFFFF); if (num3 == 255) { return (ushort)(num2 | 0x7C00 | ((num4 != 0) ? 1u : 0u)); } num3 = num3 - 127 + 15; if (num3 >= 31) { return (ushort)(num2 | 0x7C00); } if (num3 <= 0) { if (num3 < -10) { return (ushort)num2; } num4 |= 0x800000; int num5 = 14 - num3; uint num6 = num4 >> num5; uint num7 = num4 & (uint)((1 << num5) - 1); uint num8 = (uint)(1 << num5 - 1); if (num7 > num8 || (num7 == num8 && (num6 & 1) != 0)) { num6++; } return (ushort)(num2 | num6); } uint num9 = num4 >> 13; uint num10 = num4 & 0x1FFF; if (num10 > 4096 || (num10 == 4096 && (num9 & 1) != 0)) { num9++; } return (ushort)(num2 | (uint)(num3 << 10) | num9); } private static void FixWinding(List verts, List tris) { //IL_0012: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_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_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) //IL_009b: 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_009f: 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_00a6: 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_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_00b4: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) float num = float.MaxValue; float num2 = float.MinValue; for (int i = 0; i < verts.Count; i++) { if (verts[i].z < num) { num = verts[i].z; } if (verts[i].z > num2) { num2 = verts[i].z; } } float num3 = (num + num2) / 2f; for (int j = 0; j < tris.Count; j += 3) { Vector3 val = verts[tris[j]]; Vector3 val2 = verts[tris[j + 1]]; Vector3 val3 = verts[tris[j + 2]]; Vector3 val4 = Vector3.Cross(val2 - val, val3 - val); Vector3 val5 = (val + val2 + val3) / 3f; Vector3 val6 = ((Mathf.Abs(val4.z) > 0.7f * ((Vector3)(ref val4)).magnitude) ? new Vector3(0f, 0f, (val5.z >= num3) ? 1f : (-1f)) : new Vector3(val5.x, val5.y, 0f)); float magnitude = ((Vector3)(ref val6)).magnitude; if (magnitude > 0f) { val6 /= magnitude; } if (Vector3.Dot(val4, val6) < 0f) { int value = tris[j + 1]; tris[j + 1] = tris[j + 2]; tris[j + 2] = value; } } } } internal static class SoundSwap { private static object _clip; private static MethodInfo _setData; private static PlayerEating _swappedOn; private static object _origEat; private static object _origDrink; internal static float SwallowSuppressUntil = -999f; public static void Init() { try { string text = Path.Combine(Paths.PluginPath, "smoke.wav"); _clip = LoadWav(text); if (_clip != null) { _setData = AccessTools.Method(AccessTools.TypeByName("UnityEngine.AudioClip"), "SetData", new Type[2] { typeof(float[]), typeof(int) }, (Type[])null); float num = (float)AccessTools.Property(AccessTools.TypeByName("UnityEngine.AudioClip"), "length").GetValue(_clip, null); CigarettePlugin.Log.LogInfo((object)("[CigaretteMod] 音效已加载: " + text + " (" + num.ToString("F1") + "秒)")); } else { CigarettePlugin.Log.LogWarning((object)"[CigaretteMod] smoke.wav 解析失败, 抽烟将无音效"); } } catch (Exception ex) { CigarettePlugin.Log.LogWarning((object)("[CigaretteMod] 音效加载失败(抽烟无声): " + ex.Message)); } } public static void Swap(PlayerHolding holding) { if (_clip == null) { return; } try { object value = AccessTools.Field(typeof(PlayerHolding), "_player").GetValue(holding); if (value == null) { return; } object? value2 = AccessTools.Field(typeof(Player), "_playerEating").GetValue(value); PlayerEating val = (PlayerEating)((value2 is PlayerEating) ? value2 : null); if (!((Object)(object)val == (Object)null)) { if ((Object)(object)_swappedOn != (Object)null && _swappedOn != val) { Restore(); } _swappedOn = val; FieldInfo fieldInfo = AccessTools.Field(typeof(PlayerEating), "_eatSound"); FieldInfo fieldInfo2 = AccessTools.Field(typeof(PlayerEating), "_drinkSound"); _origEat = fieldInfo.GetValue(val); _origDrink = fieldInfo2.GetValue(val); fieldInfo.SetValue(val, _clip); fieldInfo2.SetValue(val, _clip); } } catch (Exception ex) { CigarettePlugin.Log.LogWarning((object)("[CigaretteMod] 音效替换失败: " + ex.Message)); } } public static void Restore() { if ((Object)(object)_swappedOn == (Object)null) { return; } try { if (_origEat != _clip && _origDrink != _clip) { AccessTools.Field(typeof(PlayerEating), "_eatSound").SetValue(_swappedOn, _origEat); AccessTools.Field(typeof(PlayerEating), "_drinkSound").SetValue(_swappedOn, _origDrink); } } catch (Exception ex) { CigarettePlugin.Log.LogWarning((object)("[CigaretteMod] 音效恢复失败: " + ex.Message)); } finally { SwallowSuppressUntil = Time.time + 5f; _swappedOn = null; _origEat = null; _origDrink = null; } } private static object LoadWav(string path) { byte[] array = File.ReadAllBytes(path); if (array.Length < 44) { return null; } if (Encoding.ASCII.GetString(array, 0, 4) != "RIFF" || Encoding.ASCII.GetString(array, 8, 4) != "WAVE") { return null; } int num = 0; int num2 = 0; int num3 = 0; byte[] array2 = null; int num4; for (int i = 12; i + 8 <= array.Length; i += 8 + num4 + (num4 & 1)) { string text = Encoding.ASCII.GetString(array, i, 4); num4 = BitConverter.ToInt32(array, i + 4); if (text == "fmt ") { num = BitConverter.ToInt16(array, i + 10); num2 = BitConverter.ToInt32(array, i + 12); num3 = BitConverter.ToInt16(array, i + 22); } else if (text == "data") { int val = array.Length - (i + 8); array2 = new byte[Math.Min(num4, val)]; Array.Copy(array, i + 8, array2, 0, array2.Length); } } if (array2 == null || num < 1 || num2 < 1 || num3 != 16) { return null; } int num5 = array2.Length / 2 / num; if (num5 < 1) { return null; } float[] array3 = new float[num5 * num]; for (int j = 0; j < array3.Length; j++) { array3[j] = (float)BitConverter.ToInt16(array2, j * 2) / 32768f; } Type type = AccessTools.TypeByName("UnityEngine.AudioClip"); object obj = AccessTools.Method(type, "Create", new Type[5] { typeof(string), typeof(int), typeof(int), typeof(int), typeof(bool) }, (Type[])null).Invoke(null, new object[5] { "CigSmokeSound", num5, num, num2, false }); AccessTools.Method(type, "SetData", new Type[2] { typeof(float[]), typeof(int) }, (Type[])null).Invoke(obj, new object[2] { array3, 0 }); return obj; } } [HarmonyPatch(typeof(PlayerEating), "FinishEating")] internal static class RestoreSoundPatch { private static void Postfix() { SoundSwap.Restore(); } } [HarmonyPatch(typeof(AudioManager), "PlayPlayerClip")] internal static class SwallowSuppressPatch { private static bool Prefix(object __0) { try { if (__0 as string == "Swallow" && Time.time < SoundSwap.SwallowSuppressUntil) { return false; } } catch (Exception ex) { CigarettePlugin.Log.LogWarning((object)("[CigaretteMod] SwallowSuppress: " + ex.Message)); } return true; } } internal class DizzyRunner : MonoBehaviour { private Transform _cam; private Quaternion _lastOffset = Quaternion.identity; private float _elapsed; private bool _done; private const float Dur = 10f; private const float RampIn = 1.5f; private const float RampOut = 3f; public void Begin(Transform cam) { _cam = cam; ((MonoBehaviour)this).StartCoroutine(Dizzy()); } private IEnumerator Dizzy() { CigarettePlugin.Log.LogInfo((object)("[CigaretteMod] 眩晕开始 (10秒, 相机=" + (((Object)(object)_cam != (Object)null) ? ((Object)_cam).name : "无") + ")")); yield return (object)new WaitForSeconds(10f); Restore(); } private void Restore() { //IL_0025: 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_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) if (!_done) { _done = true; if ((Object)(object)_cam != (Object)null) { _cam.localRotation = Quaternion.Inverse(_lastOffset) * _cam.localRotation; } CigarettePlugin.Log.LogInfo((object)"[CigaretteMod] 眩晕结束"); Object.Destroy((Object)(object)((Component)this).gameObject); } } private void LateUpdate() { //IL_0081: 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_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_009b: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) if (_done) { return; } if ((Object)(object)_cam == (Object)null) { Restore(); return; } _elapsed += Time.deltaTime; if (_elapsed >= 10f) { Restore(); return; } float elapsed = _elapsed; float num = ((elapsed < 1.5f) ? (elapsed / 1.5f) : ((!(elapsed > 7f)) ? 1f : Mathf.Clamp01((10f - elapsed) / 3f))); Quaternion val = Quaternion.Inverse(_lastOffset) * _cam.localRotation; float num2 = Time.time * (float)Math.PI * 2f; float num3 = Mathf.Sin(num2 * 0.55f) * 4f * num; float num4 = Mathf.Sin(num2 * 0.37f + 1.7f) * 2.5f * num; Quaternion val2 = Quaternion.Euler(Mathf.Cos(num2 * 0.43f + 0.9f) * 1.8f * num, num4, num3); _cam.localRotation = val * val2; _lastOffset = val2; } } [HarmonyPatch(typeof(PlayerHolding), "PrimaryInput")] internal static class UseInputPatch { private static bool Prefix(PlayerHolding __instance) { try { object? value = AccessTools.Field(typeof(PlayerHolding), "_heldItem").GetValue(__instance); Item val = (Item)((value is Item) ? value : null); if ((Object)(object)val == (Object)null) { return true; } Mesh mesh = val.Mesh; if ((Object)(object)mesh == (Object)null || (((Object)mesh).name != "BeerCan" && ((Object)mesh).name != "Cigarette")) { return true; } if ((Object)(object)((Component)val).GetComponent() != (Object)null) { return false; } ((Component)val).gameObject.AddComponent().Begin(__instance, val); return false; } catch (Exception ex) { CigarettePlugin.Log.LogError((object)("[CigaretteMod] UseInputPatch: " + ex)); return true; } } } internal class CigaretteSmoker : MonoBehaviour { private const float TipY = -0.058f; private const float FilterY = 0.074f; private const float MoveTime = 0.7f; private const float SmokeTime = 3f; private const float FadeTime = 0.6f; private Item _item; private Rigidbody _rb; private PlayerHolding _holding; private bool _wasKinematic; private Vector3 _startPos; private Quaternion _startRot; private Transform _cam; private Vector3 _mouthLocal; private bool _mouthValid; private float _t; private int _phase; private GameObject _fx; private Light _ember; private ParticleSystem _smoke; private float _flickerSeed; private static readonly HashSet Active = new HashSet(); private static Material _fxMat; private bool _dizzyStarted; public void Begin(PlayerHolding holding, Item item) { //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_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) _item = item; _holding = holding; _rb = ((Component)item).GetComponent(); _startPos = ((Component)item).transform.position; _startRot = ((Component)item).transform.rotation; _flickerSeed = Random.value * 100f; _mouthValid = TryGetMouth(holding, out _cam, out _mouthLocal); SoundSwap.Swap(holding); if ((Object)(object)_rb != (Object)null) { _wasKinematic = _rb.isKinematic; _rb.isKinematic = true; _rb.detectCollisions = false; } Active.Add(item); CigarettePlugin.Log.LogInfo((object)("[CigaretteMod] 开始抽烟 (嘴部" + (_mouthValid ? "来自游戏数据" : "使用相机估算") + ")")); } private static bool TryGetMouth(PlayerHolding holding, out Transform cam, out Vector3 mouthLocal) { //IL_0004: 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_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) cam = null; mouthLocal = Vector3.zero; try { object value = AccessTools.Field(typeof(PlayerHolding), "_player").GetValue(holding); if (value == null) { return false; } object value2 = AccessTools.Field(typeof(Player), "_playerEating").GetValue(value); if (value2 == null) { return false; } FieldInfo fieldInfo = AccessTools.Field(typeof(PlayerEating), "_mouthPos"); if (fieldInfo == null) { return false; } mouthLocal = (Vector3)fieldInfo.GetValue(value2); PropertyInfo propertyInfo = AccessTools.Property(typeof(Player), "CamObject"); cam = (Transform)((propertyInfo != null) ? /*isinst with value type is only supported in some contexts*/: null); return (Object)(object)cam != (Object)null; } catch { return false; } } private Vector3 MouthWorld() { //IL_0058: 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_001d: 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) if (_mouthValid && (Object)(object)_cam != (Object)null) { return _cam.TransformPoint(_mouthLocal); } Camera main = Camera.main; if ((Object)(object)main != (Object)null) { return ((Component)main).transform.TransformPoint(new Vector3(0.04f, -0.16f, 0.22f)); } return _startPos; } private Vector3 ForwardHoriz() { //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_001a: 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_0041: 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_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_006d: 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) Vector3 forward = Vector3.forward; if ((Object)(object)_cam != (Object)null) { forward = _cam.forward; } else if ((Object)(object)Camera.main != (Object)null) { forward = ((Component)Camera.main).transform.forward; } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(forward.x, 0f, forward.z); if (((Vector3)(ref val)).sqrMagnitude < 1E-06f) { return Vector3.forward; } return ((Vector3)(ref val)).normalized; } private Vector3 AxisDir() { //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_000b: 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_001a: 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_0022: Unknown result type (might be due to invalid IL or missing references) Vector3 val = -ForwardHoriz() + Vector3.up * 0.22f; return ((Vector3)(ref val)).normalized; } private Quaternion TargetRot() { //IL_0000: 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_000b: Unknown result type (might be due to invalid IL or missing references) return Quaternion.FromToRotation(Vector3.up, AxisDir()); } private Vector3 TargetPos() { //IL_0006: 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_0027: 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) //IL_0038: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(Mathf.Abs(((Component)this).transform.localScale.y), 0.01f); return MouthWorld() - AxisDir() * (0.074f * num); } private void Update() { //IL_0058: 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_0064: 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: 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_00c7: 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) if ((Object)(object)_item == (Object)null) { TryStartDizzy(); Finish(); return; } _t += Time.deltaTime; if (_phase == 0) { float num = Mathf.SmoothStep(0f, 1f, _t / 0.7f); ((Component)this).transform.position = Vector3.Lerp(_startPos, TargetPos(), num); ((Component)this).transform.rotation = Quaternion.Slerp(_startRot, TargetRot(), num); if (_t >= 0.7f) { Ignite(); _phase = 1; _t = 0f; } } else if (_phase == 1) { ((Component)this).transform.position = TargetPos(); ((Component)this).transform.rotation = TargetRot(); if ((Object)(object)_ember != (Object)null) { _ember.intensity = 1.7f + Mathf.PerlinNoise(_flickerSeed, Time.time * 14f) * 1.1f; } if (_t >= 3f) { StopSmoke(); _phase = 2; _t = 0f; } } else if (_phase == 2) { if ((Object)(object)_ember != (Object)null) { _ember.intensity = Mathf.Max(0f, 1.7f * (1f - _t / 0.6f)); } if (_t >= 0.6f) { Finish(); } } } private void Ignite() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0046: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_012c: Expected O, but got Unknown //IL_0149: 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) _fx = new GameObject("CigFX"); _fx.transform.SetParent(((Component)_item).transform, false); _fx.transform.localPosition = new Vector3(0f, -0.058f, 0f); GameObject val = new GameObject("EmberLight"); val.transform.SetParent(_fx.transform, false); _ember = val.AddComponent(); _ember.type = (LightType)2; _ember.color = new Color(1f, 0.42f, 0.1f); _ember.range = 0.28f; _ember.intensity = 0.1f; _ember.shadows = (LightShadows)0; GameObject val2 = new GameObject("Spark"); val2.transform.SetParent(_fx.transform, false); val2.transform.rotation = Quaternion.LookRotation(Vector3.up); ParticleSystem obj = val2.AddComponent(); SetupSpark(obj); AssignFxMaterial(obj); obj.Play(); GameObject val3 = new GameObject("Smoke"); val3.transform.SetParent(_fx.transform, false); val3.transform.rotation = Quaternion.LookRotation(Vector3.up); _smoke = val3.AddComponent(); SetupSmoke(_smoke); AssignFxMaterial(_smoke); _smoke.Play(); } private static void AssignFxMaterial(ParticleSystem ps) { ParticleSystemRenderer component = ((Component)ps).GetComponent(); if (!((Object)(object)component == (Object)null)) { Material fxMaterial = GetFxMaterial(); if ((Object)(object)fxMaterial != (Object)null) { ((Renderer)component).sharedMaterial = fxMaterial; } } } private static Material GetFxMaterial() { //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Expected O, but got Unknown //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_fxMat != (Object)null) { return _fxMat; } string[] array = new string[9] { "dust", "ash", "smoke", "steam", "splash", "spit", "water", "particle", "fx" }; Object[] array2 = Resources.FindObjectsOfTypeAll(typeof(ParticleSystemRenderer)); Material val = null; int num = -1; Object[] array3 = array2; foreach (Object obj in array3) { ParticleSystemRenderer val2 = (ParticleSystemRenderer)(object)((obj is ParticleSystemRenderer) ? obj : null); if ((Object)(object)val2 == (Object)null || (Object)(object)((Renderer)val2).sharedMaterial == (Object)null || (Object)(object)((Renderer)val2).sharedMaterial.shader == (Object)null) { continue; } string text = ((Object)((Renderer)val2).sharedMaterial).name.ToLower(); int num2 = -1; for (int j = 0; j < array.Length; j++) { if (text.Contains(array[j])) { num2 = array.Length - j; break; } } if (num2 > num) { num = num2; val = ((Renderer)val2).sharedMaterial; } } if ((Object)(object)val != (Object)null) { _fxMat = new Material(val); if (_fxMat.HasProperty("_BaseColor")) { _fxMat.SetColor("_BaseColor", Color.white); } if (_fxMat.HasProperty("_Color")) { _fxMat.SetColor("_Color", Color.white); } CigarettePlugin.Log.LogInfo((object)("[CigaretteMod] 粒子材质: 克隆自游戏 '" + ((Object)val).name + "'")); return _fxMat; } Shader val3 = Shader.Find("Shader Graphs/DefaultParticle"); if ((Object)(object)val3 == (Object)null) { val3 = Shader.Find("Universal Render Pipeline/Particles/Unlit"); } if ((Object)(object)val3 == (Object)null) { val3 = Shader.Find("Sprites/Default"); } if ((Object)(object)val3 == (Object)null) { CigarettePlugin.Log.LogWarning((object)"[CigaretteMod] 找不到可用粒子shader"); return null; } _fxMat = new Material(val3); Texture2D val4 = MakeSoftCircleTex(); _fxMat.SetTexture("_BaseMap", (Texture)(object)val4); _fxMat.SetTexture("_MainTex", (Texture)(object)val4); if (_fxMat.HasProperty("_BaseColor")) { _fxMat.SetColor("_BaseColor", Color.white); } if (_fxMat.HasProperty("_Color")) { _fxMat.SetColor("_Color", Color.white); } _fxMat.SetFloat("_Surface", 1f); _fxMat.SetFloat("_Blend", 0f); _fxMat.SetInt("_SrcBlend", 5); _fxMat.SetInt("_DstBlend", 10); _fxMat.DisableKeyword("_ALPHATEST_ON"); _fxMat.EnableKeyword("_SURFACE_TYPE_TRANSPARENT"); _fxMat.renderQueue = 3000; CigarettePlugin.Log.LogInfo((object)("[CigaretteMod] 粒子材质: 兜底 " + ((Object)val3).name)); return _fxMat; } private static Texture2D MakeSoftCircleTex() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false); for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float num = ((float)j + 0.5f) / 64f - 0.5f; float num2 = ((float)i + 0.5f) / 64f - 0.5f; float num3 = Mathf.Sqrt(num * num + num2 * num2) / 0.5f; float num4 = Mathf.Clamp01(1f - num3); num4 = num4 * num4 * (3f - 2f * num4); val.SetPixel(j, i, new Color(1f, 1f, 1f, num4)); } } val.Apply(); return val; } private static void SetupSpark(ParticleSystem ps) { //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_0022: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00ac: 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_00cc: 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) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) MainModule main = ps.main; ((MainModule)(ref main)).duration = 0.1f; ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(0.28f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.15f, 0.45f); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.004f, 0.009f); ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(1f, 0.55f, 0.15f, 1f)); ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0.4f); ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).playOnAwake = false; EmissionModule emission = ps.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f); ((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1] { new Burst(0f, (short)16) }); ColorOverLifetimeModule colorOverLifetime = ps.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(new Color(1f, 0.7f, 0.3f, 1f), new Color(1f, 0.3f, 0.05f, 0f)); } private static void SetupSmoke(ParticleSystem ps) { //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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0073: 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_0089: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown //IL_0159: 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_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: 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_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) MainModule main = ps.main; ((MainModule)(ref main)).duration = 5f; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(1.5f, 2.4f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.22f, 0.4f); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.02f, 0.036f); ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.92f, 0.92f, 0.95f, 0.55f)); ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.015f); ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).playOnAwake = false; ((MainModule)(ref main)).maxParticles = 200; EmissionModule emission = ps.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(22f); ShapeModule shape = ps.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4; ((ShapeModule)(ref shape)).angle = 9f; ((ShapeModule)(ref shape)).radius = 0.006f; SizeOverLifetimeModule sizeOverLifetime = ps.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3] { new Keyframe(0f, 0.55f), new Keyframe(0.4f, 1f), new Keyframe(1f, 2.8f) })); ColorOverLifetimeModule colorOverLifetime = ps.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(new Color(0.95f, 0.95f, 0.98f, 0.15f), new Color(0.95f, 0.95f, 0.98f, 0.62f)); VelocityOverLifetimeModule velocityOverLifetime = ps.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = new MinMaxCurve(0.02f, 0.08f); } private void StopSmoke() { if ((Object)(object)_smoke != (Object)null) { _smoke.Stop(true, (ParticleSystemStopBehavior)1); } TryStartDizzy(); } private void TryStartDizzy() { if (!_dizzyStarted) { _dizzyStarted = true; StartDizzy(); } } private void StartDizzy() { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) try { Transform val = null; object value = AccessTools.Field(typeof(PlayerHolding), "_player").GetValue(_holding); if (value != null) { PropertyInfo propertyInfo = AccessTools.Property(typeof(Player), "CamObject"); if (propertyInfo != null) { object? value2 = propertyInfo.GetValue(value, null); val = (Transform)((value2 is Transform) ? value2 : null); } } if ((Object)(object)val == (Object)null && (Object)(object)Camera.main != (Object)null) { val = ((Component)Camera.main).transform; } if ((Object)(object)val == (Object)null) { CigarettePlugin.Log.LogWarning((object)"[CigaretteMod] 眩晕: 找不到玩家相机"); return; } CigarettePlugin.Log.LogInfo((object)("[CigaretteMod] 眩晕目标相机: " + ((Object)val).name)); new GameObject("CigDizzy").AddComponent().Begin(val); } catch (Exception ex) { CigarettePlugin.Log.LogWarning((object)("[CigaretteMod] 眩晕启动失败: " + ex.Message)); } } private void Finish() { if ((Object)(object)_item != (Object)null && (Object)(object)_rb != (Object)null) { _rb.isKinematic = _wasKinematic; _rb.detectCollisions = true; } if ((Object)(object)_item != (Object)null) { Active.Remove(_item); } if ((Object)(object)_fx != (Object)null) { Object.Destroy((Object)(object)_fx); } Object.Destroy((Object)(object)this); } private void OnDestroy() { TryStartDizzy(); if ((Object)(object)_item != (Object)null && (Object)(object)_rb != (Object)null && _rb.isKinematic && !_wasKinematic) { _rb.isKinematic = _wasKinematic; _rb.detectCollisions = true; } if ((Object)(object)_item != (Object)null) { Active.Remove(_item); } } }