using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LongerBelts")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP Inc.")]
[assembly: AssemblyProduct("LongerBelts")]
[assembly: AssemblyCopyright("Copyright © HP Inc. 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d20c6a87-29e6-41cd-88de-8d808362c85c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = "")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace LongerBelts;
[BepInPlugin("shisang_LongerBelts", "LongerBelts", "1.5.1")]
public class LongerBelts : BaseUnityPlugin
{
private bool DisplayingWindow = false;
private Rect windowRect = new Rect(200f, 200f, 600f, 400f);
public static bool shortestUnlimit = false;
public static float currentDistance = 1.9f;
public static float longitudeDistance = 1.75f;
public static float latitudeDistance = 1.5f;
private readonly float minimumGridDistance = 1f;
private readonly float maxmumGridDistance = 3f;
public static float minimum_distance = 0.400001f;
private readonly float maxmum_distance = 2.302172f;
public static int isometricSegmentation = 0;
public static bool longerOnGrid = false;
private int distance_units = 0;
private Translate UItexture;
public static float test;
private KeyboardShortcut enlargeWindow = new KeyboardShortcut((KeyCode)306, (KeyCode[])(object)new KeyCode[1] { (KeyCode)273 });
private KeyboardShortcut shortenWindow = new KeyboardShortcut((KeyCode)306, (KeyCode[])(object)new KeyCode[1] { (KeyCode)274 });
private ConfigEntry<KeyboardShortcut> SettingWindow { get; set; }
private ConfigEntry<float> WindowScale { get; set; }
private ConfigEntry<bool> LongerOnGrid { get; set; }
private ConfigEntry<int> IsometricSegmentation { get; set; }
private ConfigEntry<float> CurrentDistance { get; set; }
private ConfigEntry<float> LongitudeDistance { get; set; }
private ConfigEntry<float> LatitudeDistance { get; set; }
private void Awake()
{
Harmony.CreateAndPatchAll(typeof(LongerBelts), (string)null);
Debug.Log((object)"Add LongerBelts");
}
private void Start()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
SettingWindow = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("打开窗口快捷键/HotKey", "Key", new KeyboardShortcut((KeyCode)51, (KeyCode[])(object)new KeyCode[1] { (KeyCode)114 }), (ConfigDescription)null);
WindowScale = ((BaseUnityPlugin)this).Config.Bind<float>("默认窗口尺寸/WindowScale", "WindowScale", 200f, (ConfigDescription)null);
LongerOnGrid = ((BaseUnityPlugin)this).Config.Bind<bool>("更改经纬线模式默认跨度/Change default span in gridline mode", "Enable", false, (ConfigDescription)null);
IsometricSegmentation = ((BaseUnityPlugin)this).Config.Bind<int>("斜坡带模式/Slope Path Mode", "Enable", 0, "0为原始模式,1为阿基米德螺线模式/A value of 0 indicates the use of the default mode, whereas a value of 1 signifies the adoption of the Archimedean spiral pattern.");
CurrentDistance = ((BaseUnityPlugin)this).Config.Bind<float>("最远距离/Maximum Spacing", "Distance", 1.9f, (ConfigDescription)null);
LongitudeDistance = ((BaseUnityPlugin)this).Config.Bind<float>("沿纬线最远距离/Maximum Longitude Distance", "Distance", 1.75f, (ConfigDescription)null);
LatitudeDistance = ((BaseUnityPlugin)this).Config.Bind<float>("沿经线最远距离/Maximum Latitude Distance", "Distance", 1.5f, (ConfigDescription)null);
((Rect)(ref windowRect)).width = 3f * WindowScale.Value;
((Rect)(ref windowRect)).height = 2f * WindowScale.Value;
longerOnGrid = LongerOnGrid.Value;
isometricSegmentation = IsometricSegmentation.Value;
currentDistance = CurrentDistance.Value;
longitudeDistance = LongitudeDistance.Value;
latitudeDistance = LatitudeDistance.Value;
}
private void Update()
{
//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)
KeyboardShortcut value = SettingWindow.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
DisplayingWindow = !DisplayingWindow;
}
}
private void OnGUI()
{
//IL_000c: 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_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
//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)
if (DisplayingWindow)
{
GUI.backgroundColor = Color.gray;
UItexture = Translate.NewTexture();
windowRect = GUI.Window(20231008, windowRect, new WindowFunction(SetLongerBelts), "LongerBelts" + UItexture.resize_window);
}
}
public void SetLongerBelts(int winId)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Expected O, but got Unknown
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_069a: Unknown result type (might be due to invalid IL or missing references)
GUI.skin.label.fontSize = (int)(WindowScale.Value / 12f);
GUIStyle val = new GUIStyle(GUI.skin.toggle);
float num = 0.1f * WindowScale.Value;
val.fontSize = (int)(WindowScale.Value / 12f);
val.fixedHeight = num;
GUIStyle val2 = new GUIStyle(GUI.skin.horizontalSlider);
val2.fixedHeight = 0.05f * WindowScale.Value;
val2.stretchHeight = false;
val2.padding.top = (int)(val2.fixedHeight - num) / 2;
GUIStyle val3 = new GUIStyle(GUI.skin.horizontalSliderThumb);
val3.fixedHeight = num;
val3.fixedWidth = 0.05f * WindowScale.Value;
GUIStyle val4 = new GUIStyle(GUI.skin.textField);
val4.fontSize = (int)(WindowScale.Value / 12f);
GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref windowRect)).width, WindowScale.Value / 12f));
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
longerOnGrid = GUILayout.Toggle(longerOnGrid, UItexture.ifLongerOnGrid, val, Array.Empty<GUILayoutOption>());
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label(UItexture.longitudeDistance, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(0.7f * WindowScale.Value) });
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
GUILayout.Space(num / 2f);
longitudeDistance = GUILayout.HorizontalSlider(longitudeDistance, minimumGridDistance, maxmumGridDistance, val2, val3, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(0.4f * WindowScale.Value) });
GUILayout.EndVertical();
string s = GUILayout.TextField(longitudeDistance.ToString("0.000"), val4, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(0.25f * WindowScale.Value) });
if (float.TryParse(s, out var result) && result < maxmumGridDistance && result > minimumGridDistance)
{
longitudeDistance = result;
}
GUILayout.Label(UItexture.latitudeDistance, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(0.7f * WindowScale.Value) });
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
GUILayout.Space(num / 2f);
latitudeDistance = GUILayout.HorizontalSlider(latitudeDistance, minimumGridDistance, maxmumGridDistance, val2, val3, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(0.4f * WindowScale.Value) });
GUILayout.EndVertical();
s = GUILayout.TextField(latitudeDistance.ToString("0.000"), val4, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(0.25f * WindowScale.Value) });
if (float.TryParse(s, out result) && result < maxmumGridDistance && result > minimumGridDistance)
{
latitudeDistance = result;
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label(UItexture.distance_setting, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(1.5f * WindowScale.Value) });
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
GUILayout.Space(num / 2f);
currentDistance = GUILayout.HorizontalSlider(currentDistance, minimum_distance, maxmum_distance, val2, val3, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(0.5f * WindowScale.Value) });
GUILayout.EndVertical();
s = GUILayout.TextField(((distance_units == 1) ? (currentDistance / 1.256637f) : currentDistance).ToString("0.000000"), val4, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(0.7f * WindowScale.Value) });
if (float.TryParse(s, out result))
{
if (distance_units == 1)
{
result *= 1.256637f;
}
if (result < maxmum_distance && result > minimum_distance)
{
currentDistance = result;
}
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label(UItexture.distance_units, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(0.25f * WindowScale.Value) });
distance_units = GUILayout.SelectionGrid(distance_units, UItexture.distance_unitsStrings, 2, val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(1.5f * WindowScale.Value) });
GUILayout.EndHorizontal();
GUILayout.Label(UItexture.pathMode, Array.Empty<GUILayoutOption>());
isometricSegmentation = GUILayout.SelectionGrid(isometricSegmentation, UItexture.pathModeStrings, 1, val, Array.Empty<GUILayoutOption>());
GUILayout.Label("", Array.Empty<GUILayoutOption>());
GUILayout.Label(UItexture.WarningNotice, Array.Empty<GUILayoutOption>());
shortestUnlimit = GUILayout.Toggle(shortestUnlimit, UItexture.unlimit_distance_instruction, val, Array.Empty<GUILayoutOption>());
GUILayout.EndVertical();
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label(UItexture.unlimit_distance_setting, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(2f * WindowScale.Value) });
string s2 = GUILayout.TextField(((distance_units == 1) ? (currentDistance / 1.256637f) : currentDistance).ToString("0.000000"), val4, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(0.7f * WindowScale.Value) });
if (float.TryParse(s2, out result) && shortestUnlimit)
{
if (distance_units == 1)
{
result *= 1.256637f;
}
if (result < 0.001f)
{
result = 0.001f;
}
if (result > 999f)
{
result = 999f;
}
currentDistance = result;
}
GUILayout.EndHorizontal();
EatInputInRect(windowRect);
}
public static void EatInputInRect(Rect eatRect)
{
//IL_001d: 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_0038: Unknown result type (might be due to invalid IL or missing references)
if ((Input.GetMouseButton(0) || Input.GetMouseButtonDown(0)) && ((Rect)(ref eatRect)).Contains(new Vector2(Input.mousePosition.x, (float)Screen.height - Input.mousePosition.y)))
{
Input.ResetInputAxes();
}
}
public static int LongerSnapLineNonAlloc(PlanetGrid planetGrid, Vector3 begin, Vector3 end, int path, Vector3[] snaps, out int swerveIndex)
{
//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
//IL_04ff: 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_004b: 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_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: 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_0445: Unknown result type (might be due to invalid IL or missing references)
//IL_0447: Unknown result type (might be due to invalid IL or missing references)
//IL_044b: Unknown result type (might be due to invalid IL or missing references)
//IL_0450: Unknown result type (might be due to invalid IL or missing references)
//IL_0454: Unknown result type (might be due to invalid IL or missing references)
//IL_0459: Unknown result type (might be due to invalid IL or missing references)
//IL_0240: Unknown result type (might be due to invalid IL or missing references)
//IL_0245: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
//IL_0289: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: Unknown result type (might be due to invalid IL or missing references)
//IL_0290: Unknown result type (might be due to invalid IL or missing references)
//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
//IL_04db: Unknown result type (might be due to invalid IL or missing references)
//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
if (longerOnGrid)
{
swerveIndex = 0;
int num = snaps.Length - 10;
if (num <= 0)
{
return 0;
}
((Vector3)(ref begin)).Normalize();
((Vector3)(ref end)).Normalize();
float num2 = Mathf.Asin(begin.y);
float num3 = Mathf.Atan2(begin.x, 0f - begin.z);
float num4 = Mathf.Asin(end.y);
float num5 = Mathf.Atan2(end.x, 0f - end.z);
float num6 = Mathf.Repeat(num5 - num3, 6.283185f);
float num7 = Mathf.Max(Mathf.Abs(num2), Mathf.Abs(num4));
Vector3 normalized = ((Vector3)(ref begin)).normalized;
Vector3 normalized2 = ((Vector3)(ref end)).normalized;
int num8 = 0;
snaps[num8++] = normalized;
if ((double)num6 > 3.14159274101257)
{
num6 -= 6.283185f;
}
Vector3 val2;
if (path == 1)
{
float num9 = PlanetGrid.DetermineLongitudeSegmentCount(Mathf.FloorToInt(Mathf.Max(0f, Mathf.Abs(num2 / 6.283185f * (float)planetGrid.segment) - 0.1f)), planetGrid.segment);
if ((Mathf.Abs(num6) - (float)Math.PI / 2f) * num9 > ((float)Math.PI / 2f - num7) * 200f)
{
num6 = ((!(num6 > 0f)) ? (num6 + 3.141593f) : (num6 - 3.141593f));
num4 = (((double)num4 < 0.0) ? (-3.141593f - num4) : (3.141593f - num4));
}
float num10 = num3 + num6;
float num11 = num4 - num2;
int num12 = (int)(Mathf.Abs(num6) / ((float)Math.PI * 2f / 5f) * num9 / latitudeDistance) + 1;
if ((double)Mathf.Abs(num6) < 0.0001)
{
num12 = 0;
}
test = num9;
int num13 = (int)(Mathf.Abs(num11) / 0.0062831854f / longitudeDistance) + 1;
float num14 = Mathf.Cos(num2);
for (int i = 1; i <= num12; i++)
{
float num15 = num6 * (float)i / (float)num12;
snaps[num8++] = new Vector3(num14 * Mathf.Sin(num3 + num15), Mathf.Sin(num2), (0f - num14) * Mathf.Cos(num3 + num15));
}
swerveIndex = num8;
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(num14 * Mathf.Sin(num10), Mathf.Sin(num2), (0f - num14) * Mathf.Cos(num10));
val2 = normalized2 - val;
if (((Vector3)(ref val2)).magnitude < 0.00251f)
{
return num8;
}
for (int j = 1; j <= num13; j++)
{
float num16 = (float)j / (float)num13;
int num17 = num8++;
val2 = Vector3.Slerp(val, normalized2, num16);
snaps[num17] = ((Vector3)(ref val2)).normalized;
}
return num8;
}
float num18 = PlanetGrid.DetermineLongitudeSegmentCount(Mathf.FloorToInt(Mathf.Max(0f, Mathf.Abs(num4 / 6.283185f * (float)planetGrid.segment) - 0.1f)), planetGrid.segment);
if ((Mathf.Abs(num6) - (float)Math.PI / 2f) * num18 > ((float)Math.PI / 2f - num7) * 200f)
{
num6 = ((!(num6 > 0f)) ? (num6 + 3.141593f) : (num6 - 3.141593f));
num4 = (((double)num4 < 0.0) ? (-3.141593f - num4) : (3.141593f - num4));
}
float num19 = num4 - num2;
int num20 = (int)(Mathf.Abs(num6) / ((float)Math.PI * 2f / 5f) * num18 / latitudeDistance) + 1;
int num21 = (int)(Mathf.Abs(num19) / 0.0062831854f / longitudeDistance) + 1;
if ((double)Mathf.Abs(num19) < 0.0001)
{
num21 = 0;
}
float num22 = Mathf.Cos(num4);
Vector3 val3 = default(Vector3);
((Vector3)(ref val3))..ctor(num22 * Mathf.Sin(num3), Mathf.Sin(num4), (0f - num22) * Mathf.Cos(num3));
for (int k = 1; k <= num21; k++)
{
float num23 = (float)k / (float)num21;
int num24 = num8++;
val2 = Vector3.Slerp(normalized, val3, num23);
snaps[num24] = ((Vector3)(ref val2)).normalized;
}
swerveIndex = num8;
if (Mathf.Abs(num6) / ((float)Math.PI * 2f / 5f) * num18 < 0.4f)
{
return num8;
}
for (int l = 1; l <= num20; l++)
{
float num25 = num3 + (float)l / (float)num20 * num6;
snaps[num8++] = new Vector3(num22 * Mathf.Sin(num25), Mathf.Sin(num4), (0f - num22) * Mathf.Cos(num25));
}
return num8;
}
return planetGrid.SnapLineNonAlloc(begin, end, path, snaps, ref swerveIndex);
}
public static bool LongerGeodesic(Vector3 begin, Vector3 end, ref int counts, Vector3[] snaps)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0224: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Unknown result type (might be due to invalid IL or missing references)
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0302: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
int num = 150;
float num2 = ((((Vector3)(ref begin)).magnitude > ((Vector3)(ref end)).magnitude) ? ((Vector3)(ref begin)).magnitude : ((Vector3)(ref end)).magnitude);
Vector3 normalized = ((Vector3)(ref begin)).normalized;
Vector3 normalized2 = ((Vector3)(ref end)).normalized;
float num3 = Mathf.Acos(Mathf.Clamp(Vector3.Dot(normalized, normalized2), -1f, 1f)) * num2;
Vector3 val;
float num5;
int num6;
if (isometricSegmentation == 1)
{
float magnitude = ((Vector3)(ref begin)).magnitude;
float magnitude2 = ((Vector3)(ref end)).magnitude;
float num4 = Mathf.Abs(magnitude2 - magnitude);
num5 = Mathf.Sqrt(num3 * num3 + num4 * num4) / currentDistance;
if (!shortestUnlimit && Mathf.Sqrt(num3 * num3 + num4 * num4) / (float)((int)num5 + 1) < minimum_distance)
{
num5 = Mathf.Sqrt(num3 * num3 + num4 * num4) / minimum_distance - 1f;
}
num6 = (((double)num5 > 0.1) ? ((int)num5 + 1) : 0);
if (num6 == 0)
{
snaps[counts++] = normalized;
if ((double)Mathf.Abs(magnitude - magnitude2) > 0.001)
{
snaps[counts++] = snaps[0] * magnitude2;
return false;
}
}
else
{
for (int i = 0; i <= num6; i++)
{
if (counts >= num)
{
break;
}
float num7 = (float)i / (float)num6;
int num8 = counts++;
val = Vector3.Slerp(normalized, normalized2, num7);
snaps[num8] = ((Vector3)(ref val)).normalized;
}
}
for (int j = 0; j < counts; j++)
{
ref Vector3 reference = ref snaps[j];
reference *= magnitude * (float)(counts - 1 - j) / (float)(counts - 1) + magnitude2 * (float)j / (float)(counts - 1);
}
return false;
}
num5 = num3 / currentDistance;
if (!shortestUnlimit && Mathf.Acos(Vector3.Dot(normalized, normalized2)) * ((((Vector3)(ref begin)).magnitude < num2) ? ((Vector3)(ref begin)).magnitude : ((Vector3)(ref end)).magnitude) / (float)((int)num5 + 1) < minimum_distance)
{
num5 = Mathf.Acos(Vector3.Dot(normalized, normalized2)) * ((((Vector3)(ref begin)).magnitude < num2) ? ((Vector3)(ref begin)).magnitude : ((Vector3)(ref end)).magnitude) / minimum_distance - 1f;
}
num6 = (((double)num5 > 0.1) ? ((int)num5 + 1) : 0);
if (num6 == 0)
{
snaps[counts++] = normalized;
}
else
{
for (int k = 0; k <= num6; k++)
{
if (counts >= num)
{
break;
}
float num9 = (float)k / (float)num6;
int num10 = counts++;
val = Vector3.Slerp(normalized, normalized2, num9);
snaps[num10] = ((Vector3)(ref val)).normalized;
}
}
return true;
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(PlanetAuxData), "SnapLineNonAlloc")]
private static IEnumerable<CodeInstruction> PlanetAuxData_SnapLineNonAlloc_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Expected O, but got Unknown
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Expected O, but got Unknown
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Expected O, but got Unknown
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Expected O, but got Unknown
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Expected O, but got Unknown
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Expected O, but got Unknown
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Expected O, but got Unknown
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Expected O, but got Unknown
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Expected O, but got Unknown
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Expected O, but got Unknown
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, generator);
val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(PlanetGrid), "SnapLineNonAlloc", (Type[])null, (Type[])null), (string)null)
});
val.SetAndAdvance(OpCodes.Call, (object)AccessTools.Method(typeof(LongerBelts), "LongerSnapLineNonAlloc", (Type[])null, (Type[])null));
object operand = val.InstructionAt(-3).operand;
object operand2 = val.InstructionAt(1).operand;
val.Advance(5);
Label label = default(Label);
val.CreateLabelAt(val.Pos, ref label);
val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[11]
{
new CodeInstruction(OpCodes.Ldarg_3, (object)null),
new CodeInstruction(OpCodes.Ldc_I4_2, (object)null),
new CodeInstruction(OpCodes.Bne_Un_S, (object)label),
new CodeInstruction(OpCodes.Ldarg_1, (object)null),
new CodeInstruction(OpCodes.Ldarg_2, (object)null),
new CodeInstruction(OpCodes.Ldloca_S, (object)0),
new CodeInstruction(OpCodes.Ldarg_S, operand),
new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(LongerBelts), "LongerGeodesic", (Type[])null, (Type[])null)),
new CodeInstruction(OpCodes.Brtrue_S, operand2),
new CodeInstruction(OpCodes.Ldloc_0, (object)null),
new CodeInstruction(OpCodes.Ret, (object)null)
});
return val.InstructionEnumeration();
}
public static void SwitchBeltsPath(BuildTool_Path path)
{
if (path.pathSuggest > 0)
{
path.geodesic = false;
}
if (path.pathAlternative == 1)
{
path.pathAlternative = 2;
return;
}
path.pathAlternative = 1;
path.geodesic = false;
}
public static void SlantVerticalBelts(Vector3 begin, ref Vector3 end)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: 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_003f: 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_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: 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_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: 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)
Vector3 val = ((Vector3)(ref begin)).normalized - ((Vector3)(ref end)).normalized;
if (((Vector3)(ref val)).magnitude < 0.0001f)
{
Vector3 val2 = default(Vector3);
((Vector3)(ref val2))..ctor(0f, 0.001f, 0f);
if (Mathf.Abs(Vector3.Dot(((Vector3)(ref begin)).normalized, ((Vector3)(ref val2)).normalized)) > 0.99f)
{
((Vector3)(ref val2))..ctor(0.001f, 0f, 0f);
}
val2 = Vector3.Cross(end - begin, val2);
end += val2;
}
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(BuildTool_Path), "DeterminePreviews")]
private static IEnumerable<CodeInstruction> BuildTool_Path_DeterminePreviews_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Expected O, but got Unknown
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Expected O, but got Unknown
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Expected O, but got Unknown
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, generator);
val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
{
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(BuildTool_Path), "geodesic"), (string)null)
});
val.SetAndAdvance(OpCodes.Ldarg_0, (object)null);
val.SetAndAdvance(OpCodes.Call, (object)AccessTools.Method(typeof(LongerBelts), "SwitchBeltsPath", (Type[])null, (Type[])null));
val.SetAndAdvance(OpCodes.Nop, (object)null);
val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(PlanetAuxData), "SnapLineNonAlloc", (Type[])null, (Type[])null), (string)null)
});
object operand = val.InstructionAt(-22).operand;
object operand2 = val.InstructionAt(-21).operand;
val.Advance(-26).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3]
{
new CodeInstruction(OpCodes.Ldloc_S, operand),
new CodeInstruction(OpCodes.Ldloca_S, operand2),
new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(LongerBelts), "SlantVerticalBelts", (Type[])null, (Type[])null))
});
return val.InstructionEnumeration();
}
}
internal class Translate
{
public string ifLongerOnGrid;
public string longitudeDistance;
public string latitudeDistance;
public string distance_setting;
public string distance_units;
public string[] distance_unitsStrings = new string[2] { "米", "格(赤道)" };
public string pathMode;
public string[] pathModeStrings = new string[2] { "原版升降逻辑(水平移动一格后每节升降0.5层至目标高度)", "\"均匀\"升降(端点不水平,常规游戏需先在两端拉好水平带\n建议配合如建筑铺设无条件等放宽传送带铺设条件的功能使用)" };
public string WarningNotice;
public string unlimit_distance_instruction;
public string unlimit_distance_setting;
public string resize_window;
public static Translate NewTexture()
{
Translate translate = new Translate();
if (Localization.isZHCN)
{
translate.ifLongerOnGrid = "更改经纬线模式默认跨度";
translate.longitudeDistance = "沿经线时跨度";
translate.latitudeDistance = "沿纬线时跨度";
translate.distance_setting = "最大间距设置";
translate.distance_units = "单位:";
translate.distance_unitsStrings[0] = "米";
translate.distance_unitsStrings[1] = "格(赤道)";
translate.pathMode = "传送带路径";
translate.pathModeStrings[0] = "原版升降逻辑(水平移动一格后每节升降0.5层至目标高度)";
translate.pathModeStrings[1] = "垂直等距分割(端点不水平,常规游戏需先在两端拉好水平带\n建议配合如建筑铺设无条件等放宽传送带铺设条件的功能使用)";
translate.WarningNotice = "下列功能慎用!";
translate.unlimit_distance_instruction = "勾选以启用弱约束间距输入框(常规游戏中会出现传送带过短或过长等错误\n即使使用无条件铺设也可能触发特殊bug,造出的蓝图也未必能用)";
translate.unlimit_distance_setting = "弱约束间距输入框(配合铺设无条件作弊、测试用):";
translate.resize_window = "";
}
else
{
translate.ifLongerOnGrid = "Change default span in gridline mode";
translate.longitudeDistance = "Latitude Span";
translate.latitudeDistance = "Longitude Span";
translate.distance_setting = "Maximum Spacing(unit: meters, not grid)";
translate.distance_units = "Units:";
translate.distance_unitsStrings[0] = "meters";
translate.distance_unitsStrings[1] = "Grid(At equator)";
translate.pathMode = "Belt Path Mode";
translate.pathModeStrings[0] = "Original elevating logic(moving horizontally one grid and changing\nelevation by 0.5 units per segment to reach the target height)";
translate.pathModeStrings[1] = "Vertical equidistant(horizontal conveyor belts at both ends \n or other auxiliary mods are required)";
translate.WarningNotice = "Exercise caution when modifying the following settings!";
translate.unlimit_distance_instruction = "Check to enable the following input box(certain numbers can lead\nto errors such as belts being too short or too long during vanilla game.)";
translate.unlimit_distance_setting = "Maximum Spacing(less constraints)";
translate.resize_window = "";
}
return translate;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "LongerBelts";
public const string PLUGIN_NAME = "";
public const string PLUGIN_VERSION = "1.0.0.0";
}