Decompiled source of PointSpawn v0.2.2
plugins/PointSpawn.dll
Decompiled 3 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ChainDirectedBuild; using HarmonyLib; using MagicBeanDirectedGrowth; using Microsoft.CodeAnalysis; using Peak; using Photon.Pun; using UnityEngine; using Zorro.Core; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 MagicBeanDirectedGrowth { public class DirectedGrowthController : MonoBehaviour { private bool _selecting; private MagicBean _bean; private Vector3 _start; private Vector3 _startNormal; private Vector3 _spawnPos; private Vector3 _dir = Vector3.forward; private Vector3 _end; private float _distance; private float _reachable; private float _maxLength; private bool _overflow; private bool _blocked; private Color _color = Color.green; private float _horizontalDistance; private float _heightDiff; private float _pitchDeg; public static DirectedGrowthController Instance { get; private set; } public bool IsSelecting => _selecting; public Vector3 StartPos => _spawnPos; public Vector3 EndPos => _end; public float Reachable => _reachable; public float Distance => _distance; public float MaxLength => _maxLength; public bool Overflow => _overflow; public bool Blocked => _blocked; public Vector3 ReachableEndPos => _spawnPos + _dir * _reachable; public Vector3 Direction => _dir; public float HorizontalDistance => _horizontalDistance; public float HeightDiff => _heightDiff; public float PitchDeg => _pitchDeg; public Color CurrentColor => _color; public string StatusText { get { if (_blocked) { return L10n.T("被地形挡住", "Blocked"); } if (_overflow) { return L10n.T("超过最大长度", "Over max length"); } return L10n.T("正常", "OK"); } } private void Awake() { Instance = this; } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } Cancel(); } private void Update() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) if ((int)Plugin.LanguageKey.Value != 0 && Input.GetKeyDown(Plugin.LanguageKey.Value)) { Plugin.ToggleLanguage(); } if (!Plugin.Enabled.Value) { if (_selecting) { Cancel(); } return; } Character localCharacter = Character.localCharacter; MagicBean heldBean = GetHeldBean(localCharacter); bool num = (Object)(object)localCharacter != (Object)null && (Object)(object)localCharacter.data != (Object)null && !localCharacter.data.dead; if (_selecting && (Object)(object)heldBean == (Object)null) { Cancel(); } if (num && Input.GetKeyDown(Plugin.SelectKey.Value)) { if (_selecting) { Cancel(); return; } if ((Object)(object)heldBean != (Object)null && TryStartSelection(heldBean)) { UpdateSelection(heldBean); } } if (_selecting) { UpdateSelection(heldBean); } } private bool TryStartSelection(MagicBean bean) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)bean.plantPrefab == (Object)null) { return false; } if (!PointPicker.TryPickCrosshair(Plugin.MaxSelectDistance.Value, out var hit)) { return false; } _bean = bean; _start = ((RaycastHit)(ref hit)).point; Vector3 normal = ((RaycastHit)(ref hit)).normal; Vector3 startNormal; if (!(((Vector3)(ref normal)).sqrMagnitude > 1E-06f)) { startNormal = Vector3.up; } else { normal = ((RaycastHit)(ref hit)).normal; startNormal = ((Vector3)(ref normal)).normalized; } _startNormal = startNormal; _maxLength = Mathf.Max(0.5f, bean.plantPrefab.maxLength); _selecting = true; return true; } private void UpdateSelection(MagicBean bean) { //IL_004f: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00af: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_00f8: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_0117: 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_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_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)bean == (Object)null || (Object)(object)bean.plantPrefab == (Object)null) { Cancel(); return; } _bean = bean; Vector3 val; Vector3 val2; if (PointPicker.TryPickCrosshair(Plugin.MaxSelectDistance.Value, out var hit)) { val = ((RaycastHit)(ref hit)).point; val2 = val - _start; } else { val2 = PointPicker.CrosshairForward(); val = _start + val2 * _maxLength; } if (((Vector3)(ref val2)).sqrMagnitude < 1E-06f) { val2 = PointPicker.CrosshairForward(); } _dir = ((Vector3)(ref val2)).normalized; _end = val; _distance = Vector3.Distance(_start, val); _reachable = PointPicker.ReachableLength(_start, _startNormal, _dir, _distance, _maxLength, out _overflow, out _blocked); _spawnPos = _start + _startNormal * 0.1f; Vector3 val3 = val - _start; Vector2 val4 = new Vector2(val3.x, val3.z); _horizontalDistance = ((Vector2)(ref val4)).magnitude; _heightDiff = val3.y; _pitchDeg = Mathf.Asin(Mathf.Clamp(_dir.y, -1f, 1f)) * 57.29578f; Color fallback = default(Color); ((Color)(ref fallback))..ctor(0.2f, 0.8f, 0.4f, 1f); string raw = (_blocked ? Plugin.BlockedColor.Value : (_overflow ? Plugin.OverflowColor.Value : Plugin.NormalColor.Value)); _color = Plugin.ParseColor(raw, fallback); VinePreview.Show(bean, _spawnPos, _dir, _reachable, _color); } public bool TryCommitThrow(Character character, CharacterItems items) { //IL_0032: 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) if (!_selecting || (Object)(object)_bean == (Object)null || (Object)(object)_bean.plantPrefab == (Object)null) { return false; } if (!VineSpawner.TrySpawn(_bean, _spawnPos, _dir, _reachable)) { return false; } if (Plugin.ConsumeBean.Value) { ConsumeHeld(character, items); } Cancel(); return true; } public void Cancel() { _selecting = false; _bean = null; _overflow = false; _blocked = false; _reachable = 0f; _distance = 0f; _maxLength = 0f; VinePreview.Clear(); } private static void ConsumeHeld(Character character, CharacterItems items) { //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_0013: 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) try { Optionable<byte> currentSelectedSlot = items.currentSelectedSlot; items.DestroyHeldItemRpc(); character.player.EmptySlot(currentSelectedSlot, ((MonoBehaviourPun)character).photonView.IsMine); items.EquipSlot(Optionable<byte>.None); } catch (Exception ex) { Plugin.LogError("消耗魔豆失败:" + ex.Message); } } private static MagicBean GetHeldBean(Character character) { if ((Object)(object)character == (Object)null || (Object)(object)character.data == (Object)null) { return null; } Item currentItem = character.data.currentItem; if (!((Object)(object)currentItem == (Object)null)) { return ((Component)currentItem).GetComponent<MagicBean>(); } return null; } } public class HintOverlay : MonoBehaviour { private const float RefMarkerDistance = 12f; private const float BaseMarkerRadius = 9f; private GUIStyle _style; private Font _font; private Camera _cam; private Camera Cam { get { if ((Object)(object)_cam == (Object)null) { MainCamera instance = MainCamera.instance; _cam = (((Object)(object)instance != (Object)null) ? ((Component)instance).GetComponent<Camera>() : Camera.main); } return _cam; } } private void OnGUI() { //IL_003c: 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_0043: 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_0058: 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_006e: 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) DirectedGrowthController instance = DirectedGrowthController.Instance; if ((Object)(object)instance == (Object)null || !instance.IsSelecting || !Plugin.Enabled.Value) { return; } Camera cam = Cam; if (!((Object)(object)cam == (Object)null)) { EnsureStyle(); Vector3 startPos = instance.StartPos; Vector3 reachableEndPos = instance.ReachableEndPos; if (Plugin.ShowGuideLine.Value) { DrawGuide(cam, instance, startPos, reachableEndPos); } if (Plugin.ShowMarkers.Value) { DrawMarkers(cam, instance, startPos, reachableEndPos); } if (Plugin.ShowInfoBar.Value || Plugin.ShowHint.Value) { DrawInfo(instance); } } } private void DrawGuide(Camera cam, DirectedGrowthController controller, Vector3 start, Vector3 reach) { //IL_0001: 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_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) //IL_0039: 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_0058: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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) if (TryProject(cam, start, out var screen) && TryProject(cam, reach, out var screen2)) { float num = Mathf.Clamp(Plugin.LineWidth.Value, 1f, 12f); Color currentColor = controller.CurrentColor; SelectionOverlayDraw.DrawLine(screen, screen2, num, currentColor); if (Plugin.ShowTicks.Value) { DrawTicks(cam, controller, start, num); } SelectionOverlayDraw.DrawChevron(screen2, screen2 - screen, Mathf.Clamp(num * 4.5f, 9f, 24f), num, currentColor); } } private void DrawTicks(Camera cam, DirectedGrowthController controller, Vector3 start, float width) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_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_0047: 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_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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0082: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(Plugin.TickSpacing.Value, 0.5f, 50f); Vector3 direction = controller.Direction; int num2 = Mathf.FloorToInt(controller.Reachable / num); Color currentColor = controller.CurrentColor; currentColor.a = 0.8f; for (int i = 1; i <= num2; i++) { Vector3 val = start + direction * ((float)i * num); if (TryProject(cam, val, out var screen) && TryProject(cam, val + direction * 0.5f, out var screen2)) { SelectionOverlayDraw.DrawTick(screen, screen2 - screen, Mathf.Max(1f, width * 0.7f), 6f, currentColor); } } } private void DrawMarkers(Camera cam, DirectedGrowthController controller, Vector3 start, Vector3 reach) { //IL_0001: 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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (TryProject(cam, start, out var screen)) { SelectionOverlayDraw.DrawRing(screen, MarkerRadius(cam, start), new Color(0.3f, 0.7f, 1f, 0.95f)); } if (TryProject(cam, reach, out var screen2)) { SelectionOverlayDraw.DrawRing(screen2, MarkerRadius(cam, reach), controller.CurrentColor); } } private float MarkerRadius(Camera cam, Vector3 world) { //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) if (!Plugin.MarkerScaleByDistance.Value) { return 9f; } float num = Vector3.Distance(((Component)cam).transform.position, world); float num2 = Mathf.Clamp(12f / Mathf.Max(1f, num), 0.55f, 2.4f); return 9f * num2; } private void DrawInfo(DirectedGrowthController controller) { //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Expected O, but got Unknown //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_037b: 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_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) string text = controller.Distance.ToString("0.0"); string text2 = controller.HorizontalDistance.ToString("0.0"); string text3 = Signed(controller.HeightDiff); string text4 = controller.PitchDeg.ToString("0"); string text5 = controller.Reachable.ToString("0.0"); string text6 = controller.MaxLength.ToString("0.0"); string statusText = controller.StatusText; string text7 = L10n.T("距离 " + text + "m 水平 " + text2 + "m 高差 " + text3 + "m 仰角 " + text4 + "度", "Dist " + text + "m Horiz " + text2 + "m dY " + text3 + "m Pitch " + text4 + "°"); string text8 = L10n.T("长度 " + text5 + " / 上限 " + text6 + "m " + statusText, "Length " + text5 + " / Max " + text6 + "m " + statusText); string text9 = L10n.T("[" + ((object)Plugin.SelectKey.Value/*cast due to .constrained prefix*/).ToString() + "] 取消 投掷键 确认", "[" + ((object)Plugin.SelectKey.Value/*cast due to .constrained prefix*/).ToString() + "] Cancel Throw key Confirm"); string[] array = ((Plugin.ShowInfoBar.Value && Plugin.ShowHint.Value) ? new string[3] { text7, text8, text9 } : ((!Plugin.ShowInfoBar.Value) ? new string[1] { text9 } : new string[2] { text7, text8 })); float num = Mathf.Max(24f, (float)_style.fontSize + 8f); float num2 = 0f; for (int i = 0; i < array.Length; i++) { num2 = Mathf.Max(num2, _style.CalcSize(new GUIContent(array[i])).x); } float num3 = 10f; float num4 = num2 + num3 * 2f; float num5 = num * (float)array.Length + num3 * 2f; float num6 = Mathf.Clamp((float)Screen.width * 0.5f + 24f, 8f, Mathf.Max(8f, (float)Screen.width - num4 - 8f)); float num7 = Mathf.Clamp((float)Screen.height * 0.5f + 30f, 8f, Mathf.Max(8f, (float)Screen.height - num5 - 8f)); Rect rect = default(Rect); ((Rect)(ref rect))..ctor(num6, num7, num4, num5); SelectionOverlayDraw.DrawRect(rect, new Color(0f, 0f, 0f, 0.78f)); Rect val = default(Rect); for (int j = 0; j < array.Length; j++) { ((Rect)(ref val))..ctor(((Rect)(ref rect)).x + num3, ((Rect)(ref rect)).y + num3 + (float)j * num, num2, num); Color color = GUI.color; GUI.color = new Color(0f, 0f, 0f, 0.9f); GUI.Label(new Rect(((Rect)(ref val)).x + 1.5f, ((Rect)(ref val)).y + 1.5f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), array[j], _style); GUI.color = color; GUI.Label(val, array[j], _style); } } private static string Signed(float v) { return ((v >= 0f) ? "+" : "") + v.ToString("0.0"); } private static bool TryProject(Camera cam, Vector3 world, out Vector2 screen) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) Vector3 val = cam.WorldToScreenPoint(world); if (val.z <= 0.05f) { screen = default(Vector2); return false; } screen = new Vector2(val.x, (float)Screen.height - val.y); return true; } private void EnsureStyle() { //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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_006a: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) if (_style == null) { if ((Object)(object)_font == (Object)null) { _font = TryCreateCjkFont(); } _style = new GUIStyle(GUI.skin.label) { fontSize = 16, richText = false, wordWrap = false, clipping = (TextClipping)0, alignment = (TextAnchor)3, padding = new RectOffset(0, 0, 0, 0) }; if ((Object)(object)_font != (Object)null) { _style.font = _font; } _style.normal.textColor = Color.white; } } private static Font TryCreateCjkFont() { string[] array = new string[8] { "Microsoft YaHei UI", "Microsoft YaHei", "SimHei", "SimSun", "NSimSun", "Noto Sans CJK SC", "Source Han Sans SC", "Arial Unicode MS" }; try { Font val = Font.CreateDynamicFontFromOSFont(array, 16); if ((Object)(object)val != (Object)null) { return val; } } catch (Exception ex) { Plugin.LogInfo("加载中文字体失败,使用默认字体:" + ex.Message); } return null; } } internal enum Lang { Chinese, English } internal static class L10n { private static Lang _current; public static bool IsEnglish => _current == Lang.English; public static void Init(string setting) { _current = Parse(setting); } public static void Toggle() { _current = ((_current == Lang.Chinese) ? Lang.English : Lang.Chinese); } public static string T(string zh, string en) { if (_current != Lang.English) { return zh; } return en; } private static Lang Parse(string value) { if (!string.IsNullOrEmpty(value)) { switch (value.Trim().ToLowerInvariant()) { case "english": case "en": case "英文": return Lang.English; case "chinese": case "zh": case "中文": return Lang.Chinese; } } return Detect(); } private static Lang Detect() { //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_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 SystemLanguage systemLanguage = Application.systemLanguage; if ((int)systemLanguage != 6 && (int)systemLanguage != 40 && (int)systemLanguage != 41) { return Lang.English; } return Lang.Chinese; } } internal static class Plugin { public static ConfigEntry<string> Language; public static ConfigEntry<KeyCode> LanguageKey; public static ConfigEntry<bool> Enabled; public static ConfigEntry<KeyCode> SelectKey; public static ConfigEntry<bool> ConsumeBean; public static ConfigEntry<float> MaxSelectDistance; public static ConfigEntry<bool> ShowHint; public static ConfigEntry<bool> ShowGuideLine; public static ConfigEntry<bool> ShowMarkers; public static ConfigEntry<bool> ShowTicks; public static ConfigEntry<float> TickSpacing; public static ConfigEntry<float> LineWidth; public static ConfigEntry<bool> MarkerScaleByDistance; public static ConfigEntry<bool> ShowInfoBar; public static ConfigEntry<bool> PreviewPulse; public static ConfigEntry<float> PreviewAlpha; public static ConfigEntry<string> NormalColor; public static ConfigEntry<string> OverflowColor; public static ConfigEntry<string> BlockedColor; public static ConfigEntry<bool> LogSpawn; internal static ManualLogSource LoggerRef; internal static ConfigFile ConfigRef; private static GameObject _host; internal static void Init(ManualLogSource logger, ConfigFile config) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Expected O, but got Unknown //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Expected O, but got Unknown //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Expected O, but got Unknown //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Expected O, but got Unknown //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Expected O, but got Unknown //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Expected O, but got Unknown //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Expected O, but got Unknown //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Expected O, but got Unknown //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Expected O, but got Unknown //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Expected O, but got Unknown //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Expected O, but got Unknown //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Expected O, but got Unknown //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Expected O, but got Unknown //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Expected O, but got Unknown LoggerRef = logger; ConfigRef = config; Language = config.Bind<string>("MagicBean", "Language", "Auto", new ConfigDescription("界面语言 / UI language:Auto 跟随系统,可选 中文 / English。运行时用 LanguageKey 切换。", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "Auto", "中文", "English" }), Array.Empty<object>())); L10n.Init(Language.Value); LanguageKey = config.Bind<KeyCode>("MagicBean", "LanguageKey", (KeyCode)0, new ConfigDescription(L10n.T("切换中英双语的快捷键,None 表示关闭。", "Hotkey to toggle Chinese/English; None disables."), (AcceptableValueBase)null, Array.Empty<object>())); Enabled = config.Bind<bool>("MagicBean", "Enabled", true, new ConfigDescription(L10n.T("总开关。关闭后完全恢复原版行为。", "Master switch; disabling restores vanilla behavior."), (AcceptableValueBase)null, Array.Empty<object>())); SelectKey = config.Bind<KeyCode>("MagicBean", "SelectKey", (KeyCode)324, new ConfigDescription(L10n.T("选择起点 / 取消选择的按键。手持魔豆时按一下设定起点,再按一下取消。", "Select start / cancel key. With a magic bean in hand, press once to set the start, again to cancel."), (AcceptableValueBase)null, Array.Empty<object>())); ConsumeBean = config.Bind<bool>("MagicBean", "ConsumeBean", true, new ConfigDescription(L10n.T("生成藤蔓时是否消耗手中的魔豆(与原版一致)。", "Whether the held bean is consumed when the vine spawns (same as vanilla)."), (AcceptableValueBase)null, Array.Empty<object>())); MaxSelectDistance = config.Bind<float>("MagicBean", "MaxSelectDistance", 200f, new ConfigDescription(L10n.T("准星拾取地形点的最远距离(米)。", "Maximum distance for picking a terrain point with the crosshair (meters)."), (AcceptableValueBase)null, Array.Empty<object>())); ShowHint = config.Bind<bool>("MagicBean.Visual", "ShowHint", true, new ConfigDescription(L10n.T("选择期间显示操作提示文字。", "Show the control hint text while selecting."), (AcceptableValueBase)null, Array.Empty<object>())); ShowGuideLine = config.Bind<bool>("MagicBean.Visual", "ShowGuideLine", true, new ConfigDescription(L10n.T("从起点沿生长方向绘制引导射线与箭头(可穿墙看到)。", "Draw a guide ray and arrow from the start along the growth direction (visible through walls)."), (AcceptableValueBase)null, Array.Empty<object>())); ShowMarkers = config.Bind<bool>("MagicBean.Visual", "ShowMarkers", true, new ConfigDescription(L10n.T("标出起点与藤蔓顶端的标记(可穿墙看到)。", "Mark the start point and the vine tip (visible through walls)."), (AcceptableValueBase)null, Array.Empty<object>())); ShowTicks = config.Bind<bool>("MagicBean.Visual", "ShowTicks", true, new ConfigDescription(L10n.T("在引导射线上按固定间隔绘制距离刻度。", "Draw distance ticks at fixed intervals along the guide ray."), (AcceptableValueBase)null, Array.Empty<object>())); TickSpacing = config.Bind<float>("MagicBean.Visual", "TickSpacing", 2f, new ConfigDescription(L10n.T("刻度间隔(米)。", "Tick interval (meters)."), (AcceptableValueBase)null, Array.Empty<object>())); LineWidth = config.Bind<float>("MagicBean.Visual", "LineWidth", 2.5f, new ConfigDescription(L10n.T("引导射线线宽(像素)。", "Guide ray line width (pixels)."), (AcceptableValueBase)null, Array.Empty<object>())); MarkerScaleByDistance = config.Bind<bool>("MagicBean.Visual", "MarkerScaleByDistance", true, new ConfigDescription(L10n.T("端点标记是否按距离缩放(近大远小)。", "Scale markers by distance (near larger, far smaller)."), (AcceptableValueBase)null, Array.Empty<object>())); ShowInfoBar = config.Bind<bool>("MagicBean.Visual", "ShowInfoBar", true, new ConfigDescription(L10n.T("在准星旁显示距离 / 水平距离 / 高度差 / 俯仰角 / 状态。", "Show distance / horizontal distance / height difference / pitch / status near the crosshair."), (AcceptableValueBase)null, Array.Empty<object>())); PreviewPulse = config.Bind<bool>("MagicBean.Visual", "PreviewPulse", true, new ConfigDescription(L10n.T("预览藤蔓颜色明暗脉动,提示这是预览。", "Pulse the preview vine brightness to indicate it is a preview."), (AcceptableValueBase)null, Array.Empty<object>())); PreviewAlpha = config.Bind<float>("MagicBean.Visual", "PreviewAlpha", 0.85f, new ConfigDescription(L10n.T("预览藤蔓透明度(0.2~1)。着色器不支持透明时会自动回退为不透明。", "Preview vine opacity (0.2-1). Falls back to opaque if the shader does not support transparency."), (AcceptableValueBase)null, Array.Empty<object>())); NormalColor = config.Bind<string>("MagicBean.Visual", "NormalColor", "33CC66", new ConfigDescription(L10n.T("预览藤蔓正常(可完整到达终点)时的颜色,十六进制 RRGGBB。", "Preview color when the vine can fully reach the target, hex RRGGBB."), (AcceptableValueBase)null, Array.Empty<object>())); OverflowColor = config.Bind<string>("MagicBean.Visual", "OverflowColor", "FF8C1A", new ConfigDescription(L10n.T("终点超过藤蔓最大长度、被截断时的颜色,十六进制 RRGGBB。", "Preview color when the target exceeds the vine's max length, hex RRGGBB."), (AcceptableValueBase)null, Array.Empty<object>())); BlockedColor = config.Bind<string>("MagicBean.Visual", "BlockedColor", "E04040", new ConfigDescription(L10n.T("生长路径被地形挡住、无法到达终点时的颜色,十六进制 RRGGBB。", "Preview color when the growth path is blocked by terrain, hex RRGGBB."), (AcceptableValueBase)null, Array.Empty<object>())); LogSpawn = config.Bind<bool>("MagicBean.Debug", "LogSpawn", false, new ConfigDescription(L10n.T("生成藤蔓时在日志中输出信息。", "Log information when a vine is spawned."), (AcceptableValueBase)null, Array.Empty<object>())); _host = new GameObject("MagicBeanDirectedGrowthHost"); Object.DontDestroyOnLoad((Object)(object)_host); ((Object)_host).hideFlags = (HideFlags)61; _host.AddComponent<DirectedGrowthController>(); _host.AddComponent<HintOverlay>(); LogInfo("v0.3.0" + L10n.T(" 已加载。", " loaded.")); } internal static void Dispose() { if ((Object)(object)_host != (Object)null) { Object.Destroy((Object)(object)_host); _host = null; } } internal static void ToggleLanguage() { L10n.Toggle(); if (Language != null) { Language.Value = (L10n.IsEnglish ? "English" : "中文"); if (ConfigRef != null) { ConfigRef.Save(); } } } internal static Color ParseColor(string raw, Color fallback) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(raw)) { return fallback; } string text = raw.Trim(); if (!text.StartsWith("#")) { text = "#" + text; } Color result = default(Color); if (!ColorUtility.TryParseHtmlString(text, ref result)) { return fallback; } return result; } internal static void LogInfo(string msg) { if (LoggerRef != null) { LoggerRef.LogInfo((object)msg); } } internal static void LogError(string msg) { if (LoggerRef != null) { LoggerRef.LogError((object)msg); } } } internal static class PluginInfo { public const string GUID = "MagicBeanDirectedGrowth"; public const string NAME = "魔豆定向生长"; public const string VERSION = "0.3.0"; } internal static class PointPicker { private static readonly RaycastHit[] Buffer = (RaycastHit[])(object)new RaycastHit[128]; public static bool TryPickCrosshair(float maxDistance, out RaycastHit hit) { //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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) hit = default(RaycastHit); MainCamera instance = MainCamera.instance; if ((Object)(object)instance == (Object)null) { return false; } Transform transform = ((Component)instance).transform; hit = HelperFunctions.LineCheck(transform.position, transform.position + transform.forward * maxDistance, (LayerType)1, 0f, (QueryTriggerInteraction)1); return (Object)(object)((RaycastHit)(ref hit)).collider != (Object)null; } public static Vector3 CrosshairForward() { //IL_001b: 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) MainCamera instance = MainCamera.instance; if (!((Object)(object)instance != (Object)null)) { return Vector3.forward; } return ((Component)instance).transform.forward; } public static float ReachableLength(Vector3 start, Vector3 surfaceNormal, Vector3 dir, float distanceToEnd, float maxLength, out bool overflow, out bool blocked) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) overflow = distanceToEnd > maxLength; blocked = false; float num = Mathf.Min(distanceToEnd, maxLength); if (num <= 0.01f || ((Vector3)(ref dir)).sqrMagnitude < 1E-08f) { return 0.1f; } Vector3 val = start + surfaceNormal * 0.1f; float num2 = float.MaxValue; int num3 = HelperFunctions.LineCheckAll(val, val + dir * maxLength, (LayerType)1, Buffer, 0f, (QueryTriggerInteraction)1); for (int i = 0; i < num3; i++) { RaycastHit val2 = Buffer[i]; if (!((Object)(object)((RaycastHit)(ref val2)).collider == (Object)null) && !(((RaycastHit)(ref val2)).distance <= 0.7f) && ((RaycastHit)(ref val2)).distance < num2) { num2 = ((RaycastHit)(ref val2)).distance; } } float num4 = num; if (num2 < num - 0.05f) { num4 = num2; blocked = true; } return Mathf.Max(num4, 0.1f); } } internal static class SelectionOverlayDraw { private static Texture2D _px; private static Texture2D _ring; public static Texture2D Px { get { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_px == (Object)null) { _px = new Texture2D(1, 1, (TextureFormat)4, false); _px.SetPixel(0, 0, Color.white); _px.Apply(); ((Object)_px).hideFlags = (HideFlags)61; } return _px; } } public static Texture2D Ring { get { if ((Object)(object)_ring == (Object)null) { _ring = BuildRing(64); } return _ring; } } public static void DrawLine(Vector2 a, Vector2 b, float width, Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_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_0019: 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_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_0036: 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_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_0048: 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_005e: 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_0073: Unknown result type (might be due to invalid IL or missing references) Vector2 val = b - a; float magnitude = ((Vector2)(ref val)).magnitude; if (!(magnitude < 0.5f)) { float num = Mathf.Atan2(val.y, val.x) * 57.29578f; Matrix4x4 matrix = GUI.matrix; Color color2 = GUI.color; GUI.color = color; GUIUtility.RotateAroundPivot(num, a); GUI.DrawTexture(new Rect(a.x, a.y - width * 0.5f, magnitude, width), (Texture)(object)Px); GUI.matrix = matrix; GUI.color = color2; } } public static void DrawTicks(Vector2 a, Vector2 b, float width, float tickLen, Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) Vector2 val = b - a; float magnitude = ((Vector2)(ref val)).magnitude; if (!(magnitude < 1f)) { Vector2 val2 = val / magnitude; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0f - val2.y, val2.x); for (float num = 0f; num <= magnitude; num += 1f) { Vector2 val4 = a + val2 * num; DrawLine(val4 - val3 * tickLen, val4 + val3 * tickLen, width, color); } } } public static void DrawTick(Vector2 center, Vector2 dir, float width, float tickLen, Color color) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) Vector2 val = ((((Vector2)(ref dir)).sqrMagnitude > 1E-06f) ? ((Vector2)(ref dir)).normalized : Vector2.up); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f - val.y, val.x); DrawLine(center - val2 * tickLen, center + val2 * tickLen, width, color); } public static void DrawRing(Vector2 center, float radius, Color color) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (!(radius < 0.5f)) { Color color2 = GUI.color; GUI.color = color; GUI.DrawTexture(new Rect(center.x - radius, center.y - radius, radius * 2f, radius * 2f), (Texture)(object)Ring); GUI.color = color2; } } public static void DrawChevron(Vector2 tip, Vector2 dir, float size, float width, Color color) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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) if (!(((Vector2)(ref dir)).sqrMagnitude < 1E-06f)) { Vector2 normalized = ((Vector2)(ref dir)).normalized; Vector2 val = tip - normalized * size; Vector2 val2 = new Vector2(0f - normalized.y, normalized.x) * (size * 0.55f); DrawLine(tip, val + val2, width, color); DrawLine(tip, val - val2, width, color); } } public static void DrawRect(Rect rect, Color color) { //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_000b: Unknown result type (might be due to invalid IL or missing references) Color color2 = GUI.color; GUI.color = color; GUI.DrawTexture(rect, (Texture)(object)Px); GUI.color = color2; } private static Texture2D BuildRing(int size) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false); ((Object)val).hideFlags = (HideFlags)61; float num = (float)(size - 1) * 0.5f; float num2 = num - 1f; float num3 = num2 - 5f; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num4 = (float)j - num; float num5 = (float)i - num; float num6 = Mathf.Sqrt(num4 * num4 + num5 * num5); float num7 = Mathf.Clamp01(num2 - num6) * Mathf.Clamp01(num6 - num3); val.SetPixel(j, i, new Color(1f, 1f, 1f, num7)); } } val.Apply(); return val; } } [HarmonyPatch(typeof(CharacterItems), "DoDropping")] internal static class ThrowPatch { private static readonly FieldRef<CharacterItems, bool> PressedDropRef = AccessTools.FieldRefAccess<CharacterItems, bool>("pressedDrop"); private static readonly FieldRef<CharacterItems, float> ThrowChargeRef = AccessTools.FieldRefAccess<CharacterItems, float>("throwChargeLevel"); private static bool Prefix(CharacterItems __instance, Character ___character) { try { if (!Plugin.Enabled.Value) { return true; } if ((Object)(object)___character == (Object)null || !___character.IsLocal || (Object)(object)___character.data == (Object)null) { return true; } CharacterInput input = ___character.input; if ((Object)(object)input == (Object)null) { return true; } bool dropWasPressed = input.dropWasPressed; bool flag = input.dropWasReleased && PressedDropRef.Invoke(__instance); if (!dropWasPressed && !flag) { return true; } DirectedGrowthController instance = DirectedGrowthController.Instance; if ((Object)(object)instance == (Object)null || !instance.IsSelecting) { return true; } Item currentItem = ___character.data.currentItem; if ((Object)(object)currentItem == (Object)null || (Object)(object)((Component)currentItem).GetComponent<MagicBean>() == (Object)null) { return true; } if (instance.TryCommitThrow(___character, __instance)) { PressedDropRef.Invoke(__instance) = false; ThrowChargeRef.Invoke(__instance) = 0f; return false; } return true; } catch (Exception ex) { Plugin.LogError("拦截投掷异常:" + ex); return true; } } } internal static class VinePreview { private const string StalkPath = "VineOrigin/Stalk"; private static GameObject _root; private static GameObject _preview; private static readonly MaterialPropertyBlock Mpb = new MaterialPropertyBlock(); public static GameObject Root { get { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)_root == (Object)null) { _root = new GameObject("MagicBeanDirectedGrowthPreviewRoot"); Object.DontDestroyOnLoad((Object)(object)_root); ((Object)_root).hideFlags = (HideFlags)61; } return _root; } } public static void Show(MagicBean bean, Vector3 pos, Vector3 dir, float length, Color color) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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) if ((Object)(object)bean == (Object)null || (Object)(object)bean.plantPrefab == (Object)null) { Clear(); return; } if ((Object)(object)_preview == (Object)null) { _preview = Object.Instantiate<GameObject>(((Component)bean.plantPrefab).gameObject, Root.transform); if ((Object)(object)_preview == (Object)null) { return; } ((Object)_preview).name = "MagicBeanDirectedGrowthPreview"; SetLayerRecursive(_preview, 0); StripExtras(_preview); PurgePhysics(_preview); } _preview.transform.SetPositionAndRotation(pos, Quaternion.identity); if (((Vector3)(ref dir)).sqrMagnitude > 1E-06f) { _preview.transform.up = ((Vector3)(ref dir)).normalized; } Shape(_preview, length); ApplyColor(_preview, color); } public static void Clear() { if ((Object)(object)_preview != (Object)null) { Object.Destroy((Object)(object)_preview); } _preview = null; } private static void Shape(GameObject preview, float length) { //IL_0033: 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_008b: Unknown result type (might be due to invalid IL or missing references) MagicBeanVine component = preview.GetComponent<MagicBeanVine>(); if (!((Object)(object)component == (Object)null)) { float num = Mathf.Max(0.01f, length); component.growingSpeed = 1f; bool flag = false; try { component.RPC_GrowVine(num, float.MinValue, default(PhotonMessageInfo)); flag = true; } catch (Exception ex) { Plugin.LogError("预览藤蔓成型失败:" + ex.Message); } if (!flag && (Object)(object)component.vineOriginTransform != (Object)null) { float num2 = Mathf.Max(0.01f, component.maxWidth); component.vineOriginTransform.localScale = new Vector3(num2, num, num2); } component.growingSpeed = 0f; ((Behaviour)component).enabled = false; Animator[] componentsInChildren = preview.GetComponentsInChildren<Animator>(); for (int i = 0; i < componentsInChildren.Length; i++) { ((Behaviour)componentsInChildren[i]).enabled = false; } } } private static void ApplyColor(GameObject preview, Color color) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_0061: 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_0071: Unknown result type (might be due to invalid IL or missing references) Transform val = preview.transform.Find("VineOrigin/Stalk"); if ((Object)(object)val == (Object)null) { return; } Renderer component = ((Component)val).GetComponent<Renderer>(); if (!((Object)(object)component == (Object)null)) { Color val2 = color; if (Plugin.PreviewPulse.Value) { float num = 0.72f + 0.28f * Mathf.Sin(Time.unscaledTime * 6f); ((Color)(ref val2))..ctor(color.r * num, color.g * num, color.b * num, color.a); } val2.a = Mathf.Clamp(Plugin.PreviewAlpha.Value, 0.2f, 1f); component.GetPropertyBlock(Mpb); Mpb.SetColor("_Color", val2); Mpb.SetColor("_BaseColor", val2); component.SetPropertyBlock(Mpb); } } private static void StripExtras(GameObject preview) { PhotonCleanupHelper component = preview.GetComponent<PhotonCleanupHelper>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } for (int num = preview.transform.childCount - 1; num >= 0; num--) { Transform child = preview.transform.GetChild(num); if (((Object)child).name.StartsWith("VFX") || ((Object)child).name.StartsWith("SFX")) { Object.Destroy((Object)(object)((Component)child).gameObject); } } } private static void PurgePhysics(GameObject preview) { Collider[] componentsInChildren = preview.GetComponentsInChildren<Collider>(); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } Rigidbody[] componentsInChildren2 = preview.GetComponentsInChildren<Rigidbody>(); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.Destroy((Object)(object)componentsInChildren2[i]); } } private static void SetLayerRecursive(GameObject go, int layer) { go.layer = layer; for (int i = 0; i < go.transform.childCount; i++) { SetLayerRecursive(((Component)go.transform.GetChild(i)).gameObject, layer); } } } internal static class VineSpawner { public static bool TrySpawn(MagicBean bean, Vector3 pos, Vector3 dir, float length) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0057: 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_006d: 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) if ((Object)(object)bean == (Object)null || (Object)(object)bean.plantPrefab == (Object)null) { return false; } string text = "0_Items/" + ((Object)bean.plantPrefab).name; Quaternion rot = ((((Vector3)(ref dir)).sqrMagnitude > 1E-06f) ? Quaternion.FromToRotation(Vector3.up, ((Vector3)(ref dir)).normalized) : Quaternion.identity); GameObject val = InstantiatePrefab(text, pos, rot) ?? InstantiatePrefab(((Object)bean.plantPrefab).name, pos, rot); if ((Object)(object)val == (Object)null) { Plugin.LogError("藤蔓预制体实例化失败,预制体池中找不到:" + text); return false; } try { PhotonView component = val.GetComponent<PhotonView>(); if ((Object)(object)component == (Object)null) { Object.Destroy((Object)(object)val); return false; } if (!component.IsMine && PhotonNetwork.LocalPlayer != null) { component.TransferOwnership(PhotonNetwork.LocalPlayer); } component.RPC("RPC_GrowVine", (RpcTarget)0, new object[2] { Mathf.Max(0.1f, length), (float)PhotonNetwork.Time }); if (Plugin.LogSpawn.Value) { Plugin.LogInfo("生成定向藤蔓:" + text + " 位置=" + ((Vector3)(ref pos)).ToString("F2") + " 方向=" + ((Vector3)(ref dir)).ToString("F2") + " 长度=" + length.ToString("F2")); } return true; } catch (Exception ex) { Plugin.LogError("广播藤蔓生长失败:" + ex.Message); return false; } } private static GameObject InstantiatePrefab(string name, Vector3 pos, Quaternion rot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) try { return PhotonNetwork.Instantiate(name, pos, rot, (byte)0, (object[])null); } catch (Exception ex) { Plugin.LogInfo("Instantiate(" + name + ") 失败:" + ex.Message); return null; } } } } namespace ChainDirectedBuild { internal static class ChainPathSolver { private const int Attempts = 10; public static bool Solve(VineShooter shooter, Vector3 from, Vector3 to, out float hang, out Vector3 mid) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_0098: Unknown result type (might be due to invalid IL or missing references) hang = 0f; mid = Vector3.zero; JungleVine template = GetTemplate(shooter); if ((Object)(object)template == (Object)null) { return false; } float minDown = template.minDown; float maxDown = template.maxDown; Vector3 val = default(Vector3); for (int i = 0; i < 10; i++) { float num = (float)i / 9f; float num2 = Mathf.Lerp(minDown, 0f, num); float num3 = Mathf.Lerp(maxDown, 0f, num); float num4 = 0f - Mathf.Lerp(Mathf.Min(num2, num3), Mathf.Max(num2, num3), 0.5f); if (JungleVine.CheckVinePath(from, to, num4, ref val, 0f)) { hang = num4; mid = val; return true; } } return false; } public static JungleVine GetTemplate(VineShooter shooter) { if ((Object)(object)shooter == (Object)null || (Object)(object)shooter.vinePrefab == (Object)null) { return null; } return shooter.vinePrefab.GetComponentInChildren<JungleVine>(true); } } internal static class ChainPreview { private static GameObject _preview; private static GameObject _cachedPrefab; private static JungleVine _vine; private static Renderer _renderer; private static Material _material; private static Transform _meshT; private static Transform _hangCenter; private static float _meshLength = 40f; private static bool _shaped; public static bool HasPreview => (Object)(object)_preview != (Object)null; public static void Show(VineShooter shooter, Vector3 from, Vector3 to, float hang, Vector3 mid, Color color, bool pulse) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_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_00a1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)shooter == (Object)null || (Object)(object)shooter.vinePrefab == (Object)null) { return; } if ((Object)(object)_preview == (Object)null || (Object)(object)_cachedPrefab != (Object)(object)shooter.vinePrefab) { Build(shooter.vinePrefab); if ((Object)(object)_preview == (Object)null) { return; } } if (!_shaped) { try { _vine.ForceBuildVine(from, to, hang, mid); } catch (Exception ex) { Plugin.LogError("构建锁链预览失败:" + ex.Message); Clear(); return; } StripColliders(_preview); _shaped = true; } else { ApplyShape(from, to, hang, mid); } ApplyColor(color, pulse); } private static void Build(GameObject prefab) { Clear(); _cachedPrefab = prefab; _preview = Object.Instantiate<GameObject>(prefab); if ((Object)(object)_preview == (Object)null) { _cachedPrefab = null; return; } ((Object)_preview).name = "ChainDirectedBuild_Preview"; StripExtras(_preview); _vine = _preview.GetComponentInChildren<JungleVine>(true); _renderer = _preview.GetComponentInChildren<Renderer>(true); if ((Object)(object)_vine == (Object)null || (Object)(object)_renderer == (Object)null) { Plugin.LogError("锁链预制体缺少 JungleVine 或 Renderer"); Clear(); return; } _material = _renderer.material; _meshT = _preview.transform.Find("Mesh"); if ((Object)(object)_meshT == (Object)null) { _meshT = ((Component)_renderer).transform; } _hangCenter = _vine.hangCenter; _meshLength = ((_vine.meshLength > 0.01f) ? _vine.meshLength : 40f); _shaped = false; } private static void ApplyShape(Vector3 from, Vector3 to, float hang, Vector3 mid) { //IL_0018: 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_0023: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_009e: 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_00a0: 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_00c2: 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_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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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) if (!((Object)(object)_preview == (Object)null)) { _preview.transform.SetPositionAndRotation(from, Quaternion.identity); float num = Vector3.Distance(from, to) / _meshLength; Vector3 val = Vector3.Lerp(from, to, 0.5f); val.y += hang; if ((Object)(object)_material != (Object)null) { _material.SetFloat("_Hang", hang); _material.SetFloat("_LengthScale", (num < 0.5f) ? (num * 2f) : 1f); } if ((Object)(object)_hangCenter != (Object)null) { _hangCenter.position = QuadraticBezier(from, val, to, 0.5f); } if ((Object)(object)_meshT != (Object)null) { _meshT.rotation = Quaternion.LookRotation(to - from); _meshT.localScale = Vector3.one * num; } if ((Object)(object)_renderer != (Object)null) { Bounds localBounds = _renderer.localBounds; ((Bounds)(ref localBounds)).Encapsulate(((Component)_renderer).transform.InverseTransformPoint(val)); _renderer.localBounds = localBounds; } } } private static void ApplyColor(Color color, bool pulse) { //IL_000e: 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_005f: 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_0032: 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_0042: 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) if (!((Object)(object)_material == (Object)null)) { Color val = color; if (pulse) { float num = 0.72f + 0.28f * Mathf.Sin(Time.unscaledTime * 6f); ((Color)(ref val))..ctor(color.r * num, color.g * num, color.b * num, color.a); } _material.SetColor("_Color", val); _material.SetColor("_BaseColor", val); } } public static void Clear() { Material material = _material; if ((Object)(object)_preview != (Object)null) { Object.DestroyImmediate((Object)(object)_preview); } if ((Object)(object)material != (Object)null) { Object.DestroyImmediate((Object)(object)material); } _preview = null; _cachedPrefab = null; _vine = null; _renderer = null; _material = null; _meshT = null; _hangCenter = null; _shaped = false; } private static Vector3 QuadraticBezier(Vector3 start, Vector3 control, Vector3 end, float t) { //IL_000b: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_002e: Unknown result type (might be due to invalid IL or missing references) float num = 1f - t; return num * num * start + 2f * num * t * control + t * t * end; } private static void StripColliders(GameObject preview) { Collider[] componentsInChildren = preview.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } Rigidbody[] componentsInChildren2 = preview.GetComponentsInChildren<Rigidbody>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } } private static void StripExtras(GameObject preview) { Component[] componentsInChildren = preview.GetComponentsInChildren<Component>(true); foreach (Component val in componentsInChildren) { if ((Object)(object)val == (Object)null) { continue; } switch (((object)val).GetType().Name) { case "PhotonView": { Behaviour val3 = (Behaviour)(object)((val is Behaviour) ? val : null); if (val3 != null && val3.enabled) { val3.enabled = false; } break; } case "AudioSource": case "ParticleSystem": case "ParticleSystemRenderer": Object.DestroyImmediate((Object)(object)val); break; case "JungleVine": { Behaviour val2 = (Behaviour)(object)((val is Behaviour) ? val : null); if (val2 != null && val2.enabled) { val2.enabled = false; } break; } } } for (int num = preview.transform.childCount - 1; num >= 0; num--) { Transform child = preview.transform.GetChild(num); string name = ((Object)child).name; if (name.StartsWith("VFX") || name.StartsWith("SFX")) { Object.DestroyImmediate((Object)(object)((Component)child).gameObject); } } } } public class DirectedChainController : MonoBehaviour { private const float MinChainLength = 0.6f; private bool _selecting; private bool _hasTarget; private bool _blocked; private bool _overLength; private bool _suppressPrimary; private Vector3 _a; private Vector3 _b; private Vector3 _mid; private float _hang; private float _distance; private float _horizontalDistance; private float _heightDiff; private float _pitchDeg; private Color _color = Color.green; private static MethodInfo _incrementPlaced; public static DirectedChainController Instance { get; private set; } public bool IsSelecting => _selecting; public bool PrimarySuppressed => _suppressPrimary; public bool HasTarget => _hasTarget; public bool Blocked => _blocked; public bool OverLength => _overLength; public Vector3 StartPos => _a; public Vector3 EndPos => _b; public Vector3 Mid => _mid; public float Hang => _hang; public float Distance => _distance; public float HorizontalDistance => _horizontalDistance; public float HeightDiff => _heightDiff; public float PitchDeg => _pitchDeg; public Color CurrentColor => _color; public Vector3 Direction { get { //IL_0001: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) Vector3 val = _b - _a; if (!(((Vector3)(ref val)).sqrMagnitude > 1E-08f)) { return Vector3.forward; } return ((Vector3)(ref val)).normalized; } } public string StatusText { get { if (!_hasTarget) { return L10n.T("未命中目标", "No target"); } if (_blocked) { return L10n.T("被地形挡住", "Blocked"); } if (_overLength) { return L10n.T("超过最大长度(已截断)", "Over max length (clipped)"); } return L10n.T("可以架设", "Ready"); } } private void Awake() { Instance = this; } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } ChainPreview.Clear(); } private void Update() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) if ((int)Plugin.LanguageKey.Value != 0 && Input.GetKeyDown(Plugin.LanguageKey.Value)) { Plugin.ToggleLanguage(); } if (!Plugin.Enabled.Value) { if (_selecting) { Cancel(); } return; } Character localCharacter = Character.localCharacter; VineShooter val = HeldShooter(localCharacter); if (_selecting && (Object)(object)val == (Object)null) { Cancel(); } else if ((Object)(object)val != (Object)null && Input.GetKeyDown(Plugin.SelectKey.Value)) { if (_selecting) { Cancel(); return; } TryStartSelection(); if (_selecting) { UpdateSelection(val); } } else { if (_selecting) { UpdateSelection(val); } HandlePrimaryInput(localCharacter); } } private void HandlePrimaryInput(Character character) { if ((Object)(object)character == (Object)null || (Object)(object)character.data == (Object)null) { return; } CharacterInput input = character.input; if ((Object)(object)input == (Object)null) { return; } if (_suppressPrimary && !input.usePrimaryIsPressed) { _suppressPrimary = false; } if (_selecting && input.usePrimaryWasPressed) { Item currentItem = character.data.currentItem; if ((Object)(object)currentItem != (Object)null) { TryCommit(currentItem); MarkPrimarySuppressed(); } } } private bool TryStartSelection() { //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) if (!PointPicker.TryPickCrosshair(MaxChainLength(), out var hit)) { return false; } _a = ((RaycastHit)(ref hit)).point; _hasTarget = false; _blocked = false; _overLength = false; _distance = 0f; _horizontalDistance = 0f; _heightDiff = 0f; _pitchDeg = 0f; _selecting = true; return true; } private void UpdateSelection(VineShooter shooter) { //IL_0019: 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_003c: 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_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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_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_0123: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_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) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: 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_01be: 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_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)shooter == (Object)null || !_selecting) { return; } float num = MaxChainLength(); if (PointPicker.TryPickCrosshair(num + Vector3.Distance(GetCameraPos(), _a) + 5f, out var hit)) { _b = ((RaycastHit)(ref hit)).point; _hasTarget = true; } else { _hasTarget = false; } if (!_hasTarget) { _blocked = false; _overLength = false; _color = Plugin.NoTargetColorValue; ChainPreview.Clear(); return; } Vector3 val = _b - _a; _distance = ((Vector3)(ref val)).magnitude; if (_distance < 0.6f) { _blocked = true; _overLength = false; _color = Plugin.NoTargetColorValue; ChainPreview.Clear(); return; } _overLength = _distance > num + 0.001f; if (_overLength) { _b = _a + val / _distance * num; val = _b - _a; _distance = num; } Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(val.x, 0f, val.z); _horizontalDistance = ((Vector3)(ref val2)).magnitude; _heightDiff = val.y; _pitchDeg = Mathf.Asin(Mathf.Clamp(val.y / _distance, -1f, 1f)) * 57.29578f; if (ChainPathSolver.Solve(shooter, _a, _b, out var hang, out var mid)) { _hang = hang; _mid = mid; _blocked = false; _color = (_overLength ? Plugin.OverflowColorValue : Plugin.NormalColorValue); ChainPreview.Show(shooter, _a, _b, hang, mid, _color, Plugin.PreviewPulse.Value); } else { _blocked = true; _color = Plugin.BlockedColorValue; ChainPreview.Clear(); } } public bool TryCommit(Item item) { //IL_004f: 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_00eb: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) if (!_selecting) { return false; } VineShooter val = (((Object)(object)item != (Object)null) ? ((Component)item).GetComponentInChildren<VineShooter>(true) : null); if ((Object)(object)val == (Object)null) { Cancel(); return false; } if (!_hasTarget || _blocked) { return true; } GameObject val2 = null; try { val2 = PhotonNetwork.Instantiate(((Object)val.vinePrefab).name, _a, Quaternion.identity, (byte)0, (object[])null); } catch (Exception ex) { Plugin.LogError("生成锁链失败:" + ex.Message); } if ((Object)(object)val2 == (Object)null) { return false; } JungleVine val3 = val2.GetComponent<JungleVine>(); if ((Object)(object)val3 == (Object)null) { val3 = val2.GetComponentInChildren<JungleVine>(true); } if ((Object)(object)val3 == (Object)null) { Plugin.LogError("生成的锁链上找不到 JungleVine 组件"); return false; } PhotonView val4 = (((Object)(object)val3.photonView != (Object)null) ? val3.photonView : ((Component)val3).GetComponent<PhotonView>()); if ((Object)(object)val4 != (Object)null) { val4.RPC("ForceBuildVine_RPC", (RpcTarget)3, new object[4] { _a, _b, _hang, _mid }); } if ((Object)(object)val.disableOnFire != (Object)null) { val.disableOnFire.SetActive(false); } if (Plugin.ConsumeAmmo.Value) { Action_ReduceUses component = ((Component)val).GetComponent<Action_ReduceUses>(); if ((Object)(object)component != (Object)null) { ((ItemActionBase)component).RunAction(); } } IncrementPlaced(); if (Plugin.LogSpawn.Value) { Plugin.LogInfo($"架设锁链:A={_a} B={_b} hang={_hang:F2} 长度={_distance:F2}"); } Cancel(); return true; } public bool IsLocalChainItem(Item item) { if ((Object)(object)item == (Object)null) { return false; } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || (Object)(object)localCharacter.data == (Object)null || (Object)(object)localCharacter.data.currentItem != (Object)(object)item) { return false; } return (Object)(object)((Component)item).GetComponentInChildren<VineShooter>(true) != (Object)null; } public void MarkPrimarySuppressed() { _suppressPrimary = true; } public void Cancel() { _selecting = false; _hasTarget = false; _blocked = false; _overLength = false; _distance = 0f; ChainPreview.Clear(); } private static float MaxChainLength() { float value = Plugin.MaxLength.Value; if (!(value > 0.6f)) { return 0.6f; } return value; } private static Vector3 GetCameraPos() { //IL_001b: 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) MainCamera instance = MainCamera.instance; if (!((Object)(object)instance != (Object)null)) { return Vector3.zero; } return ((Component)instance).transform.position; } private static VineShooter HeldShooter(Character character) { if ((Object)(object)character == (Object)null || (Object)(object)character.data == (Object)null) { return null; } Item currentItem = character.data.currentItem; if ((Object)(object)currentItem == (Object)null) { return null; } return ((Component)currentItem).GetComponentInChildren<VineShooter>(true); } private static void IncrementPlaced() { try { GameUtils instance = GameUtils.instance; if (!((Object)(object)instance == (Object)null)) { if (_incrementPlaced == null) { _incrementPlaced = typeof(GameUtils).GetMethod("IncrementPermanentItemsPlaced", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } _incrementPlaced?.Invoke(instance, null); } } catch (Exception) { } } } public class HintOverlay : MonoBehaviour { private const float RefMarkerDistance = 12f; private const float BaseMarkerRadius = 9f; private const int CurveSegments = 20; private GUIStyle _style; private Font _font; private Camera _cam; private Camera Cam { get { if ((Object)(object)_cam == (Object)null) { MainCamera instance = MainCamera.instance; _cam = (((Object)(object)instance != (Object)null) ? ((Component)instance).GetComponent<Camera>() : Camera.main); } return _cam; } } private void OnGUI() { //IL_0049: 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_0074: 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_009a: 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_00a1: Unknown result type (might be due to invalid IL or missing references) DirectedChainController instance = DirectedChainController.Instance; if ((Object)(object)instance == (Object)null || !instance.IsSelecting || !Plugin.Enabled.Value) { return; } Camera cam = Cam; if ((Object)(object)cam == (Object)null) { return; } EnsureStyle(); if (Plugin.ShowMarkers.Value) { if (TryProject(cam, instance.StartPos, out var screen)) { DrawMarker(cam, instance.StartPos, screen, new Color(0.3f, 0.7f, 1f, 0.95f), end: false); } if (instance.HasTarget && TryProject(cam, instance.EndPos, out var screen2)) { DrawMarker(cam, instance.EndPos, screen2, instance.CurrentColor, end: true); } } if (Plugin.ShowGuideLine.Value) { DrawGuide(cam, instance); } if (Plugin.ShowInfoBar.Value || Plugin.ShowHint.Value) { DrawInfo(instance); } } private void DrawGuide(Camera cam, DirectedChainController controller) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_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_009c: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) if (!TryProject(cam, controller.StartPos, out var screen)) { return; } float width = Mathf.Clamp(Plugin.LineWidth.Value, 1f, 12f); Color currentColor = controller.CurrentColor; if (!controller.HasTarget || !TryProject(cam, controller.EndPos, out var screen2)) { return; } if (controller.Blocked) { SelectionOverlayDraw.DrawLine(screen, screen2, width, currentColor); return; } Vector3 mid = controller.Mid; Vector2 a = screen; for (int i = 1; i <= 20; i++) { float t = (float)i / 20f; Vector3 world = QuadraticBezier(controller.StartPos, mid, controller.EndPos, t); if (TryProject(cam, world, out var screen3)) { SelectionOverlayDraw.DrawLine(a, screen3, width, currentColor); a = screen3; } } if (Plugin.ShowTicks.Value) { SelectionOverlayDraw.DrawTicks(screen, screen2, width, 7f, currentColor); } } private void DrawMarker(Camera cam, Vector3 world, Vector2 screen, Color color, bool end) { //IL_004b: 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_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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_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) float num = 9f; if (Plugin.MarkerScaleByDistance.Value) { float num2 = Vector3.Distance(((Component)cam).transform.position, world); num = Mathf.Clamp(9f * (12f / Mathf.Max(num2, 1f)), 5f, 26f); } SelectionOverlayDraw.DrawRing(screen, num, color); if (end) { SelectionOverlayDraw.DrawRing(screen, num * 1.7f, new Color(color.r, color.g, color.b, color.a * 0.4f)); } } private void DrawInfo(DirectedChainController controller) { //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) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Expected O, but got Unknown //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(24f, 24f); string text = (controller.HasTarget ? L10n.T($"距离 {controller.Distance:F1} 米 水平 {controller.HorizontalDistance:F1} 米 高差 {controller.HeightDiff:F1} 米 仰角 {controller.PitchDeg:F0}°", $"Dist {controller.Distance:F1} m Horiz {controller.HorizontalDistance:F1} m dY {controller.HeightDiff:F1} m Pitch {controller.PitchDeg:F0}°") : L10n.T("将准星指向地形以选择终点", "Aim at terrain to pick the end point")); string text2 = L10n.T($"下垂 {controller.Hang:F1} 米 上限 {Plugin.MaxLength.Value:F0} 米 ", $"Sag {controller.Hang:F1} m Max {Plugin.MaxLength.Value:F0} m ") + controller.StatusText; string text3 = ((object)Plugin.SelectKey.Value/*cast due to .constrained prefix*/).ToString(); string text4 = L10n.T("[" + text3 + "] 取消 左键 架设", "[" + text3 + "] Cancel Left click Build"); string[] array = new string[3] { text, text2, text4 }; float num2 = 8f; float num3 = 0f; for (int i = 0; i < array.Length; i++) { num3 = Mathf.Max(num3, _style.CalcSize(new GUIContent(array[i])).x); } float num4 = num * (float)array.Length + num2 * 2f; float num5 = Mathf.Clamp((float)Screen.width * 0.5f + 24f, 8f, (float)Screen.width - num3 - num2 * 2f - 8f); float num6 = Mathf.Clamp((float)Screen.height * 0.5f + 30f, 8f, (float)Screen.height - num4 - 8f); SelectionOverlayDraw.DrawRect(new Rect(num5, num6, num3 + num2 * 2f, num4), new Color(0f, 0f, 0f, 0.78f)); for (int j = 0; j < array.Length; j++) { float num7 = num6 + num2 + (float)j * num; _style.normal.textColor = new Color(0f, 0f, 0f, 0.9f); GUI.Label(new Rect(num5 + num2 + 1.5f, num7 + 1.5f, num3 + 4f, num), array[j], _style); _style.normal.textColor = Color.white; GUI.Label(new Rect(num5 + num2, num7, num3 + 4f, num), array[j], _style); } } private static Vector3 QuadraticBezier(Vector3 start, Vector3 control, Vector3 end, float t) { //IL_000b: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_002e: Unknown result type (might be due to invalid IL or missing references) float num = 1f - t; return num * num * start + 2f * num * t * control + t * t * end; } private static bool TryProject(Camera cam, Vector3 world, out Vector2 screen) { //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_000c: 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_0012: