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