mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-08 22:53:33 +08:00
work in progress
This commit is contained in:
@@ -6,6 +6,7 @@ using CommonAPI.Systems;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
public static class UIFunctions
|
||||
{
|
||||
@@ -15,6 +16,7 @@ public static class UIFunctions
|
||||
private static MyConfigWindow _configWin;
|
||||
private static GameObject _buttonOnPlanetGlobe;
|
||||
private static int _cornerComboBoxIndex;
|
||||
private static string[] _starOrderNames;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
@@ -27,9 +29,25 @@ public static class UIFunctions
|
||||
});
|
||||
I18N.Add("KEYOpenUXAssistConfigWindow", "[UXA] Open UXAssist Config Window", "[UXA] 打开UX助手设置面板");
|
||||
I18N.OnInitialized += RecreateConfigWindow;
|
||||
GameLogic.OnGameBegin += () =>
|
||||
{
|
||||
var galaxy = GameMain.data.galaxy;
|
||||
_starOrderNames = new string[galaxy.starCount];
|
||||
StarData[] stars = [..galaxy.stars.Where(star => star != null)];
|
||||
Array.Sort(stars, (a, b) =>
|
||||
{
|
||||
int res = a.position.sqrMagnitude.CompareTo(b.position.sqrMagnitude);
|
||||
if (res != 0) return res;
|
||||
return a.index.CompareTo(b.index);
|
||||
});
|
||||
};
|
||||
GameLogic.OnGameEnd += () =>
|
||||
{
|
||||
_starOrderNames = null;
|
||||
};
|
||||
}
|
||||
|
||||
public static void OnUpdate()
|
||||
public static void OnInputUpdate()
|
||||
{
|
||||
if (_toggleKey.keyValue)
|
||||
{
|
||||
@@ -162,18 +180,11 @@ public static class UIFunctions
|
||||
|
||||
public static void UpdateStarmapStarNames()
|
||||
{
|
||||
var galaxy = GameMain.data.galaxy;
|
||||
string[] starOrderNames = null;
|
||||
if (_cornerComboBoxIndex > 0)
|
||||
{
|
||||
starOrderNames = new string[galaxy.starCount];
|
||||
StarData[] stars = new StarData[galaxy.starCount];
|
||||
for (int i = 0; i < galaxy.starCount; i++)
|
||||
{
|
||||
stars[i] = galaxy.stars[i];
|
||||
}
|
||||
Array.Sort(stars, (a, b) => a.position.sqrMagnitude.CompareTo(b.position.sqrMagnitude));
|
||||
int[] spectrCount = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||
var galaxy = GameMain.data.galaxy;
|
||||
StarData[] stars = new StarData[galaxy.starCount];
|
||||
for (int i = 0; i < galaxy.starCount; i++)
|
||||
{
|
||||
var star = stars[i];
|
||||
@@ -184,39 +195,39 @@ public static class UIFunctions
|
||||
switch (star.spectr)
|
||||
{
|
||||
case ESpectrType.M:
|
||||
starOrderNames[index] = String.Format("M{0}", ++spectrCount[0]);
|
||||
_starOrderNames[index] = String.Format("M{0}", ++spectrCount[0]);
|
||||
break;
|
||||
case ESpectrType.K:
|
||||
starOrderNames[index] = String.Format("K{0}", ++spectrCount[1]);
|
||||
_starOrderNames[index] = String.Format("K{0}", ++spectrCount[1]);
|
||||
break;
|
||||
case ESpectrType.G:
|
||||
starOrderNames[index] = String.Format("G{0}", ++spectrCount[2]);
|
||||
_starOrderNames[index] = String.Format("G{0}", ++spectrCount[2]);
|
||||
break;
|
||||
case ESpectrType.F:
|
||||
starOrderNames[index] = String.Format("F{0}", ++spectrCount[3]);
|
||||
_starOrderNames[index] = String.Format("F{0}", ++spectrCount[3]);
|
||||
break;
|
||||
case ESpectrType.A:
|
||||
starOrderNames[index] = String.Format("A{0}", ++spectrCount[4]);
|
||||
_starOrderNames[index] = String.Format("A{0}", ++spectrCount[4]);
|
||||
break;
|
||||
case ESpectrType.B:
|
||||
starOrderNames[index] = String.Format("B{0}", ++spectrCount[5]);
|
||||
_starOrderNames[index] = String.Format("B{0}", ++spectrCount[5]);
|
||||
break;
|
||||
case ESpectrType.O:
|
||||
starOrderNames[index] = String.Format("O{0}", ++spectrCount[6]);
|
||||
_starOrderNames[index] = String.Format("O{0}", ++spectrCount[6]);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case EStarType.GiantStar:
|
||||
starOrderNames[index] = String.Format("GS{0}", ++spectrCount[7]);
|
||||
_starOrderNames[index] = String.Format("GS{0}", ++spectrCount[7]);
|
||||
break;
|
||||
case EStarType.WhiteDwarf:
|
||||
starOrderNames[index] = String.Format("WD{0}", ++spectrCount[8]);
|
||||
_starOrderNames[index] = String.Format("WD{0}", ++spectrCount[8]);
|
||||
break;
|
||||
case EStarType.NeutronStar:
|
||||
starOrderNames[index] = String.Format("NS{0}", ++spectrCount[9]);
|
||||
_starOrderNames[index] = String.Format("NS{0}", ++spectrCount[9]);
|
||||
break;
|
||||
case EStarType.BlackHole:
|
||||
starOrderNames[index] = String.Format("BH{0}", ++spectrCount[10]);
|
||||
_starOrderNames[index] = String.Format("BH{0}", ++spectrCount[10]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -228,21 +239,21 @@ public static class UIFunctions
|
||||
switch (_cornerComboBoxIndex)
|
||||
{
|
||||
case 1:
|
||||
starUI.nameText.text = String.Format("{0}-{1:0.00LY}", starOrderNames[star.index], GetStarDist(star));
|
||||
starUI.nameText.text = String.Format("{0}-{1:0.00}", _starOrderNames[star.index], GetStarDist(star));
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
var (nongas, total) = GetStarPlanetCount(star);
|
||||
starUI.nameText.text = String.Format("{0}-{1}-{2}", starOrderNames[star.index], nongas, total);
|
||||
starUI.nameText.text = String.Format("{0}-{1}-{2}", _starOrderNames[star.index], nongas, total);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
starUI.nameText.text = String.Format("{0}-{1}", starOrderNames[star.index], GetStarSpecialOres(star));
|
||||
starUI.nameText.text = String.Format("{0}-{1}", _starOrderNames[star.index], GetStarSpecialOres(star));
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
var (nongas, total) = GetStarPlanetCount(star);
|
||||
starUI.nameText.text = String.Format("{0}-{1:0.00LY}-{2}-{3}-{4}", starOrderNames[star.index], GetStarDist(star), GetStarSpecialOres(star), nongas, total);
|
||||
starUI.nameText.text = String.Format("{0}-{1:0.00}-{2}-{3}-{4}", _starOrderNames[star.index], GetStarDist(star), GetStarSpecialOres(star), nongas, total);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -109,7 +109,6 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
BeltSignalsForBuyOutEnabled.SettingChanged += (_, _) => BeltSignalsForBuyOut.Enable(BeltSignalsForBuyOutEnabled.Value);
|
||||
TankFastFillInAndTakeOutEnabled.SettingChanged += (_, _) => TankFastFillInAndTakeOut.Enable(TankFastFillInAndTakeOutEnabled.Value);
|
||||
TankFastFillInAndTakeOutMultiplier.SettingChanged += (_, _) => UpdateTankFastFillInAndTakeOutMultiplierRealValue();
|
||||
CutConveyorBeltEnabled.SettingChanged += (_, _) => CutConveyorBelt.Enable(CutConveyorBeltEnabled.Value);
|
||||
TweakBuildingBufferEnabled.SettingChanged += (_, _) => TweakBuildingBuffer.Enable(TweakBuildingBufferEnabled.Value);
|
||||
AssemblerBufferTimeMultiplier.SettingChanged += (_, _) => TweakBuildingBuffer.RefreshAssemblerBufferMultipliers();
|
||||
AssemblerBufferMininumMultiplier.SettingChanged += (_, _) => TweakBuildingBuffer.RefreshAssemblerBufferMultipliers();
|
||||
@@ -135,7 +134,6 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
DragBuildPowerPoles.Enable(DragBuildPowerPolesEnabled.Value);
|
||||
BeltSignalsForBuyOut.Enable(BeltSignalsForBuyOutEnabled.Value);
|
||||
TankFastFillInAndTakeOut.Enable(TankFastFillInAndTakeOutEnabled.Value);
|
||||
CutConveyorBelt.Enable(CutConveyorBeltEnabled.Value);
|
||||
TweakBuildingBuffer.Enable(TweakBuildingBufferEnabled.Value);
|
||||
|
||||
Enable(true);
|
||||
@@ -147,7 +145,6 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
Enable(false);
|
||||
|
||||
TweakBuildingBuffer.Enable(false);
|
||||
CutConveyorBelt.Enable(false);
|
||||
TankFastFillInAndTakeOut.Enable(false);
|
||||
BeltSignalsForBuyOut.Enable(false);
|
||||
DragBuildPowerPoles.Enable(false);
|
||||
@@ -171,10 +168,20 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
_tankFastFillInAndTakeOutMultiplierRealValue = Mathf.Max(1, TankFastFillInAndTakeOutMultiplier.Value) * 2;
|
||||
}
|
||||
|
||||
public static void OnUpdate()
|
||||
public static void OnInputUpdate()
|
||||
{
|
||||
if (_doNotRenderEntitiesKey.keyValue)
|
||||
DoNotRenderEntitiesEnabled.Value = !DoNotRenderEntitiesEnabled.Value;
|
||||
if (CutConveyorBeltEnabled.Value && _cutConveyorBeltKey.keyValue)
|
||||
{
|
||||
var raycast = GameMain.mainPlayer.controller?.cmd.raycast;
|
||||
int beltId;
|
||||
if (raycast != null && raycast.castEntity.id > 0 && (beltId = raycast.castEntity.beltId) > 0)
|
||||
{
|
||||
var cargoTraffic = raycast.planet.factory.cargoTraffic;
|
||||
Functions.FactoryFunctions.CutConveyorBelt(cargoTraffic, beltId);
|
||||
}
|
||||
}
|
||||
if (DismantleBlueprintSelectionEnabled.Value && _dismantleBlueprintSelectionKey.keyValue)
|
||||
Functions.FactoryFunctions.DismantleBlueprintSelectedBuildings();
|
||||
}
|
||||
@@ -1992,23 +1999,6 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
}
|
||||
}
|
||||
|
||||
private class CutConveyorBelt : PatchImpl<CutConveyorBelt>
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerController), nameof(PlayerController.GameTick))]
|
||||
private static void PlayerController_GameTick_Postfix(PlayerController __instance)
|
||||
{
|
||||
if (!_cutConveyorBeltKey.keyValue) return;
|
||||
var raycast = __instance.cmd.raycast;
|
||||
if (raycast == null) return;
|
||||
if (raycast.castEntity.id <= 0) return;
|
||||
int beltId;
|
||||
if ((beltId = raycast.castEntity.beltId) <= 0) return;
|
||||
var cargoTraffic = raycast.planet.factory.cargoTraffic;
|
||||
Functions.FactoryFunctions.CutConveyorBelt(cargoTraffic, beltId);
|
||||
}
|
||||
}
|
||||
|
||||
private class TweakBuildingBuffer : PatchImpl<TweakBuildingBuffer>
|
||||
{
|
||||
public static void RefreshAssemblerBufferMultipliers()
|
||||
|
||||
@@ -126,7 +126,7 @@ public class GamePatch : PatchImpl<GamePatch>
|
||||
ConvertSavesFromPeace.Enable(false);
|
||||
}
|
||||
|
||||
public static void OnUpdate()
|
||||
public static void OnInputUpdate()
|
||||
{
|
||||
if (!_enableGameUpsFactor) return;
|
||||
if (_speedDownKey.keyValue)
|
||||
|
||||
@@ -89,7 +89,11 @@ public static class LogisticsPatch
|
||||
{
|
||||
RealtimeLogisticsInfoPanel.StationInfoPanelsUpdate();
|
||||
}
|
||||
if (LogisticsCapacityTweaksEnabled.Value && VFInput.onGUI && !VFInput.inputing)
|
||||
}
|
||||
|
||||
public static void OnInputUpdate()
|
||||
{
|
||||
if (VFInput.onGUI && LogisticsCapacityTweaksEnabled.Value)
|
||||
{
|
||||
LogisticsCapacityTweaks.UpdateInput();
|
||||
}
|
||||
|
||||
@@ -68,9 +68,9 @@ public static class PlayerPatch
|
||||
AutoNavigation.Enable(AutoNavigationEnabled.Value);
|
||||
}
|
||||
|
||||
public static void OnUpdate()
|
||||
public static void OnInputUpdate()
|
||||
{
|
||||
ShortcutKeysForStarsName.OnUpdate();
|
||||
ShortcutKeysForStarsName.OnInputUpdate();
|
||||
if (_autoDriveKey.keyValue)
|
||||
{
|
||||
AutoNavigation.ToggleAutoCruise();
|
||||
@@ -166,7 +166,7 @@ public static class PlayerPatch
|
||||
_forceShowAllStarsNameExternal = value;
|
||||
}
|
||||
|
||||
public static void OnUpdate()
|
||||
public static void OnInputUpdate()
|
||||
{
|
||||
if (!UIRoot.instance.uiGame.starmap.active) return;
|
||||
if (_toggleAllStarsNameKey.keyValue)
|
||||
|
||||
@@ -233,11 +233,18 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (DSPGame.IsMenuDemo)
|
||||
{
|
||||
if (VFInput.inputing) return;
|
||||
UIFunctions.OnInputUpdate();
|
||||
return;
|
||||
}
|
||||
LogisticsPatch.OnUpdate();
|
||||
if (VFInput.inputing) return;
|
||||
UIFunctions.OnUpdate();
|
||||
GamePatch.OnUpdate();
|
||||
FactoryPatch.OnUpdate();
|
||||
PlayerPatch.OnUpdate();
|
||||
LogisticsPatch.OnInputUpdate();
|
||||
UIFunctions.OnInputUpdate();
|
||||
GamePatch.OnInputUpdate();
|
||||
FactoryPatch.OnInputUpdate();
|
||||
PlayerPatch.OnInputUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user