mirror of
https://github.com/soarqin/DSP_Mods_TO.git
synced 2026-02-04 14:12:18 +08:00
WIP
This commit is contained in:
@@ -4,9 +4,9 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<AssemblyName>AutoPilot</AssemblyName>
|
||||
<BepInExPluginGuid>tanu.AutoPilot</BepInExPluginGuid>
|
||||
<BepInExPluginGuid>org.soardev.AutoPilot</BepInExPluginGuid>
|
||||
<Description>DSP MOD - AutoPilot</Description>
|
||||
<Version>0.0.4</Version>
|
||||
<Version>0.1.0</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<RestoreAdditionalProjectSources>https://nuget.bepinex.dev/v3/index.json</RestoreAdditionalProjectSources>
|
||||
|
||||
@@ -6,61 +6,70 @@ namespace AutoPilot;
|
||||
|
||||
internal class AutoPilotConfigManager : ConfigManager
|
||||
{
|
||||
internal AutoPilotConfigManager(ConfigFile Config)
|
||||
: base(Config)
|
||||
public static void Init(ConfigFile config)
|
||||
{
|
||||
ConfigManager.Init<AutoPilotConfigManager>(config);
|
||||
}
|
||||
|
||||
protected override void CheckConfigImplements(Step step)
|
||||
{
|
||||
var ok = false;
|
||||
if (step == Step.Awake)
|
||||
switch (step)
|
||||
{
|
||||
var configEntry = Bind("Base", "ModVersion", "0.0.4", "Don't change.");
|
||||
configEntry.Value = "0.0.4";
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if (step is Step.Awake or Step.GameMainBegin)
|
||||
{
|
||||
AutoPilotDebugUI.Show = Bind("Debug", "DebugWindowShow", false).Value;
|
||||
AutoPilotPlugin.Conf.MinEnergyPer = Bind("Setting", "MinEnergyPer", 20).Value;
|
||||
AutoPilotPlugin.Conf.MaxSpeed = Bind("Setting", "MaxSpeed", 2000).Value;
|
||||
AutoPilotPlugin.Conf.WarpMinRangeAU = Bind("Setting", "WarpMinRangeAU", 2).Value;
|
||||
AutoPilotPlugin.Conf.SpeedToWarp = Bind("Setting", "WarpSpeed", 1200).Value;
|
||||
AutoPilotPlugin.Conf.LocalWarpFlag = Bind("Setting", "LocalWarp", false).Value;
|
||||
AutoPilotPlugin.Conf.AutoStartFlag = Bind("Setting", "AutoStart", true).Value;
|
||||
AutoPilotPlugin.Conf.MainWindowJoinFlag = Bind("Setting", "MainWindowJoin", true).Value;
|
||||
for (var i = 0; i < 2; i++)
|
||||
case Step.Awake:
|
||||
{
|
||||
AutoPilotMainUI.Rect[i].x = Bind("State", $"MainWindow{i}Left", 100).Value;
|
||||
AutoPilotMainUI.Rect[i].y = Bind("State", $"MainWindow{i}Top", 100).Value;
|
||||
AutoPilotConfigUI.Rect[i].x = Bind("State", $"ConfigWindow{i}Left", 100).Value;
|
||||
AutoPilotConfigUI.Rect[i].y = Bind("State", $"ConfigWindow{i}Top", 100).Value;
|
||||
var configEntry = Bind("Base", "ModVersion", "0.0.4", "Don't change.");
|
||||
configEntry.Value = "0.0.4";
|
||||
ok = true;
|
||||
goto case Step.GameMainBegin;
|
||||
}
|
||||
AutoPilotDebugUI.Rect.x = Bind("State", "DebugWindowLeft", 100).Value;
|
||||
AutoPilotDebugUI.Rect.y = Bind("State", "DebugWindowTop", 100).Value;
|
||||
}
|
||||
else if (step == Step.State)
|
||||
{
|
||||
LogManager.LogInfo("check state.");
|
||||
ok |= UpdateEntry("Setting", "MinEnergyPer", AutoPilotPlugin.Conf.MinEnergyPer);
|
||||
ok |= UpdateEntry("Setting", "MaxSpeed", AutoPilotPlugin.Conf.MaxSpeed);
|
||||
ok |= UpdateEntry("Setting", "WarpMinRangeAU", AutoPilotPlugin.Conf.WarpMinRangeAU);
|
||||
ok |= UpdateEntry("Setting", "WarpSpeed", AutoPilotPlugin.Conf.SpeedToWarp);
|
||||
ok |= UpdateEntry("Setting", "LocalWarp", AutoPilotPlugin.Conf.LocalWarpFlag);
|
||||
ok |= UpdateEntry("Setting", "AutoStart", AutoPilotPlugin.Conf.AutoStartFlag);
|
||||
ok |= UpdateEntry("Setting", "MainWindowJoin", AutoPilotPlugin.Conf.MainWindowJoinFlag);
|
||||
for (var j = 0; j < 2; j++)
|
||||
case Step.GameMainBegin:
|
||||
{
|
||||
ok |= UpdateEntry("State", $"MainWindow{j}Left", (int)AutoPilotMainUI.Rect[j].x);
|
||||
ok |= UpdateEntry("State", $"MainWindow{j}Top", (int)AutoPilotMainUI.Rect[j].y);
|
||||
ok |= UpdateEntry("State", $"ConfigWindow{j}Left", (int)AutoPilotConfigUI.Rect[j].x);
|
||||
ok |= UpdateEntry("State", $"ConfigWindow{j}Top", (int)AutoPilotConfigUI.Rect[j].y);
|
||||
AutoPilotDebugUI.Show = Bind("Debug", "DebugWindowShow", false).Value;
|
||||
AutoPilotPlugin.Conf.MinEnergyPer = Bind("Setting", "MinEnergyPer", 20).Value;
|
||||
AutoPilotPlugin.Conf.MaxSpeed = Bind("Setting", "MaxSpeed", 2000).Value;
|
||||
AutoPilotPlugin.Conf.WarpMinRangeAu = Bind("Setting", "WarpMinRangeAU", 2).Value;
|
||||
AutoPilotPlugin.Conf.SpeedToWarp = Bind("Setting", "WarpSpeed", 1200).Value;
|
||||
AutoPilotPlugin.Conf.LocalWarpFlag = Bind("Setting", "LocalWarp", false).Value;
|
||||
AutoPilotPlugin.Conf.AutoStartFlag = Bind("Setting", "AutoStart", true).Value;
|
||||
AutoPilotPlugin.Conf.MainWindowJoinFlag = Bind("Setting", "MainWindowJoin", true).Value;
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
AutoPilotMainUI.Rect[i].x = Bind("State", $"MainWindow{i}Left", 100).Value;
|
||||
AutoPilotMainUI.Rect[i].y = Bind("State", $"MainWindow{i}Top", 100).Value;
|
||||
AutoPilotConfigUI.Rect[i].x = Bind("State", $"ConfigWindow{i}Left", 100).Value;
|
||||
AutoPilotConfigUI.Rect[i].y = Bind("State", $"ConfigWindow{i}Top", 100).Value;
|
||||
}
|
||||
AutoPilotDebugUI.Rect.x = Bind("State", "DebugWindowLeft", 100).Value;
|
||||
AutoPilotDebugUI.Rect.y = Bind("State", "DebugWindowTop", 100).Value;
|
||||
break;
|
||||
}
|
||||
ok |= UpdateEntry("State", "DebugWindowLeft", (int)AutoPilotDebugUI.Rect.x);
|
||||
ok |= UpdateEntry("State", "DebugWindowTop", (int)AutoPilotDebugUI.Rect.y);
|
||||
AutoPilotMainUI.NextCheckGameTick = long.MaxValue;
|
||||
case Step.State:
|
||||
{
|
||||
LogManager.LogInfo("check state.");
|
||||
ok |= UpdateEntry("Setting", "MinEnergyPer", AutoPilotPlugin.Conf.MinEnergyPer);
|
||||
ok |= UpdateEntry("Setting", "MaxSpeed", AutoPilotPlugin.Conf.MaxSpeed);
|
||||
ok |= UpdateEntry("Setting", "WarpMinRangeAU", AutoPilotPlugin.Conf.WarpMinRangeAu);
|
||||
ok |= UpdateEntry("Setting", "WarpSpeed", AutoPilotPlugin.Conf.SpeedToWarp);
|
||||
ok |= UpdateEntry("Setting", "LocalWarp", AutoPilotPlugin.Conf.LocalWarpFlag);
|
||||
ok |= UpdateEntry("Setting", "AutoStart", AutoPilotPlugin.Conf.AutoStartFlag);
|
||||
ok |= UpdateEntry("Setting", "MainWindowJoin", AutoPilotPlugin.Conf.MainWindowJoinFlag);
|
||||
for (var j = 0; j < 2; j++)
|
||||
{
|
||||
ok |= UpdateEntry("State", $"MainWindow{j}Left", (int)AutoPilotMainUI.Rect[j].x);
|
||||
ok |= UpdateEntry("State", $"MainWindow{j}Top", (int)AutoPilotMainUI.Rect[j].y);
|
||||
ok |= UpdateEntry("State", $"ConfigWindow{j}Left", (int)AutoPilotConfigUI.Rect[j].x);
|
||||
ok |= UpdateEntry("State", $"ConfigWindow{j}Top", (int)AutoPilotConfigUI.Rect[j].y);
|
||||
}
|
||||
ok |= UpdateEntry("State", "DebugWindowLeft", (int)AutoPilotDebugUI.Rect.x);
|
||||
ok |= UpdateEntry("State", "DebugWindowTop", (int)AutoPilotDebugUI.Rect.y);
|
||||
AutoPilotMainUI.NextCheckGameTick = long.MaxValue;
|
||||
break;
|
||||
}
|
||||
case Step.UniverseGenCreateGalaxy:
|
||||
case Step.ChangeSeed:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
|
||||
@@ -19,7 +19,7 @@ internal class AutoPilotExtension : ICruiseAssistExtensionAPI
|
||||
|
||||
public void SetTargetAstroId(int astroId)
|
||||
{
|
||||
AutoPilotPlugin.State = (AutoPilotPlugin.Conf.AutoStartFlag ? AutoPilotState.Active : AutoPilotState.Inactive);
|
||||
AutoPilotPlugin.State = AutoPilotPlugin.Conf.AutoStartFlag ? AutoPilotState.Active : AutoPilotState.Inactive;
|
||||
AutoPilotPlugin.InputSailSpeedUp = false;
|
||||
}
|
||||
|
||||
@@ -33,17 +33,16 @@ internal class AutoPilotExtension : ICruiseAssistExtensionAPI
|
||||
var player = __instance.player;
|
||||
var mecha = player.mecha;
|
||||
AutoPilotPlugin.EnergyPer = mecha.coreEnergy / mecha.coreEnergyCap * 100.0;
|
||||
AutoPilotPlugin.Speed = player.controller.actionSail.visual_uvel.magnitude;
|
||||
AutoPilotPlugin.WarperCount = mecha.warpStorage.GetItemCount(1210);
|
||||
AutoPilotPlugin.LeavePlanet = true;
|
||||
AutoPilotPlugin.SpeedUp = false;
|
||||
AutoPilotPlugin.InputSailSpeedUp = false;
|
||||
var ignoreGravityFlag = AutoPilotPlugin.Conf.IgnoreGravityFlag;
|
||||
if (ignoreGravityFlag)
|
||||
if (AutoPilotPlugin.Conf.IgnoreGravityFlag)
|
||||
{
|
||||
player.controller.universalGravity = VectorLF3.zero;
|
||||
player.controller.localGravity = VectorLF3.zero;
|
||||
}
|
||||
|
||||
__instance.controller.input0.z = 1f;
|
||||
return true;
|
||||
}
|
||||
@@ -58,17 +57,16 @@ internal class AutoPilotExtension : ICruiseAssistExtensionAPI
|
||||
var player = __instance.player;
|
||||
var mecha = player.mecha;
|
||||
AutoPilotPlugin.EnergyPer = mecha.coreEnergy / mecha.coreEnergyCap * 100.0;
|
||||
AutoPilotPlugin.Speed = player.controller.actionSail.visual_uvel.magnitude;
|
||||
AutoPilotPlugin.WarperCount = mecha.warpStorage.GetItemCount(1210);
|
||||
AutoPilotPlugin.LeavePlanet = true;
|
||||
AutoPilotPlugin.SpeedUp = false;
|
||||
AutoPilotPlugin.InputSailSpeedUp = false;
|
||||
var ignoreGravityFlag = AutoPilotPlugin.Conf.IgnoreGravityFlag;
|
||||
if (ignoreGravityFlag)
|
||||
if (AutoPilotPlugin.Conf.IgnoreGravityFlag)
|
||||
{
|
||||
player.controller.universalGravity = VectorLF3.zero;
|
||||
player.controller.localGravity = VectorLF3.zero;
|
||||
}
|
||||
|
||||
__instance.controller.input0.z = 1f;
|
||||
return true;
|
||||
}
|
||||
@@ -83,21 +81,19 @@ internal class AutoPilotExtension : ICruiseAssistExtensionAPI
|
||||
var player = __instance.player;
|
||||
var mecha = player.mecha;
|
||||
AutoPilotPlugin.EnergyPer = mecha.coreEnergy / mecha.coreEnergyCap * 100.0;
|
||||
AutoPilotPlugin.Speed = player.controller.actionSail.visual_uvel.magnitude;
|
||||
AutoPilotPlugin.WarperCount = mecha.warpStorage.GetItemCount(1210);
|
||||
AutoPilotPlugin.LeavePlanet = true;
|
||||
AutoPilotPlugin.SpeedUp = false;
|
||||
AutoPilotPlugin.InputSailSpeedUp = false;
|
||||
var ignoreGravityFlag = AutoPilotPlugin.Conf.IgnoreGravityFlag;
|
||||
if (ignoreGravityFlag)
|
||||
if (AutoPilotPlugin.Conf.IgnoreGravityFlag)
|
||||
{
|
||||
player.controller.universalGravity = VectorLF3.zero;
|
||||
player.controller.localGravity = VectorLF3.zero;
|
||||
}
|
||||
|
||||
var controller = __instance.controller;
|
||||
controller.input0.y = controller.input0.y + 1f;
|
||||
var controller2 = __instance.controller;
|
||||
controller2.input1.y = controller2.input1.y + 1f;
|
||||
controller.input0.y += 1f;
|
||||
controller.input1.y += 1f;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -111,7 +107,6 @@ internal class AutoPilotExtension : ICruiseAssistExtensionAPI
|
||||
var player = __instance.player;
|
||||
var mecha = player.mecha;
|
||||
AutoPilotPlugin.EnergyPer = mecha.coreEnergy / mecha.coreEnergyCap * 100.0;
|
||||
AutoPilotPlugin.Speed = player.controller.actionSail.visual_uvel.magnitude;
|
||||
AutoPilotPlugin.WarperCount = mecha.warpStorage.GetItemCount(1210);
|
||||
AutoPilotPlugin.LeavePlanet = false;
|
||||
AutoPilotPlugin.SpeedUp = false;
|
||||
@@ -132,7 +127,8 @@ internal class AutoPilotExtension : ICruiseAssistExtensionAPI
|
||||
player.controller.localGravity = VectorLF3.zero;
|
||||
}
|
||||
|
||||
if (AutoPilotPlugin.Speed < AutoPilotPlugin.Conf.MaxSpeed)
|
||||
var speed = player.controller.actionSail.visual_uvel.magnitude;
|
||||
if (speed < AutoPilotPlugin.Conf.MaxSpeed)
|
||||
{
|
||||
AutoPilotPlugin.InputSailSpeedUp = true;
|
||||
AutoPilotPlugin.SpeedUp = true;
|
||||
@@ -141,7 +137,7 @@ internal class AutoPilotExtension : ICruiseAssistExtensionAPI
|
||||
if (GameMain.localPlanet == null)
|
||||
{
|
||||
if (!AutoPilotPlugin.Conf.LocalWarpFlag && GameMain.localStar != null && CruiseAssistPlugin.TargetStar.id == GameMain.localStar.id) return false;
|
||||
if (!(AutoPilotPlugin.Conf.WarpMinRangeAU * 40000.0 <= CruiseAssistPlugin.TargetRange) || !(AutoPilotPlugin.Conf.SpeedToWarp <= AutoPilotPlugin.Speed) ||
|
||||
if (!(AutoPilotPlugin.Conf.WarpMinRangeAu * 40000.0 <= CruiseAssistPlugin.TargetRange) || !(AutoPilotPlugin.Conf.SpeedToWarp <= speed) ||
|
||||
1 > AutoPilotPlugin.WarperCount) return false;
|
||||
if (!(mecha.coreEnergy > mecha.warpStartPowerPerSpeed * mecha.maxWarpSpeed)) return false;
|
||||
if (!mecha.UseWarper()) return false;
|
||||
@@ -150,11 +146,13 @@ internal class AutoPilotExtension : ICruiseAssistExtensionAPI
|
||||
return false;
|
||||
}
|
||||
|
||||
speed = player.uVelocity.magnitude;
|
||||
var vec = player.uPosition - GameMain.localPlanet.uPosition;
|
||||
if (120.0 < AutoPilotPlugin.Speed && Math.Max(GameMain.localPlanet.realRadius, 800f) < vec.magnitude - GameMain.localPlanet.realRadius)
|
||||
if (340.0 < speed && Math.Max(GameMain.localPlanet.realRadius, 900f) < vec.magnitude - GameMain.localPlanet.realRadius)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
VectorLF3 result;
|
||||
if (Vector3.Angle(player.uPosition - GameMain.localPlanet.uPosition, CruiseAssistPlugin.TargetUPos - GameMain.localPlanet.uPosition) > 90f)
|
||||
{
|
||||
@@ -165,10 +163,17 @@ internal class AutoPilotExtension : ICruiseAssistExtensionAPI
|
||||
{
|
||||
result = CruiseAssistPlugin.TargetUPos - player.uPosition;
|
||||
}
|
||||
var num = Vector3.Angle(result, player.uVelocity);
|
||||
var num2 = 1.6f / Mathf.Max(10f, num);
|
||||
var num3 = Math.Min(AutoPilotPlugin.Speed, 120.0);
|
||||
player.uVelocity = Vector3.Slerp(player.uVelocity, result.normalized * num3, num2);
|
||||
|
||||
var angle = Vector3.Angle(result, player.uVelocity);
|
||||
if (angle > 1.6f)
|
||||
{
|
||||
player.uVelocity = Vector3.Slerp(player.uVelocity, result.normalized * Math.Min(speed, 320.0), 1.6f / Mathf.Max(10f, angle));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.uVelocity = result.normalized * Math.Min(speed, 320.0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -186,51 +191,53 @@ internal class AutoPilotExtension : ICruiseAssistExtensionAPI
|
||||
|
||||
public void OnGUI()
|
||||
{
|
||||
var uiGame = UIRoot.instance.uiGame;
|
||||
var num = CruiseAssistMainUI.Scale / 100f;
|
||||
if (!_initialized)
|
||||
{
|
||||
_initialized = true;
|
||||
AutoPilotMainUI.OnInit();
|
||||
AutoPilotConfigUI.OnInit();
|
||||
AutoPilotDebugUI.OnInit();
|
||||
}
|
||||
|
||||
var scale = CruiseAssistMainUI.Scale / 100f;
|
||||
|
||||
AutoPilotMainUI.OnGUI();
|
||||
var flag = AutoPilotConfigUI.Show[CruiseAssistMainUI.WIdx];
|
||||
if (flag)
|
||||
if (AutoPilotConfigUI.Show[CruiseAssistMainUI.WIdx])
|
||||
{
|
||||
AutoPilotConfigUI.OnGUI();
|
||||
}
|
||||
var show = AutoPilotDebugUI.Show;
|
||||
if (show)
|
||||
|
||||
if (AutoPilotDebugUI.Show)
|
||||
{
|
||||
AutoPilotDebugUI.OnGUI();
|
||||
}
|
||||
var flag2 = ResetInput(AutoPilotMainUI.Rect[CruiseAssistMainUI.WIdx], num);
|
||||
var flag3 = !flag2 && AutoPilotConfigUI.Show[CruiseAssistMainUI.WIdx];
|
||||
if (flag3)
|
||||
|
||||
var resetInput = ResetInput(AutoPilotMainUI.Rect[CruiseAssistMainUI.WIdx], scale);
|
||||
if (!resetInput && AutoPilotConfigUI.Show[CruiseAssistMainUI.WIdx])
|
||||
{
|
||||
flag2 = ResetInput(AutoPilotConfigUI.Rect[CruiseAssistMainUI.WIdx], num);
|
||||
resetInput = ResetInput(AutoPilotConfigUI.Rect[CruiseAssistMainUI.WIdx], scale);
|
||||
}
|
||||
var flag4 = !flag2 && AutoPilotDebugUI.Show;
|
||||
if (flag4)
|
||||
|
||||
if (!resetInput && AutoPilotDebugUI.Show)
|
||||
{
|
||||
flag2 = ResetInput(AutoPilotDebugUI.Rect, num);
|
||||
ResetInput(AutoPilotDebugUI.Rect, scale);
|
||||
}
|
||||
}
|
||||
|
||||
private bool ResetInput(Rect rect, float scale)
|
||||
private static bool ResetInput(Rect rect, float scale)
|
||||
{
|
||||
var num = rect.xMin * scale;
|
||||
var num2 = rect.xMax * scale;
|
||||
var num3 = rect.yMin * scale;
|
||||
var num4 = rect.yMax * scale;
|
||||
var xMin = rect.xMin * scale;
|
||||
var xMax = rect.xMax * scale;
|
||||
var yMin = rect.yMin * scale;
|
||||
var yMax = rect.yMax * scale;
|
||||
var x = Input.mousePosition.x;
|
||||
var num5 = Screen.height - Input.mousePosition.y;
|
||||
var flag = num <= x && x <= num2 && num3 <= num5 && num5 <= num4;
|
||||
if (flag)
|
||||
{
|
||||
int[] array = { 0, 1, 2 };
|
||||
var flag2 = array.Any(Input.GetMouseButton) || Input.mouseScrollDelta.y != 0f;
|
||||
if (flag2)
|
||||
{
|
||||
Input.ResetInputAxes();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
if (!(xMin <= x) || !(x <= xMax) || !(yMin <= num5) || !(num5 <= yMax)) return false;
|
||||
if (!MouseButtonArray.Any(Input.GetMouseButton) && Input.mouseScrollDelta.y == 0f) return false;
|
||||
Input.ResetInputAxes();
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool _initialized;
|
||||
private static readonly int[] MouseButtonArray = [0, 1, 2];
|
||||
}
|
||||
@@ -2,22 +2,24 @@
|
||||
using AutoPilot.Enums;
|
||||
using AutoPilot.Patches;
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using CruiseAssist;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace AutoPilot;
|
||||
|
||||
[BepInDependency("tanu.CruiseAssist")]
|
||||
[BepInDependency("org.soardev.CruiseAssist")]
|
||||
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
|
||||
public class AutoPilotPlugin : BaseUnityPlugin
|
||||
{
|
||||
public void Awake()
|
||||
{
|
||||
LogManager.Logger = Logger;
|
||||
new AutoPilotConfigManager(Config);
|
||||
AutoPilotConfigManager.Init(new ConfigFile(Utility.CombinePaths(Paths.ConfigPath, "tanu.AutoPilot.cfg"), false, Info.Metadata));
|
||||
ConfigManager.CheckConfig(ConfigManager.Step.Awake);
|
||||
_harmony = new Harmony("tanu.AutoPilot.Patch");
|
||||
_harmony = new Harmony("org.soardev.AutoPilot.Patch");
|
||||
_harmony.PatchAll(typeof(Patch_VFInput));
|
||||
_harmony.PatchAll(typeof(UI.Strings));
|
||||
CruiseAssistPlugin.RegistExtension(new AutoPilotExtension());
|
||||
}
|
||||
|
||||
@@ -29,8 +31,6 @@ public class AutoPilotPlugin : BaseUnityPlugin
|
||||
|
||||
public static double EnergyPer = 0.0;
|
||||
|
||||
public static double Speed = 0.0;
|
||||
|
||||
public static int WarperCount = 0;
|
||||
|
||||
public static bool LeavePlanet = false;
|
||||
@@ -49,7 +49,7 @@ public class AutoPilotPlugin : BaseUnityPlugin
|
||||
|
||||
public static int MaxSpeed = 2000;
|
||||
|
||||
public static int WarpMinRangeAU = 2;
|
||||
public static int WarpMinRangeAu = 2;
|
||||
|
||||
public static int SpeedToWarp = 1200;
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ namespace AutoPilot.Commons;
|
||||
|
||||
internal abstract class ConfigManager
|
||||
{
|
||||
public static ConfigFile Config { get; private set; }
|
||||
|
||||
protected ConfigManager(ConfigFile config)
|
||||
private static ConfigFile Config { get; set; }
|
||||
|
||||
protected static void Init<T>(ConfigFile config) where T: ConfigManager, new()
|
||||
{
|
||||
_instance = this;
|
||||
_instance = new T();
|
||||
Config = config;
|
||||
Config.SaveOnConfigSet = false;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,35 @@
|
||||
using System;
|
||||
using CruiseAssist.UI;
|
||||
using CruiseAssist.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AutoPilot.UI;
|
||||
|
||||
internal static class AutoPilotConfigUI
|
||||
{
|
||||
public static void OnInit()
|
||||
{
|
||||
_labelStyle = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fontSize = 12,
|
||||
fixedHeight = 20f,
|
||||
alignment = TextAnchor.MiddleLeft
|
||||
};
|
||||
_textFieldStyle = new GUIStyle(CruiseAssistMainUI.BaseTextFieldStyle)
|
||||
{
|
||||
fontSize = 12,
|
||||
fixedWidth = 60f
|
||||
};
|
||||
_toggleStyle = new GUIStyle(CruiseAssistMainUI.BaseToggleStyle)
|
||||
{
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12,
|
||||
alignment = TextAnchor.LowerLeft
|
||||
};
|
||||
}
|
||||
|
||||
public static void OnGUI()
|
||||
{
|
||||
_wIdx = CruiseAssistMainUI.WIdx;
|
||||
Rect[_wIdx] = GUILayout.Window(99031292, Rect[_wIdx], WindowFunction, "AutoPilot - Config", CruiseAssistMainUI.WindowStyle, Array.Empty<GUILayoutOption>());
|
||||
Rect[_wIdx] = GUILayout.Window(99031292, Rect[_wIdx], WindowFunction, "AutoPilot - " + Strings.Get(0), CruiseAssistMainUI.WindowStyle);
|
||||
var scale = CruiseAssistMainUI.Scale / 100f;
|
||||
if (Screen.width / scale < Rect[_wIdx].xMax)
|
||||
{
|
||||
@@ -42,76 +62,59 @@ internal static class AutoPilotConfigUI
|
||||
LastCheckWindowTop[_wIdx] = Rect[_wIdx].y;
|
||||
}
|
||||
|
||||
public static void WindowFunction(int windowId)
|
||||
private static void WindowFunction(int windowId)
|
||||
{
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
var guistyle = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fontSize = 12,
|
||||
fixedHeight = 20f,
|
||||
alignment = TextAnchor.MiddleLeft
|
||||
};
|
||||
var guistyle2 = new GUIStyle(CruiseAssistMainUI.BaseTextFieldStyle)
|
||||
{
|
||||
fontSize = 12,
|
||||
fixedWidth = 60f
|
||||
};
|
||||
guistyle.fixedHeight = 20f;
|
||||
guistyle2.alignment = TextAnchor.MiddleRight;
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
guistyle.fixedWidth = 240f;
|
||||
GUILayout.Label("Min Energy Percent (0-100 default:20)".Translate(), guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginVertical();
|
||||
_labelStyle.fixedHeight = 20f;
|
||||
_textFieldStyle.alignment = TextAnchor.MiddleRight;
|
||||
GUILayout.BeginHorizontal();
|
||||
_labelStyle.fixedWidth = 240f;
|
||||
GUILayout.Label(Strings.Get(15), _labelStyle);
|
||||
GUILayout.FlexibleSpace();
|
||||
SetValue(ref TempMinEnergyPer, GUILayout.TextField(TempMinEnergyPer, guistyle2, Array.Empty<GUILayoutOption>()), 0, 100, ref AutoPilotPlugin.Conf.MinEnergyPer);
|
||||
guistyle.fixedWidth = 20f;
|
||||
GUILayout.Label("%", guistyle, Array.Empty<GUILayoutOption>());
|
||||
SetValue(ref TempMinEnergyPer, GUILayout.TextField(TempMinEnergyPer, _textFieldStyle), 0, 100, ref AutoPilotPlugin.Conf.MinEnergyPer);
|
||||
_labelStyle.fixedWidth = 20f;
|
||||
GUILayout.Label("%", _labelStyle);
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
guistyle.fixedWidth = 240f;
|
||||
GUILayout.Label("Max Speed (0-2000 default:2000)".Translate(), guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginHorizontal();
|
||||
_labelStyle.fixedWidth = 240f;
|
||||
GUILayout.Label(Strings.Get(16), _labelStyle);
|
||||
GUILayout.FlexibleSpace();
|
||||
SetValue(ref TempMaxSpeed, GUILayout.TextField(TempMaxSpeed, guistyle2, Array.Empty<GUILayoutOption>()), 0, 2000, ref AutoPilotPlugin.Conf.MaxSpeed);
|
||||
guistyle.fixedWidth = 20f;
|
||||
GUILayout.Label("m/s", guistyle, Array.Empty<GUILayoutOption>());
|
||||
SetValue(ref TempMaxSpeed, GUILayout.TextField(TempMaxSpeed, _textFieldStyle), 0, 2000, ref AutoPilotPlugin.Conf.MaxSpeed);
|
||||
_labelStyle.fixedWidth = 20f;
|
||||
GUILayout.Label("m/s", _labelStyle);
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
guistyle.fixedWidth = 240f;
|
||||
GUILayout.Label("Warp Min Range (1-60 default:2)".Translate(), guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginHorizontal();
|
||||
_labelStyle.fixedWidth = 240f;
|
||||
GUILayout.Label(Strings.Get(17), _labelStyle);
|
||||
GUILayout.FlexibleSpace();
|
||||
SetValue(ref TempWarpMinRangeAU, GUILayout.TextArea(TempWarpMinRangeAU, guistyle2, Array.Empty<GUILayoutOption>()), 1, 60, ref AutoPilotPlugin.Conf.WarpMinRangeAU);
|
||||
guistyle.fixedWidth = 20f;
|
||||
GUILayout.Label("AU", guistyle, Array.Empty<GUILayoutOption>());
|
||||
SetValue(ref TempWarpMinRangeAu, GUILayout.TextArea(TempWarpMinRangeAu, _textFieldStyle), 1, 60, ref AutoPilotPlugin.Conf.WarpMinRangeAu);
|
||||
_labelStyle.fixedWidth = 20f;
|
||||
GUILayout.Label("AU", _labelStyle);
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
guistyle.fixedWidth = 240f;
|
||||
GUILayout.Label("Speed to warp (0-2000 default:1200)".Translate(), guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginHorizontal();
|
||||
_labelStyle.fixedWidth = 240f;
|
||||
GUILayout.Label(Strings.Get(18), _labelStyle);
|
||||
GUILayout.FlexibleSpace();
|
||||
SetValue(ref TempSpeedToWarp, GUILayout.TextArea(TempSpeedToWarp, guistyle2, Array.Empty<GUILayoutOption>()), 0, 2000, ref AutoPilotPlugin.Conf.SpeedToWarp);
|
||||
guistyle.fixedWidth = 20f;
|
||||
GUILayout.Label("m/s", guistyle, Array.Empty<GUILayoutOption>());
|
||||
SetValue(ref TempSpeedToWarp, GUILayout.TextArea(TempSpeedToWarp, _textFieldStyle), 0, 2000, ref AutoPilotPlugin.Conf.SpeedToWarp);
|
||||
_labelStyle.fixedWidth = 20f;
|
||||
GUILayout.Label("m/s", _labelStyle);
|
||||
GUILayout.EndHorizontal();
|
||||
var guistyle3 = new GUIStyle(CruiseAssistMainUI.BaseToggleStyle)
|
||||
{
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12,
|
||||
alignment = TextAnchor.LowerLeft
|
||||
};
|
||||
GUI.changed = false;
|
||||
AutoPilotPlugin.Conf.LocalWarpFlag = GUILayout.Toggle(AutoPilotPlugin.Conf.LocalWarpFlag, "Warp to planet in local system.".Translate(), guistyle3, Array.Empty<GUILayoutOption>());
|
||||
AutoPilotPlugin.Conf.LocalWarpFlag = GUILayout.Toggle(AutoPilotPlugin.Conf.LocalWarpFlag, Strings.Get(19), _toggleStyle);
|
||||
if (GUI.changed)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
AutoPilotMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
GUI.changed = false;
|
||||
AutoPilotPlugin.Conf.AutoStartFlag = GUILayout.Toggle(AutoPilotPlugin.Conf.AutoStartFlag, "Start AutoPilot when set target planet.".Translate(), guistyle3, Array.Empty<GUILayoutOption>());
|
||||
AutoPilotPlugin.Conf.AutoStartFlag = GUILayout.Toggle(AutoPilotPlugin.Conf.AutoStartFlag, Strings.Get(20), _toggleStyle);
|
||||
if (GUI.changed)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
AutoPilotMainUI.NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
GUI.changed = false;
|
||||
AutoPilotPlugin.Conf.MainWindowJoinFlag = GUILayout.Toggle(AutoPilotPlugin.Conf.MainWindowJoinFlag, "Join AutoPilot window to CruiseAssist window.".Translate(), guistyle3, Array.Empty<GUILayoutOption>());
|
||||
AutoPilotPlugin.Conf.MainWindowJoinFlag = GUILayout.Toggle(AutoPilotPlugin.Conf.MainWindowJoinFlag, Strings.Get(21), _toggleStyle);
|
||||
if (GUI.changed)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
@@ -149,6 +152,10 @@ internal static class AutoPilotConfigUI
|
||||
|
||||
}
|
||||
|
||||
private static GUIStyle _labelStyle;
|
||||
private static GUIStyle _textFieldStyle;
|
||||
private static GUIStyle _toggleStyle;
|
||||
|
||||
private static int _wIdx;
|
||||
|
||||
public const float WindowWidth = 400f;
|
||||
@@ -157,20 +164,21 @@ internal static class AutoPilotConfigUI
|
||||
|
||||
public static readonly bool[] Show = new bool[2];
|
||||
|
||||
public static readonly Rect[] Rect = {
|
||||
new Rect(0f, 0f, 400f, 400f),
|
||||
new Rect(0f, 0f, 400f, 400f)
|
||||
};
|
||||
public static readonly Rect[] Rect =
|
||||
[
|
||||
new(0f, 0f, 400f, 400f),
|
||||
new(0f, 0f, 400f, 400f)
|
||||
];
|
||||
|
||||
private static readonly float[] LastCheckWindowLeft = { float.MinValue, float.MinValue };
|
||||
private static readonly float[] LastCheckWindowLeft = [float.MinValue, float.MinValue];
|
||||
|
||||
private static readonly float[] LastCheckWindowTop = { float.MinValue, float.MinValue };
|
||||
private static readonly float[] LastCheckWindowTop = [float.MinValue, float.MinValue];
|
||||
|
||||
public static string TempMinEnergyPer;
|
||||
|
||||
public static string TempMaxSpeed;
|
||||
|
||||
public static string TempWarpMinRangeAU;
|
||||
public static string TempWarpMinRangeAu;
|
||||
|
||||
public static string TempSpeedToWarp;
|
||||
}
|
||||
@@ -1,20 +1,32 @@
|
||||
using System;
|
||||
using AutoPilot.Commons;
|
||||
using AutoPilot.Commons;
|
||||
using CruiseAssist;
|
||||
using CruiseAssist.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AutoPilot.UI;
|
||||
|
||||
internal static class AutoPilotDebugUI
|
||||
{
|
||||
public static void OnGUI()
|
||||
public static void OnInit()
|
||||
{
|
||||
var guistyle = new GUIStyle(GUI.skin.window)
|
||||
_windowStyle = new GUIStyle(GUI.skin.window)
|
||||
{
|
||||
fontSize = 11
|
||||
};
|
||||
Rect = GUILayout.Window(99031293, Rect, WindowFunction, "AutoPilot - Debug", guistyle, Array.Empty<GUILayoutOption>());
|
||||
_labelStyle = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fontSize = 12
|
||||
};
|
||||
_toggleStyle = new GUIStyle(GUI.skin.toggle)
|
||||
{
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12,
|
||||
alignment = TextAnchor.LowerLeft
|
||||
};
|
||||
}
|
||||
|
||||
public static void OnGUI()
|
||||
{
|
||||
Rect = GUILayout.Window(99031293, Rect, WindowFunction, "AutoPilot - Debug", _windowStyle);
|
||||
|
||||
if (Screen.width < Rect.xMax)
|
||||
{
|
||||
@@ -53,13 +65,9 @@ internal static class AutoPilotDebugUI
|
||||
|
||||
private static void WindowFunction(int windowId)
|
||||
{
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
var guistyle = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fontSize = 12
|
||||
};
|
||||
_scrollPos = GUILayout.BeginScrollView(_scrollPos, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"GameMain.mainPlayer.uPosition={GameMain.mainPlayer.uPosition}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginVertical();
|
||||
_scrollPos = GUILayout.BeginScrollView(_scrollPos);
|
||||
GUILayout.Label($"GameMain.mainPlayer.uPosition={GameMain.mainPlayer.uPosition}", _labelStyle);
|
||||
if (GameMain.localPlanet != null && CruiseAssistPlugin.TargetUPos != VectorLF3.zero)
|
||||
{
|
||||
var mainPlayer = GameMain.mainPlayer;
|
||||
@@ -68,28 +76,22 @@ internal static class AutoPilotDebugUI
|
||||
var magnitude2 = (targetUPos - GameMain.localPlanet.uPosition).magnitude;
|
||||
var vectorLF = mainPlayer.uPosition - GameMain.localPlanet.uPosition;
|
||||
var vectorLF2 = CruiseAssistPlugin.TargetUPos - GameMain.localPlanet.uPosition;
|
||||
GUILayout.Label("range1=" + RangeToString(magnitude), guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label("range2=" + RangeToString(magnitude2), guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"range1>range2={magnitude > magnitude2}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"angle={Vector3.Angle(vectorLF, vectorLF2)}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label("range1=" + RangeToString(magnitude), _labelStyle);
|
||||
GUILayout.Label("range2=" + RangeToString(magnitude2), _labelStyle);
|
||||
GUILayout.Label($"range1>range2={magnitude > magnitude2}", _labelStyle);
|
||||
GUILayout.Label($"angle={Vector3.Angle(vectorLF, vectorLF2)}", _labelStyle);
|
||||
}
|
||||
var mecha = GameMain.mainPlayer.mecha;
|
||||
GUILayout.Label($"mecha.coreEnergy={mecha.coreEnergy}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"mecha.coreEnergyCap={mecha.coreEnergyCap}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"mecha.coreEnergy={mecha.coreEnergy}", _labelStyle);
|
||||
GUILayout.Label($"mecha.coreEnergyCap={mecha.coreEnergyCap}", _labelStyle);
|
||||
var energyPer = mecha.coreEnergy / mecha.coreEnergyCap * 100.0;
|
||||
GUILayout.Label($"energyPer={energyPer}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label($"energyPer={energyPer}", _labelStyle);
|
||||
var speed = GameMain.mainPlayer.controller.actionSail.visual_uvel.magnitude;
|
||||
GUILayout.Label("spped=" + RangeToString(speed), guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label("spped=" + RangeToString(speed), _labelStyle);
|
||||
var movementStateInFrame = GameMain.mainPlayer.controller.movementStateInFrame;
|
||||
GUILayout.Label($"movementStateInFrame={movementStateInFrame}", guistyle, Array.Empty<GUILayoutOption>());
|
||||
var guistyle2 = new GUIStyle(GUI.skin.toggle)
|
||||
{
|
||||
fixedHeight = 20f,
|
||||
fontSize = 12,
|
||||
alignment = TextAnchor.LowerLeft
|
||||
};
|
||||
GUILayout.Label($"movementStateInFrame={movementStateInFrame}", _labelStyle);
|
||||
GUI.changed = false;
|
||||
AutoPilotPlugin.Conf.IgnoreGravityFlag = GUILayout.Toggle(AutoPilotPlugin.Conf.IgnoreGravityFlag, "Ignore gravity.", guistyle2, Array.Empty<GUILayoutOption>());
|
||||
AutoPilotPlugin.Conf.IgnoreGravityFlag = GUILayout.Toggle(AutoPilotPlugin.Conf.IgnoreGravityFlag, "Ignore gravity.", _toggleStyle);
|
||||
if (GUI.changed)
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
@@ -114,6 +116,10 @@ internal static class AutoPilotDebugUI
|
||||
return (range / 2400000.0).ToString("0.00") + "Ly";
|
||||
}
|
||||
|
||||
private static GUIStyle _windowStyle;
|
||||
private static GUIStyle _labelStyle;
|
||||
private static GUIStyle _toggleStyle;
|
||||
|
||||
public static bool Show = false;
|
||||
|
||||
public static Rect Rect = new(0f, 0f, 400f, 400f);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using AutoPilot.Commons;
|
||||
using AutoPilot.Commons;
|
||||
using AutoPilot.Enums;
|
||||
using CruiseAssist;
|
||||
using CruiseAssist.Enums;
|
||||
@@ -10,6 +9,45 @@ namespace AutoPilot.UI;
|
||||
|
||||
internal static class AutoPilotMainUI
|
||||
{
|
||||
public static void OnInit()
|
||||
{
|
||||
_windowStyle = new GUIStyle(CruiseAssistMainUI.WindowStyle)
|
||||
{
|
||||
fontSize = 11
|
||||
};
|
||||
|
||||
_baseLabelStyle = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fontSize = 12
|
||||
};
|
||||
|
||||
_highlightedLabelStyle = new GUIStyle(_baseLabelStyle)
|
||||
{
|
||||
normal = { textColor = Color.cyan }
|
||||
};
|
||||
|
||||
_ngLabelStyle = new GUIStyle(_baseLabelStyle)
|
||||
{
|
||||
normal = { textColor = Color.red }
|
||||
};
|
||||
|
||||
_labelStyle = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fixedWidth = 160f,
|
||||
fixedHeight = 32f,
|
||||
fontSize = 14,
|
||||
alignment = TextAnchor.MiddleLeft
|
||||
};
|
||||
|
||||
_buttonStyle = new GUIStyle(CruiseAssistMainUI.BaseButtonStyle)
|
||||
{
|
||||
fixedWidth = 55f,
|
||||
fixedHeight = 18f,
|
||||
fontSize = 11,
|
||||
alignment = TextAnchor.MiddleCenter
|
||||
};
|
||||
}
|
||||
|
||||
public static void OnGUI()
|
||||
{
|
||||
_wIdx = CruiseAssistMainUI.WIdx;
|
||||
@@ -27,11 +65,8 @@ internal static class AutoPilotMainUI
|
||||
Rect[_wIdx].width = CruiseAssistMainUI.Rect[_wIdx].width;
|
||||
Rect[_wIdx].height = 150f;
|
||||
}
|
||||
var guistyle = new GUIStyle(CruiseAssistMainUI.WindowStyle)
|
||||
{
|
||||
fontSize = 11
|
||||
};
|
||||
Rect[_wIdx] = GUILayout.Window(99031291, Rect[_wIdx], WindowFunction, "AutoPilot", guistyle, Array.Empty<GUILayoutOption>());
|
||||
|
||||
Rect[_wIdx] = GUILayout.Window(99031291, Rect[_wIdx], WindowFunction, "AutoPilot", _windowStyle);
|
||||
var scale = CruiseAssistMainUI.Scale / 100f;
|
||||
if (AutoPilotPlugin.Conf.MainWindowJoinFlag)
|
||||
{
|
||||
@@ -61,12 +96,12 @@ internal static class AutoPilotMainUI
|
||||
|
||||
if (LastCheckWindowLeft[_wIdx] != float.MinValue)
|
||||
{
|
||||
var flag6 = Rect[_wIdx].x != LastCheckWindowLeft[_wIdx] || Rect[_wIdx].y != LastCheckWindowTop[_wIdx];
|
||||
if (flag6)
|
||||
if (Rect[_wIdx].x != LastCheckWindowLeft[_wIdx] || Rect[_wIdx].y != LastCheckWindowTop[_wIdx])
|
||||
{
|
||||
NextCheckGameTick = GameMain.gameTick + 300L;
|
||||
}
|
||||
}
|
||||
|
||||
LastCheckWindowLeft[_wIdx] = Rect[_wIdx].x;
|
||||
LastCheckWindowTop[_wIdx] = Rect[_wIdx].y;
|
||||
if (NextCheckGameTick <= GameMain.gameTick)
|
||||
@@ -77,88 +112,137 @@ internal static class AutoPilotMainUI
|
||||
|
||||
private static void WindowFunction(int windowId)
|
||||
{
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginVertical();
|
||||
if (CruiseAssistMainUI.ViewMode == CruiseAssistMainUIViewMode.Full)
|
||||
{
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
var guistyle = new GUIStyle(GUI.skin.label)
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.BeginVertical();
|
||||
int status;
|
||||
if (AutoPilotPlugin.State == AutoPilotState.Inactive)
|
||||
status = 0;
|
||||
else if (AutoPilotPlugin.EnergyPer <= AutoPilotPlugin.Conf.MinEnergyPer)
|
||||
status = 1;
|
||||
else
|
||||
status = 2;
|
||||
switch (status)
|
||||
{
|
||||
fontSize = 12
|
||||
};
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
var text = ((AutoPilotPlugin.State == AutoPilotState.Inactive) ? "---" : ((AutoPilotPlugin.Conf.MinEnergyPer < AutoPilotPlugin.EnergyPer) ? "OK" : "NG"));
|
||||
guistyle.normal.textColor = ((text == "OK") ? Color.cyan : ((text == "NG") ? Color.red : Color.white));
|
||||
GUILayout.Label("Energy : " + text, guistyle, Array.Empty<GUILayoutOption>());
|
||||
var text2 = ((AutoPilotPlugin.State == AutoPilotState.Inactive) ? "---" : ((CruiseAssistPlugin.TargetStar == null) ? "---" : (GameMain.mainPlayer.warping ? "---" : ((!AutoPilotPlugin.Conf.LocalWarpFlag && GameMain.localStar != null && CruiseAssistPlugin.TargetStar.id == GameMain.localStar.id) ? "---" : ((CruiseAssistPlugin.TargetRange < (double)(AutoPilotPlugin.Conf.WarpMinRangeAU * 40000)) ? "---" : ((AutoPilotPlugin.WarperCount < 1) ? "NG" : "OK"))))));
|
||||
guistyle.normal.textColor = ((text2 == "OK") ? Color.cyan : ((text2 == "NG") ? Color.red : Color.white));
|
||||
GUILayout.Label("Warper : " + text2, guistyle, Array.Empty<GUILayoutOption>());
|
||||
case 1:
|
||||
GUILayout.Label(Strings.Get(3) + " : " + Strings.Get(7), _ngLabelStyle);
|
||||
break;
|
||||
case 2:
|
||||
GUILayout.Label(Strings.Get(3) + " : " + Strings.Get(8), _highlightedLabelStyle);
|
||||
break;
|
||||
default:
|
||||
GUILayout.Label(Strings.Get(3) + " : ---", _baseLabelStyle);
|
||||
break;
|
||||
}
|
||||
if (AutoPilotPlugin.State == AutoPilotState.Inactive || CruiseAssistPlugin.TargetStar == null || GameMain.mainPlayer.warping ||
|
||||
(!AutoPilotPlugin.Conf.LocalWarpFlag && GameMain.localStar != null && CruiseAssistPlugin.TargetStar.id == GameMain.localStar.id) ||
|
||||
CruiseAssistPlugin.TargetRange < AutoPilotPlugin.Conf.WarpMinRangeAu * 40000)
|
||||
status = 0;
|
||||
else if (AutoPilotPlugin.WarperCount < 1)
|
||||
status = 1;
|
||||
else
|
||||
status = 2;
|
||||
switch (status)
|
||||
{
|
||||
case 1:
|
||||
GUILayout.Label(Strings.Get(4) + " : " + Strings.Get(7), _ngLabelStyle);
|
||||
break;
|
||||
case 2:
|
||||
GUILayout.Label(Strings.Get(4) + " : " + Strings.Get(8), _highlightedLabelStyle);
|
||||
break;
|
||||
default:
|
||||
GUILayout.Label(Strings.Get(4) + " : ---", _baseLabelStyle);
|
||||
break;
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
var text3 = ((AutoPilotPlugin.State == AutoPilotState.Inactive) ? "---" : (AutoPilotPlugin.LeavePlanet ? "ON" : "OFF"));
|
||||
guistyle.normal.textColor = ((text3 == "ON") ? Color.cyan : Color.white);
|
||||
GUILayout.Label("Leave Planet : " + text3, guistyle, Array.Empty<GUILayoutOption>());
|
||||
var text4 = ((AutoPilotPlugin.State == AutoPilotState.Inactive) ? "---" : (AutoPilotPlugin.SpeedUp ? "ON" : "OFF"));
|
||||
guistyle.normal.textColor = ((text4 == "ON") ? Color.cyan : Color.white);
|
||||
GUILayout.Label("Spee UP : " + text4, guistyle, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.BeginVertical();
|
||||
if (AutoPilotPlugin.State == AutoPilotState.Inactive)
|
||||
status = 0;
|
||||
else if (AutoPilotPlugin.LeavePlanet)
|
||||
status = 2;
|
||||
else
|
||||
status = 1;
|
||||
switch (status)
|
||||
{
|
||||
case 1:
|
||||
GUILayout.Label(Strings.Get(5) + " : " + Strings.Get(10), _baseLabelStyle);
|
||||
break;
|
||||
case 2:
|
||||
GUILayout.Label(Strings.Get(5) + " : " + Strings.Get(9), _highlightedLabelStyle);
|
||||
break;
|
||||
default:
|
||||
GUILayout.Label(Strings.Get(5) + " : ---", _baseLabelStyle);
|
||||
break;
|
||||
}
|
||||
|
||||
if (AutoPilotPlugin.State == AutoPilotState.Inactive)
|
||||
status = 0;
|
||||
else if (AutoPilotPlugin.SpeedUp)
|
||||
status = 2;
|
||||
else
|
||||
status = 1;
|
||||
switch (status)
|
||||
{
|
||||
case 1:
|
||||
GUILayout.Label(Strings.Get(6) + " : " + Strings.Get(12), _baseLabelStyle);
|
||||
break;
|
||||
case 2:
|
||||
GUILayout.Label(Strings.Get(6) + " : " + Strings.Get(11), _highlightedLabelStyle);
|
||||
break;
|
||||
default:
|
||||
GUILayout.Label(Strings.Get(6) + " : ---", _baseLabelStyle);
|
||||
break;
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.FlexibleSpace();
|
||||
}
|
||||
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
|
||||
var guistyle2 = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fixedWidth = 160f,
|
||||
fixedHeight = 32f,
|
||||
fontSize = 14,
|
||||
alignment = TextAnchor.MiddleLeft
|
||||
};
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
if (AutoPilotPlugin.State == AutoPilotState.Inactive)
|
||||
{
|
||||
GUILayout.Label("Auto Pilot Inactive.", guistyle2, Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Label(Strings.Get(13), _labelStyle);
|
||||
}
|
||||
else
|
||||
{
|
||||
guistyle2.normal.textColor = Color.cyan;
|
||||
GUILayout.Label("Auto Pilot Active.", guistyle2, Array.Empty<GUILayoutOption>());
|
||||
_labelStyle.normal.textColor = Color.cyan;
|
||||
GUILayout.Label(Strings.Get(14), _labelStyle);
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
var guistyle3 = new GUIStyle(CruiseAssistMainUI.BaseButtonStyle)
|
||||
{
|
||||
fixedWidth = 50f,
|
||||
fixedHeight = 18f,
|
||||
fontSize = 11,
|
||||
alignment = TextAnchor.MiddleCenter
|
||||
};
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
if (GUILayout.Button("Config", guistyle3, Array.Empty<GUILayoutOption>()))
|
||||
GUILayout.BeginVertical();
|
||||
if (GUILayout.Button(Strings.Get(0), _buttonStyle))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
var show = AutoPilotConfigUI.Show;
|
||||
var num = _wIdx;
|
||||
show[num] = !show[num];
|
||||
var flag4 = AutoPilotConfigUI.Show[_wIdx];
|
||||
if (flag4)
|
||||
if (AutoPilotConfigUI.Show[_wIdx])
|
||||
{
|
||||
AutoPilotConfigUI.TempMinEnergyPer = AutoPilotPlugin.Conf.MinEnergyPer.ToString();
|
||||
AutoPilotConfigUI.TempMaxSpeed = AutoPilotPlugin.Conf.MaxSpeed.ToString();
|
||||
AutoPilotConfigUI.TempWarpMinRangeAU = AutoPilotPlugin.Conf.WarpMinRangeAU.ToString();
|
||||
AutoPilotConfigUI.TempWarpMinRangeAu = AutoPilotPlugin.Conf.WarpMinRangeAu.ToString();
|
||||
AutoPilotConfigUI.TempSpeedToWarp = AutoPilotPlugin.Conf.SpeedToWarp.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Start", guistyle3, Array.Empty<GUILayoutOption>()))
|
||||
if (GUILayout.Button(Strings.Get(1), _buttonStyle))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
AutoPilotPlugin.State = AutoPilotState.Active;
|
||||
}
|
||||
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
||||
GUILayout.Button("-", guistyle3, Array.Empty<GUILayoutOption>());
|
||||
if (GUILayout.Button("Stop", guistyle3, Array.Empty<GUILayoutOption>()))
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Button("-", _buttonStyle);
|
||||
if (GUILayout.Button(Strings.Get(2), _buttonStyle))
|
||||
{
|
||||
VFAudio.Create("ui-click-0", null, Vector3.zero, true);
|
||||
AutoPilotPlugin.State = AutoPilotState.Inactive;
|
||||
}
|
||||
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.EndVertical();
|
||||
@@ -167,22 +251,30 @@ internal static class AutoPilotMainUI
|
||||
|
||||
private static int _wIdx;
|
||||
|
||||
public const float WindowWidthFull = 398f;
|
||||
public const float WindowWidthFull = 408f;
|
||||
|
||||
public const float WindowHeightFull = 150f;
|
||||
|
||||
public const float WindowWidthMini = 288f;
|
||||
public const float WindowWidthMini = 298f;
|
||||
|
||||
public const float WindowHeightMini = 70f;
|
||||
|
||||
public static readonly Rect[] Rect = {
|
||||
public static readonly Rect[] Rect =
|
||||
[
|
||||
new Rect(0f, 0f, 398f, 150f),
|
||||
new Rect(0f, 0f, 398f, 150f)
|
||||
};
|
||||
];
|
||||
|
||||
private static readonly float[] LastCheckWindowLeft = { float.MinValue, float.MinValue };
|
||||
private static GUIStyle _windowStyle;
|
||||
private static GUIStyle _baseLabelStyle;
|
||||
private static GUIStyle _highlightedLabelStyle;
|
||||
private static GUIStyle _ngLabelStyle;
|
||||
private static GUIStyle _labelStyle;
|
||||
private static GUIStyle _buttonStyle;
|
||||
|
||||
private static readonly float[] LastCheckWindowTop = { float.MinValue, float.MinValue };
|
||||
private static readonly float[] LastCheckWindowLeft = [float.MinValue, float.MinValue];
|
||||
|
||||
private static readonly float[] LastCheckWindowTop = [float.MinValue, float.MinValue];
|
||||
|
||||
public static long NextCheckGameTick = long.MaxValue;
|
||||
}
|
||||
91
AutoPilot/UI/StringsUI.cs
Normal file
91
AutoPilot/UI/StringsUI.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using CruiseAssist.Commons;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace AutoPilot.UI;
|
||||
|
||||
public static class Strings
|
||||
{
|
||||
private static readonly string[] EngUs = [
|
||||
// 0
|
||||
"Config",
|
||||
"Start",
|
||||
"Stop",
|
||||
"Energy",
|
||||
"Warper",
|
||||
// 5
|
||||
"Leaving Planet",
|
||||
"Speed UP",
|
||||
"NG",
|
||||
"OK",
|
||||
"YES",
|
||||
// 10
|
||||
"NO",
|
||||
"ON",
|
||||
"OFF",
|
||||
"Auto Pilot Inactive.",
|
||||
"Auto Pilot Active.",
|
||||
// 15
|
||||
"Min Energy Percent (0-100 default:20)",
|
||||
"Max Speed (0-2000 default:2000)",
|
||||
"Warp Min Range (1-60 default:2)",
|
||||
"Speed to warp (0-2000 default:1200)",
|
||||
"Warp to planet in local system.",
|
||||
// 20
|
||||
"Start AutoPilot when set target planet.",
|
||||
"Join AutoPilot window to CruiseAssist window.",
|
||||
];
|
||||
|
||||
private static readonly string[] ZhoCn =
|
||||
[
|
||||
// 0
|
||||
"设置",
|
||||
"开始",
|
||||
"停止",
|
||||
"能量",
|
||||
"翘曲",
|
||||
// 5
|
||||
"离开行星",
|
||||
"加速",
|
||||
"不足",
|
||||
"OK",
|
||||
"是",
|
||||
// 10
|
||||
"否",
|
||||
"开",
|
||||
"关",
|
||||
"Auto Pilot 未在工作",
|
||||
"Auto Pilot 正在工作",
|
||||
// 15
|
||||
"最小能量百分比 (0-100 默认:20)",
|
||||
"最大速度 (0-2000 默认:2000)",
|
||||
"启用曲速最小距离 (1-60 默认:2)",
|
||||
"航行速度达到此值时启动曲速 (0-2000 默认:1200)",
|
||||
"即使本星系的行星也允许曲速",
|
||||
// 20
|
||||
"设置目标行星后立即开始导航",
|
||||
"合并 AutoPilot 和 CruiseAssist 窗口",
|
||||
];
|
||||
|
||||
public static Action OnLanguageChanged;
|
||||
|
||||
private static string[] _langStr = EngUs;
|
||||
|
||||
public static string Get(int index) => _langStr[index];
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(Localization), nameof(Localization.LoadSettings))]
|
||||
[HarmonyPatch(typeof(Localization), nameof(Localization.LoadLanguage))]
|
||||
[HarmonyPatch(typeof(Localization), nameof(Localization.NotifyLanguageChange))]
|
||||
private static void Localization_LanguageChanged_Postfix()
|
||||
{
|
||||
var newstr = Localization.Languages[Localization.currentLanguageIndex].lcId switch
|
||||
{
|
||||
2052 => ZhoCn,
|
||||
_ => EngUs
|
||||
};
|
||||
if (newstr == _langStr) return;
|
||||
_langStr = newstr;
|
||||
OnLanguageChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,6 @@
|
||||
"description": "Auto pilot to a planet or star system.",
|
||||
"dependencies": [
|
||||
"xiaoye97-BepInEx-5.4.17",
|
||||
"tanu-CruiseAssist-0.0.37"
|
||||
"soarqin-CruiseAssist-0.1.0"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user