mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 05:33:37 +08:00
UXAssist 1.1.2
This commit is contained in:
@@ -45,6 +45,8 @@ public static class FactoryPatch
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
I18N.Add("KEYToggleDoNotRenderEntities", "Toggle Do Not Render Factory Entities", "切换不渲染工厂建筑实体");
|
I18N.Add("KEYToggleDoNotRenderEntities", "Toggle Do Not Render Factory Entities", "切换不渲染工厂建筑实体");
|
||||||
|
|
||||||
|
BeltSignalsForBuyOut.InitPersist();
|
||||||
UnlimitInteractiveEnabled.SettingChanged += (_, _) => UnlimitInteractive.Enable(UnlimitInteractiveEnabled.Value);
|
UnlimitInteractiveEnabled.SettingChanged += (_, _) => UnlimitInteractive.Enable(UnlimitInteractiveEnabled.Value);
|
||||||
RemoveSomeConditionEnabled.SettingChanged += (_, _) => RemoveSomeConditionBuild.Enable(RemoveSomeConditionEnabled.Value);
|
RemoveSomeConditionEnabled.SettingChanged += (_, _) => RemoveSomeConditionBuild.Enable(RemoveSomeConditionEnabled.Value);
|
||||||
NightLightEnabled.SettingChanged += (_, _) => NightLight.Enable(NightLightEnabled.Value);
|
NightLightEnabled.SettingChanged += (_, _) => NightLight.Enable(NightLightEnabled.Value);
|
||||||
@@ -99,6 +101,7 @@ public static class FactoryPatch
|
|||||||
AllowOverflowInLogistics.Enable(false);
|
AllowOverflowInLogistics.Enable(false);
|
||||||
LogisticsCapacityTweaks.Enable(false);
|
LogisticsCapacityTweaks.Enable(false);
|
||||||
BeltSignalsForBuyOut.Enable(false);
|
BeltSignalsForBuyOut.Enable(false);
|
||||||
|
BeltSignalsForBuyOut.UninitPersist();
|
||||||
|
|
||||||
_factoryPatch?.UnpatchSelf();
|
_factoryPatch?.UnpatchSelf();
|
||||||
_factoryPatch = null;
|
_factoryPatch = null;
|
||||||
@@ -171,15 +174,6 @@ public static class FactoryPatch
|
|||||||
return matcher.InstructionEnumeration();
|
return matcher.InstructionEnumeration();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPostfix, HarmonyPriority(Priority.Last)]
|
|
||||||
[HarmonyPatch(typeof(VFPreload), nameof(VFPreload.InvokeOnLoadWorkEnded))]
|
|
||||||
private static void VFPreload_InvokeOnLoadWorkEnded_Postfix()
|
|
||||||
{
|
|
||||||
if (BeltSignalsForBuyOut.Initialized) return;
|
|
||||||
BeltSignalsForBuyOut.Initialized = true;
|
|
||||||
if (BeltSignalsForBuyOutEnabled.Value) BeltSignalsForBuyOut.EnableBeltSignals();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class NightLight
|
public static class NightLight
|
||||||
{
|
{
|
||||||
private static Harmony _patch;
|
private static Harmony _patch;
|
||||||
@@ -1872,7 +1866,8 @@ public static class FactoryPatch
|
|||||||
private static class BeltSignalsForBuyOut
|
private static class BeltSignalsForBuyOut
|
||||||
{
|
{
|
||||||
private static Harmony _patch;
|
private static Harmony _patch;
|
||||||
public static bool Initialized;
|
private static Harmony _persistPatch;
|
||||||
|
private static bool _initialized;
|
||||||
private static bool _loaded;
|
private static bool _loaded;
|
||||||
private static AssetBundle _bundle;
|
private static AssetBundle _bundle;
|
||||||
private static long _clusterSeedKey;
|
private static long _clusterSeedKey;
|
||||||
@@ -1882,23 +1877,33 @@ public static class FactoryPatch
|
|||||||
private static Dictionary<int, uint>[] _signalBelts = new Dictionary<int, uint>[64];
|
private static Dictionary<int, uint>[] _signalBelts = new Dictionary<int, uint>[64];
|
||||||
private static readonly HashSet<int> SignalBeltFactoryIndices = [];
|
private static readonly HashSet<int> SignalBeltFactoryIndices = [];
|
||||||
|
|
||||||
|
public static void InitPersist()
|
||||||
|
{
|
||||||
|
AddBeltSignalProtos();
|
||||||
|
_persistPatch = Harmony.CreateAndPatchAll(typeof(Persist));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void UninitPersist()
|
||||||
|
{
|
||||||
|
_persistPatch?.UnpatchSelf();
|
||||||
|
_persistPatch = null;
|
||||||
|
}
|
||||||
|
|
||||||
public static void Enable(bool enable)
|
public static void Enable(bool enable)
|
||||||
{
|
{
|
||||||
if (enable)
|
if (enable)
|
||||||
{
|
{
|
||||||
_patch ??= Harmony.CreateAndPatchAll(typeof(BeltSignalsForBuyOut));
|
_patch ??= Harmony.CreateAndPatchAll(typeof(BeltSignalsForBuyOut));
|
||||||
EnableBeltSignals();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_patch?.UnpatchSelf();
|
_patch?.UnpatchSelf();
|
||||||
_patch = null;
|
_patch = null;
|
||||||
DisableBeltSignals();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void EnableBeltSignals()
|
private static void AddBeltSignalProtos()
|
||||||
{
|
{
|
||||||
if (!Initialized || _loaded) return;
|
if (!_initialized || _loaded) return;
|
||||||
var pluginfolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
var pluginfolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||||
_bundle = AssetBundle.LoadFromFile($"{pluginfolder}/uxassist.assetbundle");
|
_bundle = AssetBundle.LoadFromFile($"{pluginfolder}/uxassist.assetbundle");
|
||||||
var signals = LDB._signals;
|
var signals = LDB._signals;
|
||||||
@@ -1975,9 +1980,9 @@ public static class FactoryPatch
|
|||||||
_loaded = true;
|
_loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DisableBeltSignals()
|
private static void RemoveBeltSignalProtos()
|
||||||
{
|
{
|
||||||
if (!Initialized || !_loaded) return;
|
if (!_initialized || !_loaded) return;
|
||||||
var signals = LDB._signals;
|
var signals = LDB._signals;
|
||||||
if (signals.dataIndices.TryGetValue(301, out var index))
|
if (signals.dataIndices.TryGetValue(301, out var index))
|
||||||
{
|
{
|
||||||
@@ -2022,7 +2027,7 @@ public static class FactoryPatch
|
|||||||
var signalBelts = GetOrCreateSignalBelts(factory);
|
var signalBelts = GetOrCreateSignalBelts(factory);
|
||||||
if (signalBelts.Count == 0)
|
if (signalBelts.Count == 0)
|
||||||
SignalBeltFactoryIndices.Add(factory);
|
SignalBeltFactoryIndices.Add(factory);
|
||||||
signalBelts.Add(beltId, signal);
|
signalBelts[beltId] = signal;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Dictionary<int, uint> GetOrCreateSignalBelts(int index)
|
private static Dictionary<int, uint> GetOrCreateSignalBelts(int index)
|
||||||
@@ -2065,51 +2070,63 @@ public static class FactoryPatch
|
|||||||
signalBelts.Clear();
|
signalBelts.Clear();
|
||||||
SignalBeltFactoryIndices.Remove(factory);
|
SignalBeltFactoryIndices.Remove(factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPostfix]
|
|
||||||
[HarmonyPatch(typeof(DigitalSystem), MethodType.Constructor, typeof(PlanetData))]
|
|
||||||
private static void DigitalSystem_Constructor_Postfix(PlanetData _planet)
|
|
||||||
{
|
|
||||||
var player = GameMain.mainPlayer;
|
|
||||||
if (player == null) return;
|
|
||||||
var factory = _planet?.factory;
|
|
||||||
if (factory == null) return;
|
|
||||||
RemovePlanetSignalBelts(factory.index);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPostfix]
|
|
||||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.Begin))]
|
|
||||||
private static void GameMain_Begin_Postfix()
|
|
||||||
{
|
|
||||||
_clusterSeedKey = GameMain.data.GetClusterSeedKey();
|
|
||||||
InitSignalBelts();
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPrefix]
|
private static class Persist
|
||||||
[HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.RemoveBeltComponent))]
|
|
||||||
public static void CargoTraffic_RemoveBeltComponent_Prefix(int id)
|
|
||||||
{
|
{
|
||||||
var planet = GameMain.localPlanet;
|
[HarmonyPostfix, HarmonyPriority(Priority.Last)]
|
||||||
if (planet == null) return;
|
[HarmonyPatch(typeof(VFPreload), nameof(VFPreload.InvokeOnLoadWorkEnded))]
|
||||||
RemoveSignalBelt(planet.factoryIndex, id);
|
private static void VFPreload_InvokeOnLoadWorkEnded_Postfix()
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPostfix]
|
|
||||||
[HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.SetBeltSignalIcon))]
|
|
||||||
public static void CargoTraffic_SetBeltSignalIcon_Postfix(CargoTraffic __instance, int entityId, int signalId)
|
|
||||||
{
|
|
||||||
var planet = GameMain.localPlanet;
|
|
||||||
if (planet == null) return;
|
|
||||||
var factory = __instance.factory;
|
|
||||||
var factoryIndex = planet.factoryIndex;
|
|
||||||
var beltId = factory.entityPool[entityId].beltId;
|
|
||||||
if (signalId is < 301 or > 306)
|
|
||||||
{
|
{
|
||||||
RemoveSignalBelt(factoryIndex, beltId);
|
if (BeltSignalsForBuyOut._initialized) return;
|
||||||
|
BeltSignalsForBuyOut._initialized = true;
|
||||||
|
BeltSignalsForBuyOut.AddBeltSignalProtos();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch(typeof(DigitalSystem), MethodType.Constructor, typeof(PlanetData))]
|
||||||
|
private static void DigitalSystem_Constructor_Postfix(PlanetData _planet)
|
||||||
{
|
{
|
||||||
SetSignalBelt(factoryIndex, beltId, (uint)signalId - 301U);
|
var player = GameMain.mainPlayer;
|
||||||
|
if (player == null) return;
|
||||||
|
var factory = _planet?.factory;
|
||||||
|
if (factory == null) return;
|
||||||
|
RemovePlanetSignalBelts(factory.index);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch(typeof(GameMain), nameof(GameMain.Begin))]
|
||||||
|
private static void GameMain_Begin_Postfix()
|
||||||
|
{
|
||||||
|
_clusterSeedKey = GameMain.data.GetClusterSeedKey();
|
||||||
|
InitSignalBelts();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.RemoveBeltComponent))]
|
||||||
|
public static void CargoTraffic_RemoveBeltComponent_Prefix(int id)
|
||||||
|
{
|
||||||
|
var planet = GameMain.localPlanet;
|
||||||
|
if (planet == null) return;
|
||||||
|
RemoveSignalBelt(planet.factoryIndex, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.SetBeltSignalIcon))]
|
||||||
|
public static void CargoTraffic_SetBeltSignalIcon_Postfix(CargoTraffic __instance, int entityId, int signalId)
|
||||||
|
{
|
||||||
|
var planet = GameMain.localPlanet;
|
||||||
|
if (planet == null) return;
|
||||||
|
var factory = __instance.factory;
|
||||||
|
var factoryIndex = planet.factoryIndex;
|
||||||
|
var beltId = factory.entityPool[entityId].beltId;
|
||||||
|
if (signalId is < 301 or > 306)
|
||||||
|
{
|
||||||
|
RemoveSignalBelt(factoryIndex, beltId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetSignalBelt(factoryIndex, beltId, (uint)signalId - 301U);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#### 一些提升用户体验的功能和补丁
|
#### 一些提升用户体验的功能和补丁
|
||||||
|
|
||||||
## Changlog
|
## Changlog
|
||||||
|
* 1.1.2
|
||||||
|
+ `Belt signals for buy out dark fog items automatically`: Always add belt signals to the panel to fix missing belt icons when disabled.
|
||||||
* 1.1.1
|
* 1.1.1
|
||||||
+ Fix assetbundle loading issue
|
+ Fix assetbundle loading issue
|
||||||
* 1.1.0
|
* 1.1.0
|
||||||
@@ -225,6 +227,8 @@
|
|||||||
* [CruiseAssist](https://dsp.thunderstore.io/package/tanu/CruiseAssist/) and its extension [AutoPilot](https://dsp.thunderstore.io/package/tanu/AutoPilot/): `Auto navigation on sailings` and `Auto-cruise` implementations
|
* [CruiseAssist](https://dsp.thunderstore.io/package/tanu/CruiseAssist/) and its extension [AutoPilot](https://dsp.thunderstore.io/package/tanu/AutoPilot/): `Auto navigation on sailings` and `Auto-cruise` implementations
|
||||||
|
|
||||||
## 更新日志
|
## 更新日志
|
||||||
|
* 1.1.2
|
||||||
|
+ `用于自动购买黑雾物品的传送带信号`: 总是将传送带信号添加到面板,以修复禁用时传送带图标丢失的问题。
|
||||||
* 1.1.1
|
* 1.1.1
|
||||||
+ 修复了资源包加载问题
|
+ 修复了资源包加载问题
|
||||||
* 1.1.0
|
* 1.1.0
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ public static class UIConfigWindow
|
|||||||
y = 10f;
|
y = 10f;
|
||||||
MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.StopEjectOnNodeCompleteEnabled, "Stop ejectors when available nodes are all filled up");
|
MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.StopEjectOnNodeCompleteEnabled, "Stop ejectors when available nodes are all filled up");
|
||||||
y += 36f;
|
y += 36f;
|
||||||
MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.OnlyConstructNodesEnabled, "Construct only nodes but frames");
|
MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.OnlyConstructNodesEnabled, "Construct only structure points but frames");
|
||||||
x = 400f;
|
x = 400f;
|
||||||
y = 10f;
|
y = 10f;
|
||||||
wnd.AddButton(x, y, tab4, "Initialize Dyson Sphere", 16, "init-dyson-sphere", () =>
|
wnd.AddButton(x, y, tab4, "Initialize Dyson Sphere", 16, "init-dyson-sphere", () =>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework>net472</TargetFramework>
|
||||||
<BepInExPluginGuid>org.soardev.uxassist</BepInExPluginGuid>
|
<BepInExPluginGuid>org.soardev.uxassist</BepInExPluginGuid>
|
||||||
<Description>DSP MOD - UXAssist</Description>
|
<Description>DSP MOD - UXAssist</Description>
|
||||||
<Version>1.1.1</Version>
|
<Version>1.1.2</Version>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<PackageId>UXAssist</PackageId>
|
<PackageId>UXAssist</PackageId>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "UXAssist",
|
"name": "UXAssist",
|
||||||
"version_number": "1.1.1",
|
"version_number": "1.1.2",
|
||||||
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UXAssist",
|
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UXAssist",
|
||||||
"description": "Some functions and patches for better user experience / 一些提升用户体验的功能和补丁",
|
"description": "Some functions and patches for better user experience / 一些提升用户体验的功能和补丁",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
|
|||||||
Reference in New Issue
Block a user