mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-08-05 09:10:10 +08:00
Compare commits
280
Commits
dev
...
157c86112b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
157c86112b | ||
|
|
d0c20693e3 | ||
|
|
8ae88f4b41 | ||
|
|
c1428f6aee | ||
|
|
260e419855 | ||
|
|
6e0484f035 | ||
|
|
6e4416389d | ||
|
|
71c0fe75db | ||
|
|
aa775bd05f | ||
|
|
9787636d08 | ||
|
|
256faeee19 | ||
|
|
78e86aeafe | ||
|
|
3156f0ffb5 | ||
|
|
2377f92589 | ||
|
|
788ed4275e | ||
|
|
ed8d7d61ff | ||
|
|
6eb9161af1 | ||
|
|
2201de2b1b | ||
|
|
b537ff22be | ||
|
|
0049629fd1 | ||
|
|
c339041824 | ||
|
|
0d7941387f | ||
|
|
f237789fa0 | ||
|
|
b2c04c1dff | ||
|
|
29ee32b11b | ||
|
|
3f7c384284 | ||
|
|
556493b2b6 | ||
|
|
269cc3b801 | ||
|
|
cacbfd6d5f | ||
|
|
45445f82a1 | ||
|
|
1a242af84e | ||
|
|
1467a6010d | ||
|
|
6f5b779d58 | ||
|
|
d8fa46d495 | ||
|
|
af3b46be11 | ||
|
|
96f160926c | ||
|
|
ee812bbc79 | ||
|
|
052c23d3b7 | ||
|
|
be9de43492 | ||
|
|
2dbf017a5e | ||
|
|
3c7744047c | ||
|
|
a9959a2f07 | ||
|
|
77f5803a24 | ||
|
|
e9bbcf5e2c | ||
|
|
a183485286 | ||
|
|
5a6cfb18c9 | ||
|
|
49226001be | ||
|
|
7c1e88f86d | ||
|
|
16429936a9 | ||
|
|
d711dd25ef | ||
|
|
e909b6d9d2 | ||
|
|
2a4008deac | ||
|
|
6b423225fe | ||
|
|
9d9a12c1af | ||
|
|
1d11ba90bd | ||
|
|
a5dc7c5825 | ||
|
|
73ebcf1aa3 | ||
|
|
dc092d7f6f | ||
|
|
d9f87ca4e9 | ||
|
|
a3c60c32ca | ||
|
|
96a9e8a570 | ||
|
|
d6a8275938 | ||
|
|
b995503f58 | ||
|
|
a25f74443d | ||
|
|
5f37b8b6d6 | ||
|
|
4584895345 | ||
|
|
5b4633e54c | ||
|
|
31b1d90d5d | ||
|
|
8446fba0e4 | ||
|
|
688b50344c | ||
|
|
0dd1a11c14 | ||
|
|
f8552d5c34 | ||
|
|
c98c801f27 | ||
|
|
9bfa74edf2 | ||
|
|
9d586d68e0 | ||
|
|
a446a17d02 | ||
|
|
7a7943b001 | ||
|
|
a9dd130f76 | ||
|
|
0178c8cc2e | ||
|
|
4e2b4a8e22 | ||
|
|
4f292bd2d3 | ||
|
|
2949066712 | ||
|
|
b093a62e36 | ||
|
|
f58bd869fe | ||
|
|
b7abb3a32a | ||
|
|
b79cfbc994 | ||
|
|
c91a873e8d | ||
|
|
4b632db315 | ||
|
|
2c4d1b8b0d | ||
|
|
ba095d79f0 | ||
|
|
a9286d2839 | ||
|
|
17aca89249 | ||
|
|
4a3bffd927 | ||
|
|
cb3975ae1a | ||
|
|
4ba1512205 | ||
|
|
c6f1a8bd80 | ||
|
|
dc246170ac | ||
|
|
23aa8c1f13 | ||
|
|
944a4d7948 | ||
|
|
f7e1a27be1 | ||
|
|
b6c182168b | ||
|
|
7d98471dca | ||
|
|
e460b55eb4 | ||
|
|
177d8b3caf | ||
|
|
75030c5b23 | ||
|
|
7bd8abe7e6 | ||
|
|
b51cb326b7 | ||
|
|
f2a849c1af | ||
|
|
c7465133f7 | ||
|
|
ac2cc258ee | ||
|
|
586ce9a427 | ||
|
|
b060204d80 | ||
|
|
47cfb4d79a | ||
|
|
fb3a74c7e7 | ||
|
|
0d5a07b1ac | ||
|
|
780ad3d3ec | ||
|
|
40e3206953 | ||
|
|
167f53e2df | ||
|
|
f407928579 | ||
|
|
5545d7a2bf | ||
|
|
2124719de0 | ||
|
|
8550a354f1 | ||
|
|
f6f28efd88 | ||
|
|
d61b40216c | ||
|
|
6877b8e9ac | ||
|
|
950bde3464 | ||
|
|
8362fcf546 | ||
|
|
b86825c645 | ||
|
|
bb18912155 | ||
|
|
99b7943d76 | ||
|
|
5f53c50da0 | ||
|
|
68a18c113d | ||
|
|
40aa331294 | ||
|
|
150868fcea | ||
|
|
fd2aa924ff | ||
|
|
1ae4aa3ecb | ||
|
|
996a57130c | ||
|
|
5c187fb32e | ||
|
|
e765f0f42d | ||
|
|
65522c6f21 | ||
|
|
2a3fed7180 | ||
|
|
78379165e8 | ||
|
|
f32b11f49a | ||
|
|
3c8f258a1b | ||
|
|
8d7f8e8c8a | ||
|
|
d867bca1ba | ||
|
|
1d01fdbd15 | ||
|
|
db0970c3c4 | ||
|
|
a3bb6ea609 | ||
|
|
ac7f2ef63c | ||
|
|
5674d601ec | ||
|
|
cdd71006b8 | ||
|
|
0491973a85 | ||
|
|
82e0e2ac43 | ||
|
|
63eed23826 | ||
|
|
69702d4f09 | ||
|
|
69ab11c392 | ||
|
|
092795cbac | ||
|
|
adcce8e298 | ||
|
|
0f80dac134 | ||
|
|
5dba87dc7f | ||
|
|
c30758cfab | ||
|
|
e458f42f4a | ||
|
|
74c61c3eb9 | ||
|
|
b34909d71a | ||
|
|
087ceac1e3 | ||
|
|
043e7a8e70 | ||
|
|
34822453a7 | ||
|
|
0a8fa9971c | ||
|
|
f224b72838 | ||
|
|
27f04376ae | ||
|
|
bd794aa479 | ||
|
|
a823d4f2c3 | ||
|
|
706e1649a1 | ||
|
|
3486cc9ca2 | ||
|
|
b1faaf0b2f | ||
|
|
fe7644f728 | ||
|
|
88b8be79a0 | ||
|
|
833bc3b0ac | ||
|
|
cdf0972610 | ||
|
|
75147d7bc0 | ||
|
|
4b911263eb | ||
|
|
2d6f5fdf56 | ||
|
|
7c9b2f10d6 | ||
|
|
99a6708d3f | ||
|
|
d7062f3318 | ||
|
|
0de9f3c06a | ||
|
|
bbab36bc35 | ||
|
|
5b725ff94f | ||
|
|
6048db8069 | ||
|
|
54f04eb5d7 | ||
|
|
26df57f911 | ||
|
|
83b544c172 | ||
|
|
c2d55dd16e | ||
|
|
f897c0d9ec | ||
|
|
9668fda718 | ||
|
|
9d795e0ca4 | ||
|
|
4534540786 | ||
|
|
90dd17d19c | ||
|
|
9d5af1c340 | ||
|
|
53ba10bb23 | ||
|
|
237830fc91 | ||
|
|
daaf7b4901 | ||
|
|
98a8c94518 | ||
|
|
1ab57eb7ca | ||
|
|
177c74d6e9 | ||
|
|
2d2602d8b9 | ||
|
|
722c32fdd6 | ||
|
|
f5b98c1c48 | ||
|
|
bd512a6b78 | ||
|
|
fb916b3813 | ||
|
|
db0a9522da | ||
|
|
96b4d6cfc8 | ||
|
|
241c9ee605 | ||
|
|
21b7dc5a18 | ||
|
|
30366788bd | ||
|
|
245d529262 | ||
|
|
421cfd230e | ||
|
|
3a2821a2c1 | ||
|
|
bacd1b7d75 | ||
|
|
19a050639d | ||
|
|
d52bc630ba | ||
|
|
0dafd8a763 | ||
|
|
92445a452a | ||
|
|
287cfbbed4 | ||
|
|
d11817d4c3 | ||
|
|
50e209fd38 | ||
|
|
054b8e14b8 | ||
|
|
f84d20544c | ||
|
|
12c5077abc | ||
|
|
c93885da18 | ||
|
|
b9534d28ee | ||
|
|
bae06d7278 | ||
|
|
fc8488ce61 | ||
|
|
65a8a9374f | ||
|
|
5a12631c76 | ||
|
|
7430f20181 | ||
|
|
fec947e71a | ||
|
|
efa3198d81 | ||
|
|
d894ce08a6 | ||
|
|
b27ed3f96b | ||
|
|
ad1ee2988b | ||
|
|
7c14892d49 | ||
|
|
75aca132fa | ||
|
|
cb5ae4ddd8 | ||
|
|
73f5ecdb9f | ||
|
|
63e684ebf4 | ||
|
|
57c5993692 | ||
|
|
2741069bc7 | ||
|
|
b1f27a2633 | ||
|
|
3db7fa5194 | ||
|
|
6cc44af8e3 | ||
|
|
c7b5303da2 | ||
|
|
c8a0651ae2 | ||
|
|
1ebcb49536 | ||
|
|
830a242f37 | ||
|
|
4869bdb7d7 | ||
|
|
7cdaa5df20 | ||
|
|
a359f789e7 | ||
|
|
b560c2c9ff | ||
|
|
357b2781a2 | ||
|
|
74e796431e | ||
|
|
0bb4a8f4af | ||
|
|
51314305d1 | ||
|
|
6a9b9b44bc | ||
|
|
11746a0bb4 | ||
|
|
cff09505b9 | ||
|
|
3a52175041 | ||
|
|
2d38e61702 | ||
|
|
f07ad5dfc9 | ||
|
|
6d2fdd28a8 | ||
|
|
456598f2a1 | ||
|
|
d9a4cb312d | ||
|
|
86818197d8 | ||
|
|
3ddd20845a | ||
|
|
4a0ab4494a | ||
|
|
e2d83ee3cb | ||
|
|
d72d16a171 | ||
|
|
534d602953 | ||
|
|
8a19dfac9f |
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"MD013": false,
|
||||
"MD033": {
|
||||
"allowed_elements": ["details", "summary"]
|
||||
},
|
||||
"MD041": false
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,69 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace CheatEnabler;
|
||||
public static class AbnormalDisabler
|
||||
{
|
||||
public static ConfigEntry<bool> Enabled;
|
||||
private static Dictionary<int, AbnormalityDeterminator> _savedDeterminators;
|
||||
private static Harmony _patch;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(AbnormalDisabler));
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(AbnormalityLogic), "NotifyBeforeGameSave")]
|
||||
[HarmonyPatch(typeof(AbnormalityLogic), "NotifyOnAssemblerRecipePick")]
|
||||
[HarmonyPatch(typeof(AbnormalityLogic), "NotifyOnGameBegin")]
|
||||
[HarmonyPatch(typeof(AbnormalityLogic), "NotifyOnMechaForgeTaskComplete")]
|
||||
[HarmonyPatch(typeof(AbnormalityLogic), "NotifyOnUnlockTech")]
|
||||
[HarmonyPatch(typeof(AbnormalityLogic), "NotifyOnUseConsole")]
|
||||
private static bool DisableAbnormalLogic()
|
||||
{
|
||||
return !Enabled.Value;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(AbnormalityLogic), "InitDeterminators")]
|
||||
private static void DisableAbnormalDeterminators(AbnormalityLogic __instance)
|
||||
{
|
||||
_savedDeterminators = __instance.determinators;
|
||||
Enabled.SettingChanged += (_, _) =>
|
||||
{
|
||||
if (Enabled.Value)
|
||||
{
|
||||
_savedDeterminators = __instance.determinators;
|
||||
__instance.determinators = new Dictionary<int, AbnormalityDeterminator>();
|
||||
foreach (var p in _savedDeterminators)
|
||||
{
|
||||
p.Value.OnUnregEvent();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.determinators = _savedDeterminators;
|
||||
foreach (var p in _savedDeterminators)
|
||||
{
|
||||
p.Value.OnRegEvent();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_savedDeterminators = __instance.determinators;
|
||||
if (!Enabled.Value) return;
|
||||
__instance.determinators = new Dictionary<int, AbnormalityDeterminator>();
|
||||
foreach (var p in _savedDeterminators)
|
||||
{
|
||||
p.Value.OnUnregEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,343 @@
|
||||
<details>
|
||||
<summary>Read me in English</summary>
|
||||
|
||||
## Changlog
|
||||
|
||||
* 2.4.2
|
||||
* Fix critical bugs:
|
||||
* Dyson Power is not updated actively when `Skip bullet period` or `Skip absorption period` is enabled and no rocket is in fire.
|
||||
* Dyson Power is not updated actively on clicking `Complete Dyson Sphere Shells instantly` or `Remove all frames on Dyson Sphere`.
|
||||
* 2.4.1
|
||||
* New feature: `Remove all frames on Dyson Sphere`
|
||||
* Can save rockets with very little power generation impact.
|
||||
* Will keep nodes and shells and does not affect solar sails' absorption.
|
||||
* `Terraform without enough soil piles`: Working for blueprint paste and burying Dark Fog Core Driller now.
|
||||
* `Belt signal item generation`: Fix mod compatibility by resolving recursive recipes.
|
||||
* 2.4.0
|
||||
* Support game version 0.10.33
|
||||
* `Generate illegal dyson shell`: This function is open to all users now, enabling certain config entry is not needed any more.
|
||||
* 2.3.32
|
||||
* `Complete Dyson Sphere Shells instantly`: Fix a crash.
|
||||
* 2.3.31
|
||||
* New feature: `Unlock Dyson Sphere max orbit radius`
|
||||
* `Remove metadata consumption record in current game`: Fix implementation
|
||||
* Add 3 buttons for creating illegal Dyson Sphere Shells, you must enable `IllegalDysonShellFunctionsEnabled` of `DysonSphere` section in config to see them.
|
||||
* `Generate an illegal dyson shell`
|
||||
* `Keep max production shells and remove others`
|
||||
* `Duplicate shells from that with highest production`
|
||||
* 2.3.30
|
||||
* Fix a warning issue while `No condition build` or `No collision` is enabled.
|
||||
* Increase performance for `Finish build immediately` greatly on pasting large blueprints.
|
||||
* 2.3.29
|
||||
* Fix compatibility with game update 0.10.32.25779
|
||||
* 2.3.28
|
||||
* New feature: `Instant hand-craft`.
|
||||
* Fix some panels' display while `Infinite Natural Resources` is enabled.
|
||||
* 2.3.27
|
||||
* `Skip bullet period` & `Eject anyway`: Fix compatibility with `Dyson Sphere Program v0.10.32.25496`.
|
||||
* 2.3.26
|
||||
* Refactor codes to adapt to UXAssist 1.2.0
|
||||
* You should update UXAssist to 1.2.0 or later before using this version.
|
||||
* `Complete Dyson Sphere Shells instantly`: Fix possible wrong production records.
|
||||
* 2.3.25
|
||||
* New feature: `Enable warp without space warpers`
|
||||
* New feature: `Wind Turbines do global power coverage`
|
||||
* Fix an issue that `Complete Dyson Sphere Shells instantly` does not generate production records for solar sails.
|
||||
* 2.3.24
|
||||
* `Complete Dyson Sphere Shells instantly`: Fix a bug that may cause negative power in some cases
|
||||
* 2.3.23
|
||||
* New feature: `Complete Dyson Sphere Shells instantly`
|
||||
* Fix a crash when config panel is opened before game is fully loaded
|
||||
* 2.3.22
|
||||
* Fix `Pump Anywhere`
|
||||
* 2.3.21
|
||||
* `Retrieve/Place items from/to remote planets on logistics control panel`: Items are put back to player's inventory when a slot is removed from the logistics station on remote planet.
|
||||
* `Dev Shortcuts`: Camera Pose related shortcurts are working now.
|
||||
* 2.3.20
|
||||
* New feature: `Retrieve/Place items from/to remote planets on logistics control panel`
|
||||
* 2.3.19
|
||||
* New features:
|
||||
* `Remove all metadata consumption records`
|
||||
* `Remove metadata consumption record in current game`
|
||||
* `Clear metadata flag which bans achievements`
|
||||
* 2.3.18
|
||||
* New features:
|
||||
* `Teleport to outer space`, this will teleport you to the outer space which is 50 LYs far from the farthest star.
|
||||
* `Teleport to selected astronomical`
|
||||
* Fix logic of `Unlock techs with key-modifiers`.
|
||||
* `No condition build` does not hide rotation info of belts now.
|
||||
* 2.3.17
|
||||
* Make compatible with game version 0.10.30.23292
|
||||
* 2.3.16
|
||||
* Add 2 options to `Belt signal item generation`:
|
||||
* `Count generations as production in statistics`
|
||||
* `Count removals as consumption in statistics`
|
||||
* New feature: `Increase maximum power usage in Logistic Stations and Advanced Mining Machines`
|
||||
* Logistic Stations: Increased max charging power to 3GW(ILS) and 600MW(PLS) (10x of original)
|
||||
* Advanced Mining Machines: Increased max mining speed to 1000%
|
||||
* 2.3.15
|
||||
* New features:
|
||||
* `Instant teleport (like that in Sandbox mode)`
|
||||
* `Mecha and Drones/Fleets invicible`
|
||||
* `Buildings invicible`
|
||||
* 2.3.14
|
||||
* Remove default shortcut key for `No condition build` and `No collision`, to avoid misoperation. You can still set them in system settings window manually if needed.
|
||||
* Fix translation issue.
|
||||
* 2.3.13
|
||||
* Fix a bug that shortcuts are not working and have display issue on settings window.
|
||||
* 2.3.12
|
||||
* Add a shortcut to toggle `No collision`, you can modify the shortcut on system settings window.
|
||||
* Add realtime tips when toggling `No condition build` and `No collision` with shortcuts.
|
||||
* 2.3.11
|
||||
* Add a shortcut to toggle `No condition build`, you can modify the shortcut on system settings window. This depends on [UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist) 1.0.15 or later.
|
||||
* 2.3.10
|
||||
* Fix following functions not working in new game updates:
|
||||
* `Pump Anywhere`
|
||||
* `Terraform without enough soil piles`
|
||||
* 2.3.9
|
||||
* Support game version 0.10.28.21219
|
||||
* 2.3.8
|
||||
* Fix a crash on starting new games while `Finish build immediately` is enabled.
|
||||
* Fix UI button width.
|
||||
* 2.3.7
|
||||
* Support game version 0.10.28.20759
|
||||
* Fix belt signal that items' generation speed is not fit to number set sometimes.
|
||||
* 2.3.6
|
||||
* Support for UXAssist's new function within `Finish build immediately`.
|
||||
* Add a warning message when `Build without condition` is enabled.
|
||||
* Fix an issue in `Finish build immediately` that some buildings are not finished immediately.
|
||||
* 2.3.5
|
||||
* Fix another crash in `Skip bullet period`.
|
||||
* 2.3.4
|
||||
* Use new tab layout of UXAssist 1.0.2
|
||||
* Minor bug fixes
|
||||
* 2.3.3
|
||||
* Fix a crash in `Skip bullet period`.
|
||||
* Unlock techs with Alt unlocks VeinUtil to 10000 instead of 7200 now, as bug fixed in UXAssist.
|
||||
* 2.3.2
|
||||
* Birth star options moved to [UniverseGenTweaks](https://dsp.thunderstore.io/package/soarqin/UniverseGenTweaks/)
|
||||
* Optimize `Quick absorb`, consumes less CPU time and take turns firing to nodes.
|
||||
* `Fast Mining` ensures full output of oil extractors now.
|
||||
* Fix issue that `Belt signal generator` not working after switched off then on again.
|
||||
* Fix absorption issue by `Quick absorb` and `Skip bullet period` enabled at the same time.
|
||||
* Crash fix for some options
|
||||
* 2.3.1
|
||||
* Add UXAssist to dependencies in manifest.
|
||||
* 2.3.0
|
||||
* Move some functions to an individual mod: [UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist)
|
||||
* Depends on [UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist) now, so that config panel is unified with UXAssist.
|
||||
* Remove `LCtrl+A` from Dev Shortcuts, to avoid misoperation.
|
||||
* Infinite bots/drones/vessels in `Architect mode` now.
|
||||
* 2.2.7
|
||||
* New function: `Construct only nodes but frames`
|
||||
* Opening config panel does not close inventory panel now
|
||||
* Remove `Input direction conflict` check while using `Remove some build conditions`
|
||||
* Fix a bug that prevents `Belt signal alt format` from switching number formats for current belt signals
|
||||
* 2.2.6
|
||||
* New function: `Stop ejectors when available nodes are all filled up`
|
||||
* Fix a bug that absorb solar sails on unfinised nodes
|
||||
* 2.2.5
|
||||
* Skip all intermediate states and absorb solar sails instantly while enable `Quick absorb`, `Skip bullet period` and `Skip absorption period` at the same time.
|
||||
* Fix a problem that `Quick absorb` does not absorb all solar sails instantly when most nodes are full.
|
||||
* Fix crash while using with some mods
|
||||
* 2.2.4
|
||||
* New function: `Enable player actions in globe view`
|
||||
* Fix UI bug
|
||||
* 2.2.3
|
||||
* New function: `Remove some build conditions`
|
||||
* Fix compatibility with some mods
|
||||
* 2.2.2
|
||||
* New function: `Assign gamesave to currrnet account`
|
||||
* New subfunction: `Belt signal alt format`
|
||||
* Fix a crash on using `Initialize this Planet`
|
||||
* Fix belt build in `Finish build immediately`
|
||||
* 2.2.1
|
||||
* Check condition for miners even when `Build without condition` is enabled.
|
||||
* Fix a patch issue that may cause `Build without condition` not working.
|
||||
* 2.2.0
|
||||
* Add some power related functions
|
||||
* Add a subfunction to belt signal item generation, which simulates production process of raws and intermediates on statistics
|
||||
* Split some functions from Architect mode
|
||||
* 2.1.0
|
||||
* Belt signal item generation
|
||||
* Fix window display priority which may cause tips to be covered by main window
|
||||
* 2.0.0
|
||||
* Refactorying codes
|
||||
* UI implementation
|
||||
* Add a lot of functions
|
||||
* 1.0.0
|
||||
* Initial release
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>中文读我</summary>
|
||||
|
||||
## 更新日志
|
||||
|
||||
* 2.4.2
|
||||
* 修复了严重的系列BUG:
|
||||
* 在启用`跳过子弹阶段`或`跳过吸收阶段`并且没有火箭发射时,戴森球的发电量未实时更新
|
||||
* 点击`立即完成戴森壳建造`或`移除戴森球上的所有框架`时,戴森球的发电量未实时更新
|
||||
* 2.4.1
|
||||
* 新增功能:`移除戴森球上的所有框架`
|
||||
* 可以节省火箭,且几乎不影响发电效率
|
||||
* 会保留节点和壳面,不影响太阳帆的吸收
|
||||
* `沙土不够时依然可以整改地形`:现在支持蓝图粘贴和掩埋黑雾核心钻机
|
||||
* `传送带信号物品生成`:修复对递归配方的支持,兼容一些mod
|
||||
* 2.4.0
|
||||
* 支持游戏版本 0.10.33
|
||||
* `生成仙术戴森壳`:此功能现在对所有用户开放,不再需要启用特定的配置项。
|
||||
* 2.3.32
|
||||
* `立即完成戴森壳建造`:修复了一个崩溃问题
|
||||
* 2.3.31
|
||||
* 新功能:`解锁戴森球最大轨道半径`
|
||||
* `移除当前存档的元数据消耗记录`:修复实现
|
||||
* 增加了3个用于制作仙术戴森壳的按钮,你必须在设置文件里开启`DysonSphere`分类的`IllegalDysonShellFunctionsEnabled`才能看到它们
|
||||
* `生成单层仙术戴森壳`
|
||||
* `保留发电量最高的戴森壳并移除其他戴森壳`
|
||||
* `从发电量最高的壳复制戴森壳`
|
||||
* 2.3.30
|
||||
* 修复了启用`无条件建造`或`无碰撞`时的警告问题
|
||||
* 粘贴大规模蓝图时大幅提升`立即完成建造`的性能表现
|
||||
* 2.3.29
|
||||
* 修复了与游戏更新0.10.32.25779的兼容性
|
||||
* 2.3.28
|
||||
* 新功能:`快速手动制造`
|
||||
* 修复了启用`自然资源采集不消耗`时部分面板的显示问题
|
||||
* 2.3.27
|
||||
* `跳过子弹阶段`和`全球弹射`:修复了与`戴森球计划 v0.10.32.25496`的兼容性
|
||||
* 2.3.26
|
||||
* 重构代码以适应UXAssist 1.2.0
|
||||
* 在使用此版本之前,您应先更新UXAssist到1.2.0或更高版本。
|
||||
* `立即完成戴森壳建造`:修复了可能导致错误的生产记录的问题
|
||||
* 2.3.25
|
||||
* 新功能:`无需空间翘曲器即可曲速飞行`
|
||||
* 新功能:`风力涡轮机供电覆盖全球`
|
||||
* 修复了`立即完成戴森壳建造`未生成太阳帆生产记录的问题
|
||||
* 2.3.24
|
||||
* `立即完成戴森壳建造`:修复了在某些情况下可能导致发电为负的问题
|
||||
* 2.3.23
|
||||
* 新功能:`立即完成戴森壳建造`
|
||||
* 修复了在游戏完全加载前打开配置面板可能导致的崩溃问题
|
||||
* 2.3.22
|
||||
* 修复了`平地抽水`
|
||||
* 2.3.21
|
||||
* `在物流总控面板上可以从非本地行星取放物品`:当从非本地星球的物流站移除槽位时,物品会放回玩家的背包
|
||||
* `开发模式快捷键`:摄像机位(Pose)相关的快捷键现在生效了
|
||||
* 2.3.20
|
||||
* 新功能:`在物流总控面板上可以从非本地行星取放物品`
|
||||
* 2.3.19
|
||||
* 新功能:
|
||||
* `移除所有元数据消耗记录`
|
||||
* `移除当前存档的元数据消耗记录`
|
||||
* `解除当前存档因使用元数据导致的成就限制`
|
||||
* 2.3.18
|
||||
* 新功能:
|
||||
* `传送到外太空`,这会将你传送到距离最远星球50光年的外太空
|
||||
* `传送到选中天体`
|
||||
* 修复了`组合键解锁科技`的逻辑
|
||||
* `无条件建造`现在不会隐藏传送带的旋转信息了
|
||||
* 2.3.17
|
||||
* 适配游戏版本0.10.30.23292
|
||||
* 2.3.16
|
||||
* 为`传送带信号物品生成`添加了两个选项:
|
||||
* `统计信息里将生成计算为产物`
|
||||
* `统计信息里将移除计算为消耗`
|
||||
* 新功能:`提升物流塔和大型采矿机的最大功耗`
|
||||
* 物流塔:将最大充电功率提高到3GW(星际物流塔)和600MW(行星物流塔)(原来的10倍)
|
||||
* 大型采矿机:将最大采矿速度提高到1000%
|
||||
* 2.3.15
|
||||
* 新功能:
|
||||
* `快速传送(和沙盒模式一样)`
|
||||
* `机甲和战斗无人机无敌`
|
||||
* `建筑无敌`
|
||||
* 2.3.14
|
||||
* 移除了`无条件建造`和`无碰撞`的默认快捷键,以避免误操作。如有需要请手动在系统选项窗口中设置。
|
||||
* 修复了翻译问题。
|
||||
* 2.3.13
|
||||
* 修复了快捷键无效和设置窗口上的按键显示问题
|
||||
* 2.3.12
|
||||
* 添加了一个快捷键来切换`无碰撞`,你可以在系统设置面板中修改快捷键。
|
||||
* 在使用快捷键切换`无条件建造`和`无碰撞`时添加了实时提示信息。
|
||||
* 2.3.11
|
||||
* 添加了一个快捷键来切换`无条件建造`,你可以在系统设置面板中修改快捷键。这依赖于[UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist) 1.0.15或更高版本
|
||||
* 2.3.10
|
||||
* 修复了以下功能在新游戏版本中不生效的问题:
|
||||
* `平地抽水`
|
||||
* `沙土不够时依然可以整改地形`
|
||||
* 2.3.9
|
||||
* 支持游戏版本0.10.28.21219
|
||||
* 2.3.8
|
||||
* 修复了启用`建造秒完成`时开新游戏可能导致崩溃的问题
|
||||
* 修复了UI按钮宽度
|
||||
* 2.3.7
|
||||
* 支持游戏版本0.10.28.20759
|
||||
* 修复了传送带信号有时候物品生成速度和设置不匹配的问题
|
||||
* 2.3.6
|
||||
* 在`建造秒完成`中支持UXAssist的新功能
|
||||
* 在启用`无条件建造`时添加警告信息
|
||||
* 修复了`建造秒完成`可能导致部分建筑无法立即完成的问题
|
||||
* 2.3.5
|
||||
* 修复了`跳过子弹阶段`可能导致崩溃的问题
|
||||
* 2.3.4
|
||||
* 使用UXAssist 1.0.2的新页签布局
|
||||
* 修复了一些小bug
|
||||
* 2.3.3
|
||||
* 修复了`跳过子弹阶段`可能导致崩溃的问题
|
||||
* 使用Alt解锁科技时,现在`矿物利用`的科技解锁到10000级而不是7200级,因为UXAssist已修复对应bug
|
||||
* 2.3.2
|
||||
* 母星系的选项移动到了[UniverseGenTweaks](https://dsp.thunderstore.io/package/soarqin/UniverseGenTweaks/)
|
||||
* 优化了`快速吸收`,现在消耗更少的CPU,并且会轮流打向各节点
|
||||
* `高速采集`现在可以保证油井的最大产出
|
||||
* 修复了`传送带信号物品生成`在选项关闭后再次启用时不生效的问题
|
||||
* 修复了`快速吸收`和`跳过子弹阶段`同时启用时可能导致吸收计算错误的问题
|
||||
* 修复了一些选项可能导致崩溃的问题
|
||||
* 2.3.1
|
||||
* 在manifest中添加UXAssist到依赖
|
||||
* 2.3.0
|
||||
* 将部分功能移动到单独的mod:[UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist)
|
||||
* 现在依赖[UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist),因此配置面板与UXAssist合并
|
||||
* 从开发模式快捷键中移除`LCtrl+A`,以避免误操作
|
||||
* 现在`建筑师模式`中配送机/物流机/物流船也无限了
|
||||
* 2.2.7
|
||||
* 新功能:`只建造节点不建造框架`
|
||||
* 打开设置面板时不再关闭背包面板
|
||||
* 在`移除部分不影响游戏逻辑的建造条件`启用时移除`输入方向冲突`的检查条件
|
||||
* 修复导致`传送带信号替换格式`不切换传送带信号数字格式的问题
|
||||
* 2.2.6
|
||||
* 新功能:`可用节点全部造完时停止弹射`
|
||||
* 修复了在未完成的节点上吸收太阳帆的问题
|
||||
* 2.2.5
|
||||
* 在同时启用`快速吸收`、`跳过子弹阶段`和`跳过吸收阶段`时,所有弹射的太阳帆会跳过所有中间环节立即吸收
|
||||
* 修复了`快速吸收`在大部分节点已满时无法立即吸收所有太阳帆的问题
|
||||
* 修复了与一些mod的兼容性问题
|
||||
* 2.2.4
|
||||
* 新功能:`在行星视图中允许玩家操作`
|
||||
* 修复了UI显示问题
|
||||
* 2.2.3
|
||||
* 新功能:`移除部分不影响游戏逻辑的建造条件`
|
||||
* 修复了与一些mod的兼容性问题
|
||||
* 2.2.2
|
||||
* 新功能:`将游戏存档绑定给当前账号`
|
||||
* 新子功能:`传送带信号替换格式`
|
||||
* 修复了`初始化本行星`可能导致崩溃的问题
|
||||
* 修复了`建造秒完成`中传送带建造的问题
|
||||
* 2.2.1
|
||||
* 即使在启用`无条件建造`时依然检查矿机的建造条件
|
||||
* 修复一个可能导致`无条件建造`不生效的问题
|
||||
* 2.2.0
|
||||
* 添加了一些发电相关功能
|
||||
* 为传送带信号物品生成添加了一个子功能,在统计面板模拟了原材料和中间产物的生产过程
|
||||
* 从建筑师模式中分离了一些功能
|
||||
* 2.1.0
|
||||
* 传送带信号物品生成
|
||||
* 修复窗口显示优先级可能导致提示信息被主窗口遮挡的问题
|
||||
* 2.0.0
|
||||
* 重构代码
|
||||
* UI实现
|
||||
* 添加了很多功能
|
||||
* 1.0.0
|
||||
* 初始版本
|
||||
|
||||
</details>
|
||||
@@ -1,4 +1,9 @@
|
||||
using BepInEx;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using BepInEx;
|
||||
using CheatEnabler.Patches;
|
||||
using HarmonyLib;
|
||||
using UXAssist.Common;
|
||||
|
||||
namespace CheatEnabler;
|
||||
|
||||
@@ -11,10 +16,10 @@ public class CheatEnabler : BaseUnityPlugin
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
DevShortcuts.Enabled = Config.Bind("General", "DevShortcuts", false, "Enable DevMode shortcuts");
|
||||
AbnormalDisabler.Enabled = Config.Bind("General", "DisableAbnormalChecks", false,
|
||||
GamePatch.DevShortcutsEnabled = Config.Bind("General", "DevShortcuts", false, "Enable DevMode shortcuts");
|
||||
GamePatch.AbnormalDisablerEnabled = Config.Bind("General", "DisableAbnormalChecks", false,
|
||||
"disable all abnormal checks");
|
||||
TechPatch.Enabled = Config.Bind("General", "UnlockTech", false,
|
||||
GamePatch.UnlockTechEnabled = Config.Bind("General", "UnlockTech", false,
|
||||
"Unlock clicked tech by holding key-modifilers(Shift/Alt/Ctrl)");
|
||||
FactoryPatch.ImmediateEnabled = Config.Bind("Build", "ImmediateBuild", false,
|
||||
"Build immediately");
|
||||
@@ -28,6 +33,10 @@ public class CheatEnabler : BaseUnityPlugin
|
||||
"Belt signal generator");
|
||||
FactoryPatch.BeltSignalNumberAltFormat = Config.Bind("Build", "BeltSignalNumberFormat", false,
|
||||
"Belt signal number format alternative format (AAAA=generation speed in minutes, B=proliferate points, C=stack count):\n AAAABC by default\n BCAAAA as alternative");
|
||||
FactoryPatch.BeltSignalCountGenEnabled = Config.Bind("Build", "BeltSignalCountGenerations", true,
|
||||
"Belt signal count generations as production in statistics");
|
||||
FactoryPatch.BeltSignalCountRemEnabled = Config.Bind("Build", "BeltSignalCountRemovals", true,
|
||||
"Belt signal count removals as comsumption in statistics");
|
||||
FactoryPatch.BeltSignalCountRecipeEnabled = Config.Bind("Build", "BeltSignalCountRecipe", false,
|
||||
"Belt signal count all raws and intermediates in statistics");
|
||||
FactoryPatch.RemovePowerSpaceLimitEnabled = Config.Bind("Build", "RemovePowerDistanceLimit", false,
|
||||
@@ -40,6 +49,12 @@ public class CheatEnabler : BaseUnityPlugin
|
||||
"Boost fuel power");
|
||||
FactoryPatch.BoostGeothermalPowerEnabled = Config.Bind("Build", "BoostGeothermalPower", false,
|
||||
"Boost geothermal power");
|
||||
FactoryPatch.WindTurbinesPowerGlobalCoverageEnabled = Config.Bind("Build", "PowerGlobalCoverage", false,
|
||||
"Global power coverage");
|
||||
FactoryPatch.GreaterPowerUsageInLogisticsEnabled = Config.Bind("Build", "GreaterPowerUsageInLogistics", false,
|
||||
"Increase maximum power usage in Logistic Stations and Advanced Mining Machines");
|
||||
FactoryPatch.ControlPanelRemoteLogisticsEnabled = Config.Bind("Build", "ControlPanelRemoteLogistics", false,
|
||||
"Retrieve/Place items from/to remote planets on logistics control panel");
|
||||
ResourcePatch.InfiniteResourceEnabled = Config.Bind("Planet", "AlwaysInfiniteResource", false,
|
||||
"always infinite natural resource");
|
||||
ResourcePatch.FastMiningEnabled = Config.Bind("Planet", "FastMining", false,
|
||||
@@ -47,9 +62,17 @@ public class CheatEnabler : BaseUnityPlugin
|
||||
PlanetPatch.WaterPumpAnywhereEnabled = Config.Bind("Planet", "WaterPumpAnywhere", false,
|
||||
"Can pump water anywhere (while water type is not None)");
|
||||
PlanetPatch.TerraformAnywayEnabled = Config.Bind("Planet", "TerraformAnyway", false,
|
||||
"Can do terraform without enough sands");
|
||||
"Can do terraform without enough soil piless");
|
||||
PlayerPatch.InstantHandCraftEnabled = Config.Bind("Player", "InstantHandCraft", false,
|
||||
"Enable instant hand-craft");
|
||||
PlayerPatch.InstantTeleportEnabled = Config.Bind("Player", "InstantTeleport", false,
|
||||
"Enable instant teleport (like that in Sandbox mode)");
|
||||
PlayerPatch.WarpWithoutSpaceWarpersEnabled = Config.Bind("Player", "WarpWithoutWarper", false,
|
||||
"Enable warp without warper");
|
||||
DysonSpherePatch.SkipBulletEnabled = Config.Bind("DysonSphere", "SkipBullet", false,
|
||||
"Skip bullet");
|
||||
DysonSpherePatch.FireAllBulletsEnabled = Config.Bind("DysonSphere", "FireAllBullets", false,
|
||||
"Fire all bullets at once");
|
||||
DysonSpherePatch.SkipAbsorbEnabled = Config.Bind("DysonSphere", "SkipAbsorb", false,
|
||||
"Skip absorption");
|
||||
DysonSpherePatch.QuickAbsorbEnabled = Config.Bind("DysonSphere", "QuickAbsorb", false,
|
||||
@@ -60,26 +83,39 @@ public class CheatEnabler : BaseUnityPlugin
|
||||
"Overclock ejector");
|
||||
DysonSpherePatch.OverclockSiloEnabled = Config.Bind("DysonSphere", "OverclockSilo", false,
|
||||
"Overclock silo");
|
||||
|
||||
DysonSpherePatch.UnlockMaxOrbitRadiusEnabled = Config.Bind("DysonSphere", "UnlockMaxOrbitRadius", false,
|
||||
"Unlock Dyson Sphere max orbit radius");
|
||||
DysonSpherePatch.UnlockMaxOrbitRadiusValue = Config.Bind("DysonSphere", "MaxOrbitRadiusValue", 10_000_000f,
|
||||
"Unlocked Dyson Sphere max orbit radius value");
|
||||
Functions.DysonSphereFunctions.IllegalDysonShellFunctionsEnabled = Config.Bind("DysonSphere", "IllegalDysonShellFunctions", false,
|
||||
"Enable illegal dyson shell functions");
|
||||
Functions.DysonSphereFunctions.ShellsCountForFunctions = Config.Bind("DysonSphere", "ShellsCountForFunctions", 2048,
|
||||
"Shells count for various functions");
|
||||
CombatPatch.MechaInvincibleEnabled = Config.Bind("Battle", "MechaInvincible", false,
|
||||
"Mecha and Drones/Fleets invincible");
|
||||
CombatPatch.BuildingsInvincibleEnabled = Config.Bind("Battle", "BuildingsInvincible", false,
|
||||
"Buildings invincible");
|
||||
UIConfigWindow.Init();
|
||||
_patches = Util.GetTypesFiltered(Assembly.GetExecutingAssembly(),
|
||||
t => string.Equals(t.Namespace, "CheatEnabler.Patches", StringComparison.Ordinal) || string.Equals(t.Namespace, "CheatEnabler.Functions", StringComparison.Ordinal));
|
||||
_patches?.Do(type => type.GetMethod("Init")?.Invoke(null, null));
|
||||
}
|
||||
|
||||
DevShortcuts.Init();
|
||||
AbnormalDisabler.Init();
|
||||
TechPatch.Init();
|
||||
FactoryPatch.Init();
|
||||
ResourcePatch.Init();
|
||||
PlanetPatch.Init();
|
||||
DysonSpherePatch.Init();
|
||||
private Type[] _patches;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_patches?.Do(type => type.GetMethod("Start")?.Invoke(null, null));
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
DysonSpherePatch.Uninit();
|
||||
PlanetPatch.Uninit();
|
||||
ResourcePatch.Uninit();
|
||||
FactoryPatch.Uninit();
|
||||
TechPatch.Uninit();
|
||||
AbnormalDisabler.Uninit();
|
||||
DevShortcuts.Uninit();
|
||||
_patches?.Do(type => type.GetMethod("Uninit")?.Invoke(null, null));
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (VFInput.inputing) return;
|
||||
FactoryPatch.OnInputUpdate();
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<BepInExPluginGuid>org.soardev.cheatenabler</BepInExPluginGuid>
|
||||
<Description>DSP MOD - CheatEnabler</Description>
|
||||
<Version>2.3.9</Version>
|
||||
<Version>2.4.2</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageId>CheatEnabler</PackageId>
|
||||
@@ -16,10 +16,19 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BepInEx.Core" Version="5.*" />
|
||||
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
|
||||
<PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.28.21219-r.0" />
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" />
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
|
||||
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UI">
|
||||
<HintPath>..\AssemblyFromGame\UnityEngine.UI.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
|
||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
@@ -28,7 +37,8 @@
|
||||
<ProjectReference Include="..\UXAssist\UXAssist.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip
zip -9 -j package/$(ProjectName)-$(Version).zip $(TargetPath) package/icon.png package/manifest.json README.md" />
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
|
||||
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip
|
||||
powershell Compress-Archive -Force -DestinationPath 'package/$(ProjectName)-$(Version).zip' -Path '$(TargetPath)', package/icon.png, package/manifest.json, README.md, CHANGELOG.md" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace CheatEnabler;
|
||||
public static class DevShortcuts
|
||||
{
|
||||
public static ConfigEntry<bool> Enabled;
|
||||
private static Harmony _patch;
|
||||
private static PlayerAction_Test _test;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(DevShortcuts));
|
||||
Enabled.SettingChanged += (_, _) =>
|
||||
{
|
||||
if (_test != null) _test.active = Enabled.Value;
|
||||
};
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerController), "Init")]
|
||||
private static void PlayerController_Init_Postfix(PlayerController __instance)
|
||||
{
|
||||
var cnt = __instance.actions.Length;
|
||||
var newActions = new PlayerAction[cnt + 1];
|
||||
for (var i = 0; i < cnt; i++)
|
||||
{
|
||||
newActions[i] = __instance.actions[i];
|
||||
}
|
||||
|
||||
_test = new PlayerAction_Test();
|
||||
_test.Init(__instance.player);
|
||||
_test.active = Enabled.Value;
|
||||
newActions[cnt] = _test;
|
||||
__instance.actions = newActions;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerAction_Test), "GameTick")]
|
||||
private static void PlayerAction_Test_GameTick_Postfix(PlayerAction_Test __instance)
|
||||
{
|
||||
__instance.Update();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(PlayerAction_Test), nameof(PlayerAction_Test.Update))]
|
||||
private static IEnumerable<CodeInstruction> PlayerAction_Test_Update_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.End().MatchBack(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(PlayerAction_Test), nameof(PlayerAction_Test.active)))
|
||||
);
|
||||
var pos = matcher.Pos;
|
||||
/* Remove Shift+F4 part of the method */
|
||||
matcher.Start().RemoveInstructions(pos).MatchForward(false,
|
||||
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(GameMain), "get_sandboxToolsEnabled")),
|
||||
new CodeMatch(OpCodes.Ldc_I4_0),
|
||||
new CodeMatch(OpCodes.Ceq)
|
||||
);
|
||||
var labels = matcher.Labels;
|
||||
matcher.SetInstructionAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldc_I4_1).WithLabels(labels)
|
||||
).RemoveInstructions(2);
|
||||
/* Remove Ctrl+A */
|
||||
matcher.Start().MatchForward(false,
|
||||
new CodeMatch(instr => (instr.opcode == OpCodes.Ldc_I4_S || instr.opcode == OpCodes.Ldc_I4) && instr.OperandIs(0x61)),
|
||||
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(UnityEngine.Input), nameof(UnityEngine.Input.GetKeyDown), new[] { typeof(UnityEngine.KeyCode) }))
|
||||
);
|
||||
labels = matcher.Labels;
|
||||
matcher.Labels = null;
|
||||
matcher.RemoveInstructions(2);
|
||||
matcher.Opcode = OpCodes.Br;
|
||||
matcher.Labels = labels;
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace CheatEnabler;
|
||||
namespace CheatEnabler.Functions;
|
||||
|
||||
public static class PlanetFunctions
|
||||
{
|
||||
public static void BuryAllVeins(bool bury)
|
||||
@@ -0,0 +1,189 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using UXAssist.Common;
|
||||
|
||||
namespace CheatEnabler.Functions;
|
||||
|
||||
public static class PlayerFunctions
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
I18N.Add("ClearAllMetadataConsumptionDetails",
|
||||
"""
|
||||
Metadata consumption records of all gamesaves are about to be cleared.
|
||||
You will gain following metadata back:
|
||||
""",
|
||||
"""
|
||||
所有存档的元数据消耗记录即将被清除,
|
||||
此操作将返还以下元数据:
|
||||
""");
|
||||
I18N.Add("ClearCurrentMetadataConsumptionDetails",
|
||||
"""
|
||||
Metadata consumption records of current gamesave are about to be cleared.
|
||||
You will gain following metadata back:
|
||||
""",
|
||||
"""
|
||||
当前存档的元数据消耗记录即将被清除,
|
||||
此操作将返还以下元数据:
|
||||
""");
|
||||
I18N.Add("NoMetadataConsumptionRecord",
|
||||
"No metadata consumption records found.",
|
||||
"未找到元数据消耗记录。");
|
||||
}
|
||||
|
||||
public static void TeleportToOuterSpace()
|
||||
{
|
||||
var maxSqrDistance = 0.0;
|
||||
var starPosition = VectorLF3.zero;
|
||||
foreach (var star in GameMain.galaxy.stars)
|
||||
{
|
||||
var sqrDistance = star.position.sqrMagnitude;
|
||||
if (sqrDistance > maxSqrDistance)
|
||||
{
|
||||
maxSqrDistance = sqrDistance;
|
||||
starPosition = star.position;
|
||||
}
|
||||
}
|
||||
if (starPosition == VectorLF3.zero) return;
|
||||
var distance = Math.Sqrt(maxSqrDistance);
|
||||
GameMain.mainPlayer.controller.actionSail.StartFastTravelToUPosition((starPosition + starPosition.normalized * 50) * GalaxyData.LY);
|
||||
}
|
||||
|
||||
public static void TeleportToSelectedAstronomical()
|
||||
{
|
||||
var starmap = UIRoot.instance?.uiGame?.starmap;
|
||||
if (starmap == null) return;
|
||||
if (starmap.focusPlanet != null)
|
||||
{
|
||||
GameMain.mainPlayer.controller.actionSail.StartFastTravelToPlanet(starmap.focusPlanet.planet);
|
||||
return;
|
||||
}
|
||||
var targetUPos = VectorLF3.zero;
|
||||
if (starmap.focusStar != null)
|
||||
{
|
||||
var star = starmap.focusStar.star;
|
||||
targetUPos = star.uPosition + VectorLF3.unit_x * star.physicsRadius;
|
||||
}
|
||||
else if (starmap.focusHive != null)
|
||||
{
|
||||
var hive = starmap.focusHive.hive;
|
||||
var id = hive.hiveAstroId - 1000000;
|
||||
if (id > 0 && id < starmap.spaceSector.astros.Length)
|
||||
{
|
||||
ref var astro = ref starmap.spaceSector.astros[id];
|
||||
targetUPos = astro.uPos + VectorLF3.unit_x * astro.uRadius;
|
||||
}
|
||||
}
|
||||
GameMain.mainPlayer.controller.actionSail.StartFastTravelToUPosition(targetUPos);
|
||||
}
|
||||
|
||||
private static void PurgePropertySystem(PropertySystem propertySystem)
|
||||
{
|
||||
var propertyDatas = propertySystem.propertyDatas;
|
||||
for (var i = 0; i < propertyDatas.Count;)
|
||||
{
|
||||
if (propertyDatas[i].totalProduction.Any(idcnt => idcnt.count > 0) || propertyDatas[i].totalConsumption.Any(idcnt => idcnt.count > 0))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
propertyDatas.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveAllMetadataConsumptions()
|
||||
{
|
||||
var propertySystem = DSPGame.propertySystem;
|
||||
if (propertySystem == null) return;
|
||||
PurgePropertySystem(propertySystem);
|
||||
var itemCnt = new int[6];
|
||||
foreach (var cons in propertySystem.propertyDatas.SelectMany(data => data.totalConsumption.Where(cons => cons.id is >= 6001 and <= 6006)))
|
||||
{
|
||||
itemCnt[cons.id - 6001] += cons.count;
|
||||
}
|
||||
|
||||
if (itemCnt.All(cnt => cnt == 0))
|
||||
{
|
||||
UIMessageBox.Show("Remove all metadata consumption records".Translate(), "NoMetadataConsumptionRecord".Translate(), "OK".Translate(), UIMessageBox.INFO);
|
||||
return;
|
||||
}
|
||||
var msg = "ClearAllMetadataConsumptionDetails".Translate();
|
||||
for (var i = 0; i < 6; i++)
|
||||
{
|
||||
if (itemCnt[i] > 0)
|
||||
{
|
||||
msg += $"\n {LDB.items.Select(i + 6001).propertyName} x{itemCnt[i]}";
|
||||
}
|
||||
}
|
||||
UIMessageBox.Show("Remove all metadata consumption records".Translate(), msg, "取消".Translate(), "确定".Translate(), UIMessageBox.QUESTION, null, () =>
|
||||
{
|
||||
foreach (var data in propertySystem.propertyDatas)
|
||||
{
|
||||
for (var i = 0; i < data.totalConsumption.Count; i++)
|
||||
{
|
||||
if (data.totalConsumption[i].count == 0) continue;
|
||||
var id = data.totalConsumption[i].id;
|
||||
data.totalConsumption[i] = new IDCNT(id, 0);
|
||||
}
|
||||
}
|
||||
PurgePropertySystem(propertySystem);
|
||||
propertySystem.SaveToFile();
|
||||
});
|
||||
}
|
||||
|
||||
public static void RemoveCurrentMetadataConsumptions()
|
||||
{
|
||||
var propertySystem = DSPGame.propertySystem;
|
||||
if (propertySystem == null) return;
|
||||
PurgePropertySystem(propertySystem);
|
||||
var itemCnt = new int[6];
|
||||
var seedKey = DSPGame.GameDesc.seedKey64;
|
||||
var clusterPropertyData = propertySystem.propertyDatas.FirstOrDefault(cpd => cpd.seedKey == seedKey);
|
||||
if (clusterPropertyData == null)
|
||||
{
|
||||
UIMessageBox.Show("Remove metadata consumption record in current game".Translate(), "NoMetadataConsumptionRecord".Translate(), "OK".Translate(), UIMessageBox.INFO);
|
||||
return;
|
||||
}
|
||||
var currentGamePropertyData = GameMain.data.history.propertyData;
|
||||
foreach (var cons in currentGamePropertyData.totalConsumption.Where(cons => cons.id is >= 6001 and <= 6006))
|
||||
{
|
||||
itemCnt[cons.id - 6001] += cons.count;
|
||||
}
|
||||
|
||||
if (itemCnt.All(cnt => cnt == 0))
|
||||
{
|
||||
UIMessageBox.Show("Remove metadata consumption record in current game".Translate(), "NoMetadataConsumptionRecord".Translate(), "OK".Translate(), UIMessageBox.INFO);
|
||||
return;
|
||||
}
|
||||
var msg = "ClearCurrentMetadataConsumptionDetails".Translate();
|
||||
for (var i = 0; i < 6; i++)
|
||||
{
|
||||
if (itemCnt[i] > 0)
|
||||
{
|
||||
msg += $"\n {LDB.items.Select(i + 6001).propertyName} x{itemCnt[i]}";
|
||||
}
|
||||
}
|
||||
UIMessageBox.Show("Remove metadata consumption record in current game".Translate(), msg, "取消".Translate(), "确定".Translate(), UIMessageBox.QUESTION, null, () =>
|
||||
{
|
||||
for (var i = 0; i < clusterPropertyData.totalConsumption.Count; i++)
|
||||
{
|
||||
if (clusterPropertyData.totalConsumption[i].count == 0) continue;
|
||||
var id = clusterPropertyData.totalConsumption[i].id;
|
||||
if (id < 6001 || id > 6006) continue;
|
||||
var currentGameCount = itemCnt[id - 6001];
|
||||
if (currentGameCount == 0) continue;
|
||||
var totalCount = clusterPropertyData.totalConsumption[i].count;
|
||||
clusterPropertyData.totalConsumption[i] = new IDCNT(id, totalCount > currentGameCount ? totalCount - currentGameCount : 0);
|
||||
}
|
||||
PurgePropertySystem(propertySystem);
|
||||
propertySystem.SaveToFile();
|
||||
});
|
||||
}
|
||||
|
||||
public static void ClearMetadataBanAchievements()
|
||||
{
|
||||
GameMain.history.hasUsedPropertyBanAchievement = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
using UXAssist.Common;
|
||||
|
||||
namespace CheatEnabler.Patches;
|
||||
|
||||
public static class CombatPatch
|
||||
{
|
||||
public static ConfigEntry<bool> MechaInvincibleEnabled;
|
||||
public static ConfigEntry<bool> BuildingsInvincibleEnabled;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
MechaInvincibleEnabled.SettingChanged += (_, _) => MechaInvincible.Enable(MechaInvincibleEnabled.Value);
|
||||
BuildingsInvincibleEnabled.SettingChanged += (_, _) => BuildingsInvincible.Enable(BuildingsInvincibleEnabled.Value);
|
||||
}
|
||||
|
||||
public static void Start()
|
||||
{
|
||||
MechaInvincible.Enable(MechaInvincibleEnabled.Value);
|
||||
BuildingsInvincible.Enable(BuildingsInvincibleEnabled.Value);
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
BuildingsInvincible.Enable(false);
|
||||
MechaInvincible.Enable(false);
|
||||
}
|
||||
|
||||
private class MechaInvincible : PatchImpl<MechaInvincible>
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(Player), nameof(Player.invincible), MethodType.Getter)]
|
||||
private static IEnumerable<CodeInstruction> Player_get_invincible_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.Start().RemoveInstructions(matcher.Length).Insert(
|
||||
new CodeInstruction(OpCodes.Ldc_I4_1),
|
||||
new CodeInstruction(OpCodes.Ret)
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(SkillSystem), nameof(SkillSystem.DamageGroundObjectByLocalCaster))]
|
||||
[HarmonyPatch(typeof(SkillSystem), nameof(SkillSystem.DamageGroundObjectByRemoteCaster))]
|
||||
[HarmonyPatch(typeof(SkillSystem), nameof(SkillSystem.DamageObject))]
|
||||
private static IEnumerable<CodeInstruction> SkillSystem_DamageObject_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator, MethodBase __originalMethod)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(ci => ci.IsLdarg()),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(SkillTargetLocal), nameof(SkillTargetLocal.type))),
|
||||
new CodeMatch(OpCodes.Ldc_I4_6),
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Bne_Un || ci.opcode == OpCodes.Bne_Un_S)
|
||||
);
|
||||
matcher.Repeat(m => m.Advance(4).InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldc_I4_0),
|
||||
new CodeInstruction(OpCodes.Starg_S, __originalMethod.Name == "DamageObject" ? 1 : 2)
|
||||
));
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
private class BuildingsInvincible : PatchImpl<BuildingsInvincible>
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(SkillSystem), nameof(SkillSystem.DamageGroundObjectByLocalCaster))]
|
||||
[HarmonyPatch(typeof(SkillSystem), nameof(SkillSystem.DamageGroundObjectByRemoteCaster))]
|
||||
private static IEnumerable<CodeInstruction> SkillSystem_DamageObject_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(ci => ci.IsLdarg()),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(SkillTargetLocal), nameof(SkillTargetLocal.type))),
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Brtrue || ci.opcode == OpCodes.Brtrue_S),
|
||||
new CodeMatch(OpCodes.Ldarg_1)
|
||||
).Advance(3).Insert(
|
||||
new CodeInstruction(OpCodes.Ldc_I4_0),
|
||||
new CodeInstruction(OpCodes.Starg_S, 2)
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,21 +3,24 @@ using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
using UXAssist.Common;
|
||||
using GameLogicProc = UXAssist.Common.GameLogic;
|
||||
|
||||
namespace CheatEnabler;
|
||||
namespace CheatEnabler.Patches;
|
||||
|
||||
public static class DysonSpherePatch
|
||||
public class DysonSpherePatch : PatchImpl<DysonSpherePatch>
|
||||
{
|
||||
public static ConfigEntry<bool> SkipBulletEnabled;
|
||||
public static ConfigEntry<bool> FireAllBulletsEnabled;
|
||||
public static ConfigEntry<bool> SkipAbsorbEnabled;
|
||||
public static ConfigEntry<bool> QuickAbsorbEnabled;
|
||||
public static ConfigEntry<bool> EjectAnywayEnabled;
|
||||
public static ConfigEntry<bool> OverclockEjectorEnabled;
|
||||
public static ConfigEntry<bool> OverclockSiloEnabled;
|
||||
public static ConfigEntry<bool> UnlockMaxOrbitRadiusEnabled;
|
||||
public static ConfigEntry<float> UnlockMaxOrbitRadiusValue;
|
||||
private static bool _instantAbsorb;
|
||||
|
||||
private static Harmony _dysonSpherePatch;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
SkipBulletEnabled.SettingChanged += (_, _) => SkipBulletPatch.Enable(SkipBulletEnabled.Value);
|
||||
@@ -26,27 +29,43 @@ public static class DysonSpherePatch
|
||||
EjectAnywayEnabled.SettingChanged += (_, _) => EjectAnywayPatch.Enable(EjectAnywayEnabled.Value);
|
||||
OverclockEjectorEnabled.SettingChanged += (_, _) => OverclockEjector.Enable(OverclockEjectorEnabled.Value);
|
||||
OverclockSiloEnabled.SettingChanged += (_, _) => OverclockSilo.Enable(OverclockSiloEnabled.Value);
|
||||
UnlockMaxOrbitRadiusEnabled.SettingChanged += (_, _) => UnlockMaxOrbitRadius.Enable(UnlockMaxOrbitRadiusEnabled.Value);
|
||||
|
||||
FireAllBulletsEnabled.SettingChanged += (_, _) => SkipBulletPatch.SetFireAllBullets(FireAllBulletsEnabled.Value);
|
||||
}
|
||||
|
||||
public static void Start()
|
||||
{
|
||||
SkipBulletPatch.Enable(SkipBulletEnabled.Value);
|
||||
SkipAbsorbPatch.Enable(SkipAbsorbEnabled.Value);
|
||||
QuickAbsorbPatch.Enable(QuickAbsorbEnabled.Value);
|
||||
EjectAnywayPatch.Enable(EjectAnywayEnabled.Value);
|
||||
OverclockEjector.Enable(OverclockEjectorEnabled.Value);
|
||||
OverclockSilo.Enable(OverclockSiloEnabled.Value);
|
||||
_dysonSpherePatch ??= Harmony.CreateAndPatchAll(typeof(DysonSpherePatch));
|
||||
UnlockMaxOrbitRadius.Enable(UnlockMaxOrbitRadiusEnabled.Value);
|
||||
Enable(true);
|
||||
SkipBulletPatch.SetFireAllBullets(FireAllBulletsEnabled.Value);
|
||||
}
|
||||
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
_dysonSpherePatch?.UnpatchSelf();
|
||||
_dysonSpherePatch = null;
|
||||
Enable(false);
|
||||
SkipBulletPatch.Enable(false);
|
||||
SkipAbsorbPatch.Enable(false);
|
||||
QuickAbsorbPatch.Enable(false);
|
||||
EjectAnywayPatch.Enable(false);
|
||||
OverclockEjector.Enable(false);
|
||||
OverclockSilo.Enable(false);
|
||||
UnlockMaxOrbitRadius.Enable(false);
|
||||
}
|
||||
|
||||
|
||||
// [HarmonyPostfix]
|
||||
// [HarmonyPatch(typeof(DysonShell), nameof(DysonShell.ImportFromBlueprint))]
|
||||
// private static void DysonShell_ImportFromBlueprint_Postfix(DysonShell __instance)
|
||||
// {
|
||||
// CheatEnabler.Logger.LogDebug($"[DysonShell.ImportFromBlueprint] vertCount={__instance.vertexCount}, cpPerVertex={__instance.cpPerVertex}, cpMax={__instance.cellPointMax}");
|
||||
// }
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(DysonNode), nameof(DysonNode.OrderConstructCp))]
|
||||
private static IEnumerable<CodeInstruction> DysonNode_OrderConstructCp_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
@@ -81,13 +100,18 @@ public static class DysonSpherePatch
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
private static class SkipBulletPatch
|
||||
private class SkipBulletPatch : PatchImpl<SkipBulletPatch>
|
||||
{
|
||||
private static long _sailLifeTime;
|
||||
private static DysonSailCache[][] _sailsCache;
|
||||
private static int[] _sailsCacheLen, _sailsCacheCapacity;
|
||||
private static Harmony _patch;
|
||||
|
||||
private static bool _fireAllBullets;
|
||||
|
||||
public static void SetFireAllBullets(bool value)
|
||||
{
|
||||
_fireAllBullets = value;
|
||||
}
|
||||
|
||||
private struct DysonSailCache
|
||||
{
|
||||
public DysonSail Sail;
|
||||
@@ -106,19 +130,16 @@ public static class DysonSpherePatch
|
||||
}
|
||||
}
|
||||
|
||||
public static void Enable(bool on)
|
||||
protected override void OnEnable()
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
UpdateSailLifeTime();
|
||||
UpdateSailsCacheForThisGame();
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(SkipBulletPatch));
|
||||
}
|
||||
else
|
||||
{
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
UpdateSailLifeTime();
|
||||
UpdateSailsCacheForThisGame();
|
||||
GameLogicProc.OnGameBegin += OnGameBegin;
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
GameLogicProc.OnGameBegin -= OnGameBegin;
|
||||
}
|
||||
|
||||
private static void UpdateSailLifeTime()
|
||||
@@ -138,7 +159,7 @@ public static class DysonSpherePatch
|
||||
Array.Clear(_sailsCacheLen, 0, starCount);
|
||||
Array.Clear(_sailsCacheCapacity, 0, starCount);
|
||||
}
|
||||
|
||||
|
||||
private static void SetSailsCacheCapacity(int index, int capacity)
|
||||
{
|
||||
var newCache = new DysonSailCache[capacity];
|
||||
@@ -151,9 +172,7 @@ public static class DysonSpherePatch
|
||||
_sailsCacheCapacity[index] = capacity;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.Begin))]
|
||||
private static void GameMain_Begin_Postfix()
|
||||
private static void OnGameBegin()
|
||||
{
|
||||
UpdateSailsCacheForThisGame();
|
||||
UpdateSailLifeTime();
|
||||
@@ -168,7 +187,7 @@ public static class DysonSpherePatch
|
||||
UpdateSailLifeTime();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(EjectorComponent), nameof(EjectorComponent.InternalUpdate))]
|
||||
private static IEnumerable<CodeInstruction> EjectorComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
@@ -179,25 +198,28 @@ public static class DysonSpherePatch
|
||||
).Advance(2);
|
||||
var start = matcher.Pos;
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Pop)
|
||||
).Advance(1);
|
||||
new CodeMatch(OpCodes.Ldc_I4_M1),
|
||||
new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(EjectorComponent), nameof(EjectorComponent.direction)))
|
||||
).Advance(2);
|
||||
var end = matcher.Pos;
|
||||
matcher.Start().Advance(start).RemoveInstructions(end - start).Insert(
|
||||
new CodeInstruction(OpCodes.Ldarg_2),
|
||||
new CodeInstruction(OpCodes.Ldarg_0),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(EjectorComponent), nameof(EjectorComponent.orbitId))),
|
||||
new CodeInstruction(OpCodes.Ldloc_S, 8),
|
||||
new CodeInstruction(OpCodes.Ldloc_S, 10),
|
||||
new CodeInstruction(OpCodes.Ldarg_3),
|
||||
new CodeInstruction(OpCodes.Ldloc_S, 9),
|
||||
new CodeInstruction(OpCodes.Ldloc_S, 11),
|
||||
new CodeInstruction(OpCodes.Ldarg_S, 6),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(SkipBulletPatch), nameof(SkipBulletPatch.AddDysonSail)))
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
private static void AddDysonSail(DysonSwarm swarm, int orbitId, VectorLF3 uPos, VectorLF3 endVec)
|
||||
private static void AddDysonSail(ref EjectorComponent ejector, DysonSwarm swarm, VectorLF3 uPos, VectorLF3 endVec, int[] consumeRegister)
|
||||
{
|
||||
var index = swarm.starData.index;
|
||||
var orbitId = ejector.orbitId;
|
||||
var delta1 = endVec - swarm.starData.uPosition;
|
||||
var delta2 = VectorLF3.Cross(endVec - uPos, swarm.orbits[orbitId].up).normalized * Math.Sqrt(swarm.dysonSphere.gravity / swarm.orbits[orbitId].radius);
|
||||
var bulletCount = ejector.bulletCount;
|
||||
lock (swarm)
|
||||
{
|
||||
var cache = _sailsCache[index];
|
||||
@@ -207,6 +229,24 @@ public static class DysonSpherePatch
|
||||
SetSailsCacheCapacity(index, 256);
|
||||
cache = _sailsCache[index];
|
||||
}
|
||||
if (_fireAllBullets)
|
||||
{
|
||||
var capacity = _sailsCacheCapacity[index];
|
||||
var leastCapacity = len + bulletCount;
|
||||
if (leastCapacity > capacity)
|
||||
{
|
||||
do
|
||||
{
|
||||
capacity *= 2;
|
||||
} while (leastCapacity > capacity);
|
||||
SetSailsCacheCapacity(index, capacity);
|
||||
cache = _sailsCache[index];
|
||||
}
|
||||
_sailsCacheLen[index] = len + bulletCount;
|
||||
var end = len + bulletCount;
|
||||
for (var i = len; i < end; i++)
|
||||
cache[i].FromData(delta1, delta2 + RandomTable.SphericNormal(ref swarm.randSeed, 0.5), orbitId);
|
||||
}
|
||||
else
|
||||
{
|
||||
var capacity = _sailsCacheCapacity[index];
|
||||
@@ -215,14 +255,48 @@ public static class DysonSpherePatch
|
||||
SetSailsCacheCapacity(index, capacity * 2);
|
||||
cache = _sailsCache[index];
|
||||
}
|
||||
_sailsCacheLen[index] = len + 1;
|
||||
cache[len].FromData(delta1, delta2 + RandomTable.SphericNormal(ref swarm.randSeed, 0.5), orbitId);
|
||||
}
|
||||
_sailsCacheLen[index] = len + 1;
|
||||
cache[len].FromData(delta1, delta2 + RandomTable.SphericNormal(ref swarm.randSeed, 0.5), orbitId);
|
||||
}
|
||||
|
||||
if (_fireAllBullets)
|
||||
{
|
||||
if (!ejector.incUsed)
|
||||
{
|
||||
ejector.incUsed = ejector.bulletInc >= bulletCount;
|
||||
}
|
||||
ejector.bulletInc = 0;
|
||||
ejector.bulletCount = 0;
|
||||
lock (consumeRegister)
|
||||
{
|
||||
consumeRegister[ejector.bulletId] += bulletCount;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var inc = ejector.bulletInc / bulletCount;
|
||||
if (!ejector.incUsed)
|
||||
{
|
||||
ejector.incUsed = inc > 0;
|
||||
}
|
||||
ejector.bulletInc -= inc;
|
||||
ejector.bulletCount = bulletCount - 1;
|
||||
if (ejector.bulletCount == 0)
|
||||
{
|
||||
ejector.bulletInc = 0;
|
||||
}
|
||||
lock (consumeRegister)
|
||||
{
|
||||
consumeRegister[ejector.bulletId]++;
|
||||
}
|
||||
}
|
||||
ejector.time = ejector.coldSpend;
|
||||
ejector.direction = -1;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(DysonSwarm), "GameTick")]
|
||||
[HarmonyPatch(typeof(DysonSwarm), nameof(DysonSwarm.GameTick))]
|
||||
public static void DysonSwarm_GameTick_Prefix(DysonSwarm __instance, long time)
|
||||
{
|
||||
var index = __instance.starData.index;
|
||||
@@ -260,9 +334,10 @@ public static class DysonSpherePatch
|
||||
if (node.ConstructCp() == null) break;
|
||||
if (idx == 0)
|
||||
{
|
||||
sphereProductRegister[11901] += len;
|
||||
sphereConsumeRegister[11901] += len;
|
||||
sphereProductRegister[11903] += len;
|
||||
sphereProductRegister[ProductionStatistics.SOLAR_SAIL_ID] += len;
|
||||
sphereConsumeRegister[ProductionStatistics.SOLAR_SAIL_ID] += len;
|
||||
sphereProductRegister[ProductionStatistics.DYSON_CELL_ID] += len;
|
||||
__instance.dysonSphere.needRecalculatePower = true;
|
||||
return;
|
||||
}
|
||||
idx--;
|
||||
@@ -273,9 +348,10 @@ public static class DysonSpherePatch
|
||||
var absorbCnt = len - 1 - idx;
|
||||
if (absorbCnt > 0)
|
||||
{
|
||||
sphereProductRegister[11901] += absorbCnt;
|
||||
sphereConsumeRegister[11901] += absorbCnt;
|
||||
sphereProductRegister[11903] += absorbCnt;
|
||||
sphereProductRegister[ProductionStatistics.SOLAR_SAIL_ID] += absorbCnt;
|
||||
sphereConsumeRegister[ProductionStatistics.SOLAR_SAIL_ID] += absorbCnt;
|
||||
sphereProductRegister[ProductionStatistics.DYSON_CELL_ID] += absorbCnt;
|
||||
__instance.dysonSphere.needRecalculatePower = true;
|
||||
}
|
||||
}
|
||||
for (; idx >= 0; idx--)
|
||||
@@ -284,21 +360,17 @@ public static class DysonSpherePatch
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class SkipAbsorbPatch
|
||||
{
|
||||
private static Harmony _patch;
|
||||
|
||||
public static void Enable(bool on)
|
||||
private class SkipAbsorbPatch : PatchImpl<SkipAbsorbPatch>
|
||||
{
|
||||
protected override void OnEnable()
|
||||
{
|
||||
_instantAbsorb = SkipAbsorbEnabled.Value && QuickAbsorbEnabled.Value;
|
||||
if (on)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(SkipAbsorbPatch));
|
||||
return;
|
||||
}
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
_instantAbsorb = QuickAbsorbEnabled.Value;
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
_instantAbsorb = false;
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
@@ -310,54 +382,37 @@ public static class DysonSpherePatch
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(ExpiryOrder), nameof(ExpiryOrder.index)))
|
||||
).Advance(1).RemoveInstructions(matcher.Length - matcher.Pos).Insert(
|
||||
// if (node.ConstructCp() != null)
|
||||
// {
|
||||
// this.dysonSphere.productRegister[11903]++;
|
||||
// }
|
||||
new CodeInstruction(OpCodes.Ldarg_1),
|
||||
new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(DysonNode), nameof(DysonNode.ConstructCp))),
|
||||
new CodeInstruction(OpCodes.Brfalse_S, label1),
|
||||
new CodeInstruction(OpCodes.Ldarg_0),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(DysonSwarm), nameof(DysonSwarm.dysonSphere))),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(DysonSphere), nameof(DysonSphere.productRegister))),
|
||||
new CodeInstruction(OpCodes.Ldc_I4, 11903),
|
||||
new CodeInstruction(OpCodes.Ldelema, typeof(int)),
|
||||
new CodeInstruction(OpCodes.Dup),
|
||||
new CodeInstruction(OpCodes.Ldind_I4),
|
||||
new CodeInstruction(OpCodes.Ldc_I4_1),
|
||||
new CodeInstruction(OpCodes.Add),
|
||||
new CodeInstruction(OpCodes.Stind_I4),
|
||||
|
||||
// this.RemoveSolarSail(index);
|
||||
new CodeInstruction(OpCodes.Ldarg_0).WithLabels(label1),
|
||||
new CodeInstruction(OpCodes.Ldarg_1),
|
||||
new CodeInstruction(OpCodes.Ldloc_1),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(DysonSwarm), nameof(DysonSwarm.RemoveSolarSail))),
|
||||
|
||||
Transpilers.EmitDelegate((DysonSwarm swarm, DysonNode node, int index) => {
|
||||
if (node.ConstructCp() != null)
|
||||
{
|
||||
swarm.dysonSphere.productRegister[ProductionStatistics.DYSON_CELL_ID]++;
|
||||
swarm.dysonSphere.needRecalculatePower = true;
|
||||
}
|
||||
swarm.RemoveSolarSail(index);
|
||||
}),
|
||||
// return false;
|
||||
new CodeInstruction(OpCodes.Ldc_I4_1),
|
||||
new CodeInstruction(OpCodes.Ldc_I4_0),
|
||||
new CodeInstruction(OpCodes.Ret)
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
private static class QuickAbsorbPatch
|
||||
{
|
||||
private static Harmony _patch;
|
||||
|
||||
public static void Enable(bool on)
|
||||
private class QuickAbsorbPatch : PatchImpl<QuickAbsorbPatch>
|
||||
{
|
||||
protected override void OnEnable()
|
||||
{
|
||||
_instantAbsorb = SkipAbsorbEnabled.Value && QuickAbsorbEnabled.Value;
|
||||
if (on)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(QuickAbsorbPatch));
|
||||
}
|
||||
else
|
||||
{
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
_instantAbsorb = SkipAbsorbEnabled.Value;
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
_instantAbsorb = false;
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(DysonSphereLayer), nameof(DysonSphereLayer.GameTick))]
|
||||
private static IEnumerable<CodeInstruction> DysonSphereLayer_GameTick_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
@@ -376,7 +431,7 @@ public static class DysonSpherePatch
|
||||
/* Insert a RETURN before old absorption functions */
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
|
||||
private static void DoAbsorb(DysonSphereLayer layer, long gameTick)
|
||||
{
|
||||
var nodeCount = layer.nodeCursor - 1;
|
||||
@@ -396,72 +451,42 @@ public static class DysonSpherePatch
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class EjectAnywayPatch
|
||||
{
|
||||
private static Harmony _patch;
|
||||
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(EjectAnywayPatch));
|
||||
}
|
||||
else
|
||||
{
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
}
|
||||
private class EjectAnywayPatch : PatchImpl<EjectAnywayPatch>
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(EjectorComponent), nameof(EjectorComponent.InternalUpdate))]
|
||||
private static IEnumerable<CodeInstruction> EjectorComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
matcher.End().MatchBack(false,
|
||||
new CodeMatch(instr => instr.opcode == OpCodes.Ldc_R8 && Math.Abs((double)instr.operand - 0.08715574) < 0.00000001)
|
||||
);
|
||||
var start = matcher.Pos - 3;
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.And)
|
||||
).Advance(1).MatchForward(false,
|
||||
new CodeMatch(OpCodes.And)
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(EjectorComponent), nameof(EjectorComponent.bulletCount)))
|
||||
);
|
||||
var end = matcher.Pos - 2;
|
||||
/* Remove angle checking codes, then add:
|
||||
* V_13 = this.bulletCount > 0;
|
||||
*/
|
||||
matcher.Start().Advance(start).RemoveInstructions(end - start).Insert(
|
||||
new CodeInstruction(OpCodes.Ldarg_0),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(EjectorComponent), nameof(EjectorComponent.bulletCount))),
|
||||
new CodeInstruction(OpCodes.Ldc_I4_0),
|
||||
new CodeInstruction(OpCodes.Cgt),
|
||||
new CodeInstruction(OpCodes.Stloc_S, 13)
|
||||
var end = matcher.Pos;
|
||||
matcher.Start().Advance(start).RemoveInstructions(end - start).MatchForward(false,
|
||||
new CodeMatch(ci => ci.IsStloc())
|
||||
).Advance(1);
|
||||
start = matcher.Pos;
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(EjectorComponent), nameof(EjectorComponent.autoOrbit)))
|
||||
);
|
||||
end = matcher.Pos;
|
||||
matcher.Start().Advance(start).RemoveInstructions(end - start);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
private static class OverclockEjector
|
||||
private class OverclockEjector : PatchImpl<OverclockEjector>
|
||||
{
|
||||
private static Harmony _patch;
|
||||
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(OverclockEjector));
|
||||
}
|
||||
else
|
||||
{
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(EjectorComponent), nameof(EjectorComponent.InternalUpdate))]
|
||||
private static IEnumerable<CodeInstruction> EjectAndSiloComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
private static IEnumerable<CodeInstruction> EjectComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
/* Add a multiply to ejector speed */
|
||||
@@ -510,25 +535,11 @@ public static class DysonSpherePatch
|
||||
}
|
||||
}
|
||||
|
||||
private static class OverclockSilo
|
||||
private class OverclockSilo : PatchImpl<OverclockSilo>
|
||||
{
|
||||
private static Harmony _patch;
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(OverclockSilo));
|
||||
}
|
||||
else
|
||||
{
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(SiloComponent), nameof(SiloComponent.InternalUpdate))]
|
||||
private static IEnumerable<CodeInstruction> EjectAndSiloComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
private static IEnumerable<CodeInstruction> SiloComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
/* Add a multiply to ejector speed */
|
||||
@@ -576,4 +587,53 @@ public static class DysonSpherePatch
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
private class UnlockMaxOrbitRadius : PatchImpl<UnlockMaxOrbitRadius>
|
||||
{
|
||||
protected override void OnEnable()
|
||||
{
|
||||
OnViewStarChange(null, null);
|
||||
UnlockMaxOrbitRadiusValue.SettingChanged += OnViewStarChange;
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
OnViewStarChange(null, null);
|
||||
UnlockMaxOrbitRadiusValue.SettingChanged -= OnViewStarChange;
|
||||
}
|
||||
|
||||
public static void OnViewStarChange(object o, EventArgs e)
|
||||
{
|
||||
var dysonEditor = UIRoot.instance?.uiGame?.dysonEditor;
|
||||
if (dysonEditor == null || !dysonEditor.gameObject.activeSelf) return;
|
||||
dysonEditor.selection?.onViewStarChange?.Invoke();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(DysonSphere), nameof(DysonSphere.CheckLayerRadius))]
|
||||
[HarmonyPatch(typeof(DysonSphere), nameof(DysonSphere.CheckSwarmRadius))]
|
||||
[HarmonyPatch(typeof(DysonSphere), nameof(DysonSphere.QueryLayerRadius))]
|
||||
[HarmonyPatch(typeof(DysonSphere), nameof(DysonSphere.QuerySwarmRadius))]
|
||||
[HarmonyPatch(typeof(UIDEAddLayerDialogue), nameof(UIDEAddLayerDialogue.OnViewStarChange))]
|
||||
[HarmonyPatch(typeof(UIDEAddSwarmDialogue), nameof(UIDEAddSwarmDialogue.OnViewStarChange))]
|
||||
[HarmonyPatch(typeof(UIDysonEditor), nameof(UIDysonEditor.OnViewStarChange))]
|
||||
[HarmonyPatch(typeof(UIDESwarmOrbitInfo), nameof(UIDESwarmOrbitInfo._OnInit))]
|
||||
[HarmonyPatch(typeof(UIDysonOrbitPreview), nameof(UIDysonOrbitPreview.UpdateAscNodeGizmos))]
|
||||
private static IEnumerable<CodeInstruction> MaxOrbitRadiusPatch_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(DysonSphere), nameof(DysonSphere.maxOrbitRadius)))
|
||||
);
|
||||
matcher.Repeat(m =>
|
||||
{
|
||||
m.Advance(1).InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Pop),
|
||||
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(DysonSpherePatch), nameof(UnlockMaxOrbitRadiusValue))),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(ConfigEntry<float>), nameof(ConfigEntry<float>.Value)))
|
||||
);
|
||||
});
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,311 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
using UnityEngine.Bindings;
|
||||
using UXAssist.Common;
|
||||
|
||||
namespace CheatEnabler.Patches;
|
||||
|
||||
public static class GamePatch
|
||||
{
|
||||
public static ConfigEntry<bool> DevShortcutsEnabled;
|
||||
public static ConfigEntry<bool> AbnormalDisablerEnabled;
|
||||
public static ConfigEntry<bool> UnlockTechEnabled;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
DevShortcutsEnabled.SettingChanged += (_, _) => DevShortcuts.Enable(DevShortcutsEnabled.Value);
|
||||
AbnormalDisablerEnabled.SettingChanged += (_, _) => AbnormalDisabler.Enable(AbnormalDisablerEnabled.Value);
|
||||
UnlockTechEnabled.SettingChanged += (_, _) => UnlockTech.Enable(UnlockTechEnabled.Value);
|
||||
}
|
||||
|
||||
public static void Start()
|
||||
{
|
||||
DevShortcuts.Enable(DevShortcutsEnabled.Value);
|
||||
AbnormalDisabler.Enable(AbnormalDisablerEnabled.Value);
|
||||
UnlockTech.Enable(UnlockTechEnabled.Value);
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
UnlockTech.Enable(false);
|
||||
AbnormalDisabler.Enable(false);
|
||||
DevShortcuts.Enable(false);
|
||||
}
|
||||
|
||||
public class AbnormalDisabler : PatchImpl<AbnormalDisabler>
|
||||
{
|
||||
private static Dictionary<int, AbnormalityDeterminator> _savedDeterminators;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
if (_savedDeterminators == null) return;
|
||||
var abnormalLogic = GameMain.gameScenario.abnormalityLogic;
|
||||
foreach (var p in _savedDeterminators)
|
||||
{
|
||||
p.Value.OnUnregEvent();
|
||||
}
|
||||
|
||||
abnormalLogic.determinators = [];
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
if (_savedDeterminators == null) return;
|
||||
var abnormalLogic = GameMain.gameScenario?.abnormalityLogic;
|
||||
if (abnormalLogic?.determinators == null) return;
|
||||
abnormalLogic.determinators = _savedDeterminators;
|
||||
foreach (var p in _savedDeterminators)
|
||||
{
|
||||
p.Value.OnRegEvent();
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(AbnormalityLogic), nameof(AbnormalityLogic.NotifyBeforeGameSave))]
|
||||
[HarmonyPatch(typeof(AbnormalityLogic), nameof(AbnormalityLogic.NotifyOnAssemblerRecipePick))]
|
||||
[HarmonyPatch(typeof(AbnormalityLogic), nameof(AbnormalityLogic.NotifyOnGameBegin))]
|
||||
[HarmonyPatch(typeof(AbnormalityLogic), nameof(AbnormalityLogic.NotifyOnMechaForgeTaskComplete))]
|
||||
[HarmonyPatch(typeof(AbnormalityLogic), nameof(AbnormalityLogic.NotifyOnUnlockTech))]
|
||||
[HarmonyPatch(typeof(AbnormalityLogic), nameof(AbnormalityLogic.NotifyOnUseConsole))]
|
||||
private static bool DisableAbnormalLogic()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(AbnormalityLogic), nameof(AbnormalityLogic.InitDeterminators))]
|
||||
private static void DisableAbnormalDeterminators(AbnormalityLogic __instance)
|
||||
{
|
||||
_savedDeterminators = __instance.determinators;
|
||||
if (!AbnormalDisablerEnabled.Value) return;
|
||||
__instance.determinators = [];
|
||||
foreach (var p in _savedDeterminators)
|
||||
{
|
||||
p.Value.OnUnregEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class DevShortcuts : PatchImpl<DevShortcuts>
|
||||
{
|
||||
private static PlayerAction_Test _test;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
if (_test != null) _test.active = true;
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
if (_test != null) _test.active = false;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerController), nameof(PlayerController.Init))]
|
||||
private static void PlayerController_Init_Postfix(PlayerController __instance)
|
||||
{
|
||||
var cnt = __instance.actions.Length;
|
||||
var newActions = new PlayerAction[cnt + 1];
|
||||
for (var i = 0; i < cnt; i++)
|
||||
{
|
||||
newActions[i] = __instance.actions[i];
|
||||
}
|
||||
|
||||
_test = new PlayerAction_Test();
|
||||
_test.Init(__instance.player);
|
||||
_test.active = DevShortcutsEnabled.Value;
|
||||
newActions[cnt] = _test;
|
||||
__instance.actions = newActions;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerAction_Test), nameof(PlayerAction_Test.GameTick))]
|
||||
private static void PlayerAction_Test_GameTick_Postfix(PlayerAction_Test __instance)
|
||||
{
|
||||
__instance.Update();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(PlayerAction_Test), nameof(PlayerAction_Test.Update))]
|
||||
private static IEnumerable<CodeInstruction> PlayerAction_Test_Update_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.End().MatchBack(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(PlayerAction_Test), nameof(PlayerAction_Test.active)))
|
||||
);
|
||||
var pos = matcher.Pos;
|
||||
/* Remove Shift+F4 part of the method */
|
||||
matcher.Start().RemoveInstructions(pos).MatchForward(false,
|
||||
new CodeMatch(OpCodes.Call, AccessTools.PropertyGetter(typeof(GameMain), nameof(GameMain.sandboxToolsEnabled))),
|
||||
new CodeMatch(OpCodes.Ldc_I4_0),
|
||||
new CodeMatch(OpCodes.Ceq)
|
||||
);
|
||||
var labels = matcher.Labels;
|
||||
matcher.SetInstructionAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldc_I4_1).WithLabels(labels)
|
||||
).RemoveInstructions(2);
|
||||
/* Remove Ctrl+A */
|
||||
matcher.Start().MatchForward(false,
|
||||
new CodeMatch(instr => (instr.opcode == OpCodes.Ldc_I4_S || instr.opcode == OpCodes.Ldc_I4) && instr.OperandIs(0x61)),
|
||||
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(UnityEngine.Input), nameof(UnityEngine.Input.GetKeyDown), [typeof(UnityEngine.KeyCode)]))
|
||||
);
|
||||
labels = matcher.Labels;
|
||||
matcher.Labels = null;
|
||||
matcher.RemoveInstructions(2);
|
||||
matcher.Opcode = OpCodes.Br;
|
||||
matcher.Labels = labels;
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(GameCamera), nameof(GameCamera.FrameLogic))]
|
||||
private static IEnumerable<CodeInstruction> GameCamera_Logic_Transpiler(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(GameCamera), nameof(GameCamera.finalPoser))),
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(CameraPoser), nameof(CameraPoser.cameraPose)))
|
||||
);
|
||||
var labels = matcher.Labels;
|
||||
matcher.Labels = null;
|
||||
matcher.Insert(
|
||||
new CodeInstruction(OpCodes.Ldarg_0).WithLabels(labels),
|
||||
Transpilers.EmitDelegate((GameCamera camera) =>
|
||||
{
|
||||
if (PlayerAction_Test.lockCam)
|
||||
{
|
||||
camera.finalPoser.cameraPose = PlayerAction_Test.camPose;
|
||||
}
|
||||
})
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
public class UnlockTech : PatchImpl<UnlockTech>
|
||||
{
|
||||
private static void UnlockTechRecursive(GameHistoryData history, [NotNull] TechProto techProto, int maxLevel = 10000)
|
||||
{
|
||||
var techStates = history.techStates;
|
||||
var techID = techProto.ID;
|
||||
if (techStates == null || !techStates.TryGetValue(techID, out var value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (value.unlocked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var maxLvl = Math.Min(maxLevel < 0 ? value.curLevel - maxLevel - 1 : maxLevel, value.maxLevel);
|
||||
|
||||
foreach (var preid in techProto.PreTechs)
|
||||
{
|
||||
var preProto = LDB.techs.Select(preid);
|
||||
if (preProto != null)
|
||||
UnlockTechRecursive(history, preProto, techProto.PreTechsMax ? 10000 : -1);
|
||||
}
|
||||
|
||||
foreach (var preid in techProto.PreTechsImplicit)
|
||||
{
|
||||
var preProto = LDB.techs.Select(preid);
|
||||
if (preProto != null)
|
||||
UnlockTechRecursive(history, preProto, techProto.PreTechsMax ? 10000 : -1);
|
||||
}
|
||||
|
||||
if (value.curLevel < techProto.Level) value.curLevel = techProto.Level;
|
||||
while (value.curLevel <= maxLvl)
|
||||
{
|
||||
if (value.curLevel == 0)
|
||||
{
|
||||
foreach (var recipe in techProto.UnlockRecipes)
|
||||
{
|
||||
history.UnlockRecipe(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
for (var j = 0; j < techProto.UnlockFunctions.Length; j++)
|
||||
{
|
||||
history.UnlockTechFunction(techProto.UnlockFunctions[j], techProto.UnlockValues[j], value.curLevel);
|
||||
}
|
||||
|
||||
for (var k = 0; k < techProto.AddItems.Length; k++)
|
||||
{
|
||||
history.GainTechAwards(techProto.AddItems[k], techProto.AddItemCounts[k]);
|
||||
}
|
||||
|
||||
value.curLevel++;
|
||||
}
|
||||
|
||||
value.unlocked = maxLvl >= value.maxLevel;
|
||||
value.curLevel = value.unlocked ? maxLvl : maxLvl + 1;
|
||||
value.hashNeeded = techProto.GetHashNeeded(value.curLevel);
|
||||
value.hashUploaded = value.unlocked ? value.hashNeeded : 0;
|
||||
techStates[techID] = value;
|
||||
history.RegFeatureKey(1000100);
|
||||
history.NotifyTechUnlock(techID, maxLvl, true);
|
||||
}
|
||||
|
||||
private static void OnClickTech(UITechNode node)
|
||||
{
|
||||
var history = GameMain.history;
|
||||
if (VFInput.shift)
|
||||
{
|
||||
if (VFInput.alt) return;
|
||||
if (VFInput.control)
|
||||
UnlockTechRecursive(history, node.techProto, -100);
|
||||
else
|
||||
UnlockTechRecursive(history, node.techProto, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (VFInput.control)
|
||||
{
|
||||
if (!VFInput.alt)
|
||||
UnlockTechRecursive(history, node.techProto, -10);
|
||||
else
|
||||
return;
|
||||
}
|
||||
else if (VFInput.alt)
|
||||
{
|
||||
UnlockTechRecursive(history, node.techProto);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
history.VerifyTechQueue();
|
||||
if (history.currentTech != history.techQueue[0])
|
||||
{
|
||||
history.currentTech = history.techQueue[0];
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(UITechNode), nameof(UITechNode.OnPointerDown))]
|
||||
private static IEnumerable<CodeInstruction> UITechNode_OnPointerDown_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(UITechNode), nameof(UITechNode.tree))),
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(UITechTree), nameof(UITechTree.selected)))
|
||||
);
|
||||
var labels = matcher.Labels;
|
||||
matcher.Labels = null;
|
||||
matcher.Insert(
|
||||
new CodeInstruction(OpCodes.Ldarg_0).WithLabels(labels),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(UnlockTech), nameof(UnlockTech.OnClickTech)))
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
using UXAssist.Common;
|
||||
|
||||
namespace CheatEnabler.Patches;
|
||||
|
||||
public static class PlanetPatch
|
||||
{
|
||||
public static ConfigEntry<bool> WaterPumpAnywhereEnabled;
|
||||
public static ConfigEntry<bool> TerraformAnywayEnabled;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
WaterPumpAnywhereEnabled.SettingChanged += (_, _) => WaterPumperPatch.Enable(WaterPumpAnywhereEnabled.Value);
|
||||
TerraformAnywayEnabled.SettingChanged += (_, _) => TerraformAnyway.Enable(TerraformAnywayEnabled.Value);
|
||||
}
|
||||
|
||||
public static void Start()
|
||||
{
|
||||
WaterPumperPatch.Enable(WaterPumpAnywhereEnabled.Value);
|
||||
TerraformAnyway.Enable(TerraformAnywayEnabled.Value);
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
WaterPumperPatch.Enable(false);
|
||||
TerraformAnyway.Enable(false);
|
||||
}
|
||||
|
||||
private class WaterPumperPatch : PatchImpl<WaterPumperPatch>
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(BuildTool_BlueprintPaste), nameof(BuildTool_BlueprintPaste.CheckBuildConditions))]
|
||||
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.CheckBuildConditions))]
|
||||
private static IEnumerable<CodeInstruction> BuildTool_CheckBuildConditions_Transpiler(
|
||||
IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(instr => instr.opcode == OpCodes.Ldc_I4_S && instr.OperandIs((int)EBuildCondition.NeedWater))
|
||||
).Advance(1).MatchForward(false,
|
||||
new CodeMatch(instr => instr.opcode == OpCodes.Ldc_I4_S && instr.OperandIs((int)EBuildCondition.NeedWater))
|
||||
);
|
||||
matcher.Repeat(codeMatcher =>
|
||||
{
|
||||
codeMatcher.SetAndAdvance(OpCodes.Ldc_I4_S, 0);
|
||||
});
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
private class TerraformAnyway : PatchImpl<TerraformAnyway>
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(BuildTool_BlueprintPaste), nameof(BuildTool_BlueprintPaste.DetermineReforms))]
|
||||
private static IEnumerable<CodeInstruction> BuildTool_BlueprintPaste_DetermineReforms_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Call, AccessTools.PropertyGetter(typeof(BuildTool), nameof(BuildTool.player))),
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Player), nameof(Player.sandCount))),
|
||||
new CodeMatch(ci => ci.IsStloc())
|
||||
).Advance(4).MatchForward(false,
|
||||
new CodeMatch(ci => ci.IsLdloc()),
|
||||
new CodeMatch(ci => ci.IsLdloc()),
|
||||
new CodeMatch(OpCodes.Conv_I8),
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Bge || ci.opcode == OpCodes.Bge_S)
|
||||
);
|
||||
var labels = matcher.Labels;
|
||||
matcher.Labels = null;
|
||||
matcher.RemoveInstructions(3);
|
||||
matcher.Labels.AddRange(labels);
|
||||
matcher.Opcode = OpCodes.Br;
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.RemoveBasePit))]
|
||||
private static IEnumerable<CodeInstruction> BuildTool_Reform_RemoveBasePit_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(BuildTool_Reform), nameof(BuildTool_Reform.circlePointCount))),
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Blt || ci.opcode == OpCodes.Blt_S)
|
||||
).RemoveInstructions(2).InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldc_I4_0)
|
||||
).MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Call, AccessTools.PropertyGetter(typeof(BuildTool), nameof(BuildTool.player))),
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Player), nameof(Player.sandCount))),
|
||||
new CodeMatch(ci => ci.IsLdloc()),
|
||||
new CodeMatch(OpCodes.Conv_I8),
|
||||
new CodeMatch(OpCodes.Sub)
|
||||
).Advance(6).InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldc_I8, 0L),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Math), nameof(Math.Max), [typeof(long), typeof(long)]))
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(UIRemoveBasePitButton), nameof(UIRemoveBasePitButton.OnRemoveButtonClick))]
|
||||
[HarmonyPatch(typeof(UIRemoveBasePitButton), nameof(UIRemoveBasePitButton._OnUpdate))]
|
||||
private static IEnumerable<CodeInstruction> UIRemoveBasePitButton_OnRemoveButtonClick_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(UIRemoveBasePitButton), nameof(UIRemoveBasePitButton.pointCount))),
|
||||
new CodeMatch(OpCodes.Sub),
|
||||
new CodeMatch(OpCodes.Ldc_I4_0),
|
||||
new CodeMatch(OpCodes.Clt)
|
||||
);
|
||||
if (matcher.IsValid)
|
||||
{
|
||||
matcher.RemoveInstructions(2).InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldc_I4_0)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
matcher.Start();
|
||||
}
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(UIRemoveBasePitButton), nameof(UIRemoveBasePitButton.player))),
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Player), nameof(Player.sandCount))),
|
||||
new CodeMatch(ci => ci.IsLdloc()),
|
||||
new CodeMatch(OpCodes.Conv_I8),
|
||||
new CodeMatch(OpCodes.Sub)
|
||||
).Advance(6).InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldc_I8, 0L),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Math), nameof(Math.Max), [typeof(long), typeof(long)]))
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.ReformAction))]
|
||||
private static IEnumerable<CodeInstruction> BuildTool_Reform_ReformAction_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(BuildTool_Reform), nameof(BuildTool_Reform.cursorPointCount))),
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Blt || ci.opcode == OpCodes.Blt_S)
|
||||
).RemoveInstructions(2).InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldc_I4_0)
|
||||
).MatchForward(false,
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Player), nameof(Player.sandCount)))
|
||||
).Advance(1).MatchForward(false,
|
||||
new CodeMatch(OpCodes.Conv_I8),
|
||||
new CodeMatch(OpCodes.Sub)
|
||||
).Advance(2).InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldc_I8, 0L),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Math), nameof(Math.Max), [typeof(long), typeof(long)]))
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
using UXAssist.Common;
|
||||
|
||||
namespace CheatEnabler.Patches;
|
||||
|
||||
public static class PlayerPatch
|
||||
{
|
||||
public static ConfigEntry<bool> InstantHandCraftEnabled;
|
||||
public static ConfigEntry<bool> InstantTeleportEnabled;
|
||||
public static ConfigEntry<bool> WarpWithoutSpaceWarpersEnabled;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
InstantHandCraftEnabled.SettingChanged += (_, _) => InstantHandCraft.Enable(InstantHandCraftEnabled.Value);
|
||||
InstantTeleportEnabled.SettingChanged += (_, _) => InstantTeleport.Enable(InstantTeleportEnabled.Value);
|
||||
WarpWithoutSpaceWarpersEnabled.SettingChanged += (_, _) => WarpWithoutSpaceWarpers.Enable(WarpWithoutSpaceWarpersEnabled.Value);
|
||||
}
|
||||
|
||||
public static void Start()
|
||||
{
|
||||
InstantHandCraft.Enable(InstantHandCraftEnabled.Value);
|
||||
InstantTeleport.Enable(InstantTeleportEnabled.Value);
|
||||
WarpWithoutSpaceWarpers.Enable(WarpWithoutSpaceWarpersEnabled.Value);
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
InstantHandCraft.Enable(false);
|
||||
InstantTeleport.Enable(false);
|
||||
WarpWithoutSpaceWarpers.Enable(false);
|
||||
}
|
||||
|
||||
private class InstantHandCraft : PatchImpl<InstantHandCraft>
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(ForgeTask), MethodType.Constructor, typeof(int), typeof(int))]
|
||||
private static void ForgeTask_Ctor_Postfix(ForgeTask __instance)
|
||||
{
|
||||
__instance.tickSpend = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private class InstantTeleport : PatchImpl<InstantTeleport>
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(UIGlobemap), nameof(UIGlobemap._OnUpdate))]
|
||||
[HarmonyPatch(typeof(UIStarmap), nameof(UIStarmap.DoRightClickFastTravel))]
|
||||
[HarmonyPatch(typeof(UIStarmap), nameof(UIStarmap.OnFastTravelButtonClick))]
|
||||
[HarmonyPatch(typeof(UIStarmap), nameof(UIStarmap.OnScreenClick))]
|
||||
[HarmonyPatch(typeof(UIStarmap), nameof(UIStarmap.SandboxRightClickFastTravelLogic))]
|
||||
[HarmonyPatch(typeof(UIStarmap), nameof(UIStarmap.StartFastTravelToPlanet))]
|
||||
[HarmonyPatch(typeof(UIStarmap), nameof(UIStarmap.StartFastTravelToUPosition))]
|
||||
[HarmonyPatch(typeof(UIStarmap), nameof(UIStarmap.UpdateCursorView))]
|
||||
[HarmonyPatch(typeof(UIStarmap), nameof(UIStarmap._OnUpdate))]
|
||||
private static IEnumerable<CodeInstruction> UIGlobemap__OnUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Call, AccessTools.PropertyGetter(typeof(GameMain), nameof(GameMain.sandboxToolsEnabled)))
|
||||
);
|
||||
matcher.Repeat(cm => cm.SetAndAdvance(OpCodes.Ldc_I4_1, null));
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
private class WarpWithoutSpaceWarpers : PatchImpl<WarpWithoutSpaceWarpers>
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(Mecha), nameof(Mecha.HasWarper))]
|
||||
private static bool Mecha_HasWarper_Prefix(ref bool __result)
|
||||
{
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(Mecha), nameof(Mecha.UseWarper))]
|
||||
private static void Mecha_UseWarper_Postfix(ref bool __result)
|
||||
{
|
||||
__result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
using UXAssist.Common;
|
||||
|
||||
namespace CheatEnabler.Patches;
|
||||
|
||||
public static class ResourcePatch
|
||||
{
|
||||
public static ConfigEntry<bool> InfiniteResourceEnabled;
|
||||
public static ConfigEntry<bool> FastMiningEnabled;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
InfiniteResourceEnabled.SettingChanged += (_, _) => InfiniteResource.Enable(InfiniteResourceEnabled.Value);
|
||||
FastMiningEnabled.SettingChanged += (_, _) => FastMining.Enable(FastMiningEnabled.Value);
|
||||
}
|
||||
|
||||
public static void Start()
|
||||
{
|
||||
InfiniteResource.Enable(InfiniteResourceEnabled.Value);
|
||||
FastMining.Enable(FastMiningEnabled.Value);
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
InfiniteResource.Enable(false);
|
||||
FastMining.Enable(false);
|
||||
}
|
||||
|
||||
private class InfiniteResource : PatchImpl<InfiniteResource>
|
||||
{
|
||||
static private readonly float InfiniteResourceRate = 0f;
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(FactorySystem), nameof(FactorySystem.GameTick), typeof(long), typeof(bool))]
|
||||
[HarmonyPatch(typeof(GameLogic), nameof(GameLogic._miner_parallel))]
|
||||
[HarmonyPatch(typeof(PlanetTransport), nameof(PlanetTransport.GameTick))]
|
||||
[HarmonyPatch(typeof(UIChartAstroResource), nameof(UIChartAstroResource.CalculateMaxAmount))]
|
||||
[HarmonyPatch(typeof(UIChartVeinGroup), nameof(UIChartVeinGroup.CalculateMaxAmount))]
|
||||
[HarmonyPatch(typeof(UIControlPanelAdvancedMinerEntry), nameof(UIControlPanelAdvancedMinerEntry._OnUpdate))]
|
||||
[HarmonyPatch(typeof(UIControlPanelVeinCollectorPanel), nameof(UIControlPanelVeinCollectorPanel._OnUpdate))]
|
||||
[HarmonyPatch(typeof(UIMinerWindow), nameof(UIMinerWindow._OnUpdate))]
|
||||
[HarmonyPatch(typeof(UIMiningUpgradeLabel), nameof(UIMiningUpgradeLabel.Update))]
|
||||
[HarmonyPatch(typeof(UIVeinCollectorPanel), nameof(UIVeinCollectorPanel._OnUpdate))]
|
||||
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(ci => (ci.opcode == OpCodes.Ldfld || ci.opcode == OpCodes.Ldflda) && ci.OperandIs(AccessTools.Field(typeof(GameHistoryData), nameof(GameHistoryData.miningCostRate))))
|
||||
).Repeat(codeMatcher =>
|
||||
{
|
||||
if (codeMatcher.Instruction.opcode == OpCodes.Ldfld)
|
||||
{
|
||||
codeMatcher.RemoveInstruction().InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Pop),
|
||||
new CodeInstruction(OpCodes.Ldc_R4, InfiniteResourceRate)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
codeMatcher.RemoveInstruction().InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Pop),
|
||||
new CodeInstruction(OpCodes.Ldsflda, AccessTools.Field(typeof(InfiniteResource), nameof(InfiniteResourceRate)))
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
private class FastMining : PatchImpl<FastMining>
|
||||
{
|
||||
static private readonly float FastMiningSpeed = 2400f;
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(AstroResourceStatPlan), nameof(AstroResourceStatPlan.AddPlanetResources))]
|
||||
[HarmonyPatch(typeof(BuildingGizmo), nameof(BuildingGizmo.Update))]
|
||||
[HarmonyPatch(typeof(FactorySystem), nameof(FactorySystem.GameTick), typeof(long), typeof(bool))]
|
||||
[HarmonyPatch(typeof(GameLogic), nameof(GameLogic._miner_parallel))]
|
||||
[HarmonyPatch(typeof(ItemProto), nameof(ItemProto.GetPropValue))]
|
||||
[HarmonyPatch(typeof(PlanetTransport), nameof(PlanetTransport.GameTick))]
|
||||
[HarmonyPatch(typeof(ProductionExtraInfoCalculator), nameof(ProductionExtraInfoCalculator.CalculateFactory))]
|
||||
[HarmonyPatch(typeof(UIChartAstroResource), nameof(UIChartAstroResource.CalculateMaxAmount))]
|
||||
[HarmonyPatch(typeof(UIChartVeinGroup), nameof(UIChartVeinGroup.CalculateMaxAmount))]
|
||||
[HarmonyPatch(typeof(UIControlPanelStationStorage), nameof(UIControlPanelStationStorage.RefreshValues))]
|
||||
[HarmonyPatch(typeof(UIControlPanelVeinCollectorPanel), nameof(UIControlPanelVeinCollectorPanel._OnUpdate))]
|
||||
[HarmonyPatch(typeof(UIMinerWindow), nameof(UIMinerWindow._OnUpdate))]
|
||||
[HarmonyPatch(typeof(UIMiningUpgradeLabel), nameof(UIMiningUpgradeLabel.Update))]
|
||||
[HarmonyPatch(typeof(UIPlanetDetail), nameof(UIPlanetDetail.OnPlanetDataSet))]
|
||||
[HarmonyPatch(typeof(UIPlanetDetail), nameof(UIPlanetDetail.RefreshDynamicProperties))]
|
||||
[HarmonyPatch(typeof(UIReferenceSpeedTip), nameof(UIReferenceSpeedTip.AddEntryDataWithFactory))]
|
||||
[HarmonyPatch(typeof(UIStarDetail), nameof(UIStarDetail.OnStarDataSet))]
|
||||
[HarmonyPatch(typeof(UIStarDetail), nameof(UIStarDetail.RefreshDynamicProperties))]
|
||||
[HarmonyPatch(typeof(UIStationStorage), nameof(UIStationStorage.RefreshValues))]
|
||||
[HarmonyPatch(typeof(UIVeinCollectorPanel), nameof(UIVeinCollectorPanel._OnUpdate))]
|
||||
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(ci => (ci.opcode == OpCodes.Ldfld || ci.opcode == OpCodes.Ldflda) && ci.OperandIs(AccessTools.Field(typeof(GameHistoryData), nameof(GameHistoryData.miningSpeedScale))))
|
||||
).Repeat(codeMatcher =>
|
||||
{
|
||||
if (codeMatcher.Instruction.opcode == OpCodes.Ldfld)
|
||||
{
|
||||
codeMatcher.RemoveInstruction().InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Pop),
|
||||
new CodeInstruction(OpCodes.Ldc_R4, FastMiningSpeed)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
codeMatcher.RemoveInstruction().InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Pop),
|
||||
new CodeInstruction(OpCodes.Ldsflda, AccessTools.Field(typeof(FastMining), nameof(FastMiningSpeed)))
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace CheatEnabler;
|
||||
public static class PlanetPatch
|
||||
{
|
||||
public static ConfigEntry<bool> WaterPumpAnywhereEnabled;
|
||||
public static ConfigEntry<bool> TerraformAnywayEnabled;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
WaterPumpAnywhereEnabled.SettingChanged += (_, _) => WaterPumperPatch.Enable(WaterPumpAnywhereEnabled.Value);
|
||||
TerraformAnywayEnabled.SettingChanged += (_, _) => TerraformAnyway.Enable(TerraformAnywayEnabled.Value);
|
||||
WaterPumperPatch.Enable(WaterPumpAnywhereEnabled.Value);
|
||||
TerraformAnyway.Enable(TerraformAnywayEnabled.Value);
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
WaterPumperPatch.Enable(false);
|
||||
TerraformAnyway.Enable(false);
|
||||
}
|
||||
|
||||
private static class WaterPumperPatch
|
||||
{
|
||||
private static Harmony _patch;
|
||||
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(WaterPumperPatch));
|
||||
}
|
||||
else
|
||||
{
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(BuildTool_BlueprintPaste), "CheckBuildConditions")]
|
||||
[HarmonyPatch(typeof(BuildTool_Click), "CheckBuildConditions")]
|
||||
private static IEnumerable<CodeInstruction> BuildTool_CheckBuildConditions_Transpiler(
|
||||
IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(instr => instr.opcode == OpCodes.Ldc_I4_S && instr.OperandIs(22))
|
||||
).Advance(1).MatchForward(false,
|
||||
new CodeMatch(instr => instr.opcode == OpCodes.Ldc_I4_S && instr.OperandIs(22))
|
||||
);
|
||||
matcher.Repeat(codeMatcher =>
|
||||
{
|
||||
codeMatcher.SetAndAdvance(OpCodes.Ldc_I4_S, 0);
|
||||
});
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
private static class TerraformAnyway
|
||||
{
|
||||
private static Harmony _patch;
|
||||
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(TerraformAnyway));
|
||||
}
|
||||
else
|
||||
{
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.ReformAction))]
|
||||
private static IEnumerable<CodeInstruction> BuildTool_Reform_ReformAction_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(Player), "get_sandCount"))
|
||||
).Advance(4).InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldc_I8, 0L),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Math), "Max", new[] { typeof(long), typeof(long) }))
|
||||
).Advance(1).RemoveInstructions(4);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
}
|
||||
+119
-204
@@ -1,236 +1,151 @@
|
||||
# CheatEnabler
|
||||
|
||||
#### Add various cheat functions while disabling abnormal determinants
|
||||
#### 添加一些作弊功能,同时屏蔽异常检测
|
||||
<details>
|
||||
<summary>Read me in English</summary>
|
||||
|
||||
## Changlog
|
||||
* 2.3.9
|
||||
+ Support game version 0.10.28.21219
|
||||
* 2.3.8
|
||||
+ Fix a crash on starting new games while `Finish build immediately` is enabled.
|
||||
+ Fix UI button width.
|
||||
* 2.3.7
|
||||
+ Support game version 0.10.28.20759
|
||||
+ Fix belt signal that items' generation speed is not fit to number set sometimes.
|
||||
* 2.3.6
|
||||
+ Support for UXAssist's new function within `Finish build immediately`.
|
||||
+ Add a warning message when `Build without condition` is enabled.
|
||||
+ Fix a issue in `Finish build immediately` that some buildings are not finished immediately.
|
||||
* 2.3.5
|
||||
+ Fix another crash in `Skip bullet period`.
|
||||
* 2.3.4
|
||||
+ Use new tab layout of UXAssist 1.0.2
|
||||
+ Minor bug fixes
|
||||
* 2.3.3
|
||||
+ Fix a crash in `Skip bullet period`.
|
||||
+ Unlock techs with Alt unlocks VeinUtil to 10000 instead of 7200 now, as bug fixed in UXAssist.
|
||||
* 2.3.2
|
||||
+ Birth star options moved to [UniverseGenTweaks](https://dsp.thunderstore.io/package/soarqin/UniverseGenTweaks/)
|
||||
+ Optimize `Quick absorb`, consumes less CPU time and take turns firing to nodes.
|
||||
+ `Fast Mining` ensures full output of oil extractors now.
|
||||
+ Fix issue that `Belt signal generator` not working after switched off then on again.
|
||||
+ Fix absorption issue by `Quick absorb` and `Skip bullet period` enabled at the same time.
|
||||
+ Crash fix for some options
|
||||
* 2.3.1
|
||||
+ Add UXAssist to dependencies in manifest.
|
||||
* 2.3.0
|
||||
+ Move some functions to an individual mod: [UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist)
|
||||
+ Depends on [UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist) now, so that config panel is unified with UXAssist.
|
||||
+ Remove `LCtrl+A` from Dev Shortcuts, to avoid misoperation.
|
||||
+ Infinite bots/drones/vessels in `Architect mode` now.
|
||||
* 2.2.7
|
||||
+ New function: `Construct only nodes but frames`
|
||||
+ Opening config panel does not close inventory panel now
|
||||
+ Remove `Input direction conflict` check while using `Remove some build conditions`
|
||||
+ Fix a bug that prevents `Belt signal alt format` from switching number formats for current belt signals
|
||||
* 2.2.6
|
||||
+ New function: `Stop ejectors when available nodes are all filled up`
|
||||
+ Fix a bug that absorb solar sails on unfinised nodes
|
||||
* 2.2.5
|
||||
+ Skip all intermediate states and absorb solar sails instantly while enable `Quick absorb`, `Skip bullet period` and `Skip absorption period` at the same time.
|
||||
+ Fix a problem that `Quick absorb` does not absorb all solar sails instantly when most nodes are full.
|
||||
+ Fix crash while using with some mods
|
||||
* 2.2.4
|
||||
+ New function: `Enable player actions in globe view`
|
||||
+ Fix UI bug
|
||||
* 2.2.3
|
||||
+ New function: `Remove some build conditions`
|
||||
+ Fix compatibility with some mods
|
||||
* 2.2.2
|
||||
+ New function: `Assign game to currrnet account`
|
||||
+ New subfunction: `Belt signal alt format`
|
||||
+ Fix a crash on using `Initialize this Planet`
|
||||
+ Fix belt build in `Finish build immediately`
|
||||
* 2.2.1
|
||||
+ Check condition for miners even when `Build without condition` is enabled.
|
||||
+ Fix a patch issue that may cause `Build without condition` not working.
|
||||
* 2.2.0
|
||||
+ Add some power related functions
|
||||
+ Add a subfunction to belt signal item generation, which simulates production process of raws and intermediates on statistics
|
||||
+ Split some functions from Architect mode
|
||||
* 2.1.0
|
||||
+ Belt signal item generation
|
||||
+ Fix window display priority which may cause tips to be covered by main window
|
||||
* 2.0.0
|
||||
+ Refactorying codes
|
||||
+ UI implementation
|
||||
+ Add a lot of functions
|
||||
* 1.0.0
|
||||
+ Initial release
|
||||
***Add various cheat functions while disabling abnormal determinants***
|
||||
|
||||
## Usage
|
||||
|
||||
* Config panel is unified with UXAssist.
|
||||
* There are also buttons on title screen and planet minimap area to call up the config panel.
|
||||
* Features:
|
||||
+ General:
|
||||
+ Enable Dev Shortcuts (check config panel for usage)
|
||||
+ Disable Abnormal Checks
|
||||
+ Unlock techs with key-modifiers (Ctrl/Alt/Shift)
|
||||
+ Assign game to currrnet account
|
||||
+ Factory:
|
||||
+ Finish build immediately
|
||||
+ Architect mode (Infinite buildings)
|
||||
+ Build without condition
|
||||
+ No collision
|
||||
+ Belt signal item generation
|
||||
- Count all raws and intermediates in statistics
|
||||
- Belt signal alt format
|
||||
+ Remove space limit between wind turbines and solar panels
|
||||
+ Boost power generations for kinds of power generators
|
||||
+ Planet:
|
||||
+ Infinite Natural Resources
|
||||
+ Fast Mining
|
||||
+ Pump Anywhere
|
||||
+ Terraform without enought sands
|
||||
+ Dyson Sphere:
|
||||
+ Skip bullet period
|
||||
+ Skip absorption period
|
||||
+ Quick absorb
|
||||
+ Eject anyway
|
||||
* General:
|
||||
* Enable Dev Shortcuts (check config panel for usage)
|
||||
* Disable Abnormal Checks
|
||||
* Unlock techs with key-modifiers (Ctrl/Alt/Shift)
|
||||
* Remove all metadata consumption records
|
||||
* Remove metadata consumption record in current game
|
||||
* Clear metadata flag which bans achievements
|
||||
* Assign gamesave to currrnet account
|
||||
* Factory:
|
||||
* Finish build immediately
|
||||
* Architect mode (Infinite buildings)
|
||||
* Build without condition
|
||||
* No collision
|
||||
* Belt signal item generation
|
||||
* Count generations as production in statistics
|
||||
* Count removals as consumption in statistics
|
||||
* Count all raws and intermediates in statistics
|
||||
* Belt signal alt format
|
||||
* Increase maximum power usage in Logistic Stations and Advanced Mining Machines
|
||||
* Logistic Stations: Increased max charging power to 3GW(ILS) and 600MW(PLS) (10x of original)
|
||||
* Advanced Mining Machines: Increased max mining speed to 1000%
|
||||
* Retrieve/Place items from/to remote planets on logistics control panel
|
||||
* Remove space limit between wind turbines and solar panels
|
||||
* Wind Turbines do global power coverage
|
||||
* Boost power generations for kinds of power generators
|
||||
* Planet:
|
||||
* Instant hand-craft
|
||||
* Infinite Natural Resources
|
||||
* Fast Mining
|
||||
* Pump Anywhere
|
||||
* Terraform without enought soil piles
|
||||
* Instant teleport (like that in Sandbox mode)
|
||||
* Dyson Sphere:
|
||||
* Skip bullet period
|
||||
* Skip absorption period
|
||||
* Quick absorb
|
||||
* Eject anyway
|
||||
* Unlock Dyson Sphere max orbit radius
|
||||
* Complete Dyson Sphere Shells instantly
|
||||
* Remove all frames on Dyson Sphere
|
||||
* Buttons for creating illegal Dyson Sphere Shells, you must enable `IllegalDysonShellFunctionsEnabled` of `DysonSphere` section in config to see the last 2 buttons.
|
||||
* Generate an illegal dyson shell
|
||||
* Keep max production shells and remove others
|
||||
* Duplicate shells from that with highest production
|
||||
* Mecha/Combat:
|
||||
* Mecha and Drones/Fleets invicible
|
||||
* Buildings invicible
|
||||
* Enable warp without space warpers
|
||||
* Teleport to outer space
|
||||
* Teleport to selected astronomical
|
||||
|
||||
## Notes
|
||||
|
||||
* Please upgrade `BepInEx` 5.4.21 or later if using with [BlueprintTweaks](https://dsp.thunderstore.io/package/kremnev8/BlueprintTweaks/) to avoid possible conflicts.
|
||||
+ You can download `BepInEx` [here](https://github.com/bepinex/bepinex/releases/latest)(choose x64 edition).
|
||||
+ If using with r2modman, you can upgrade `BepInEx` by clicking `Settings` -> `Browse profile folder`, then extract downloaded zip to the folder and overwrite existing files.
|
||||
* You can download [BepInEx here](https://github.com/bepinex/bepinex/releases/latest)(choose x64 edition).
|
||||
* If using with r2modman, you can upgrade `BepInEx` by clicking `Settings` -> `Browse profile folder`, then extract downloaded zip to the folder and overwrite existing files.
|
||||
|
||||
## CREDITS
|
||||
|
||||
* [Dyson Sphere Program](https://store.steampowered.com/app/1366540): The great game
|
||||
* [BepInEx](https://bepinex.dev/): Base modding framework
|
||||
* [Multifunction_mod](https://github.com/blacksnipebiu/Multifunction_mod): Some cheat functions
|
||||
|
||||
## 更新日志
|
||||
* 2.3.9
|
||||
+ 支持游戏版本0.10.28.21219
|
||||
* 2.3.8
|
||||
+ 修复了启用`建造秒完成`时开新游戏可能导致崩溃的问题
|
||||
+ 修复了UI按钮宽度
|
||||
* 2.3.7
|
||||
+ 支持游戏版本0.10.28.20759
|
||||
+ 修复了传送带信号有时候物品生成速度和设置不匹配的问题
|
||||
* 2.3.6
|
||||
+ 在`建造秒完成`中支持UXAssist的新功能
|
||||
+ 在启用`无条件建造`时添加警告信息
|
||||
+ 修复了`建造秒完成`可能导致部分建筑无法立即完成的问题
|
||||
* 2.3.5
|
||||
+ 修复了`跳过子弹阶段`可能导致崩溃的问题
|
||||
* 2.3.4
|
||||
+ 使用UXAssist 1.0.2的新页签布局
|
||||
+ 修复了一些小bug
|
||||
* 2.3.3
|
||||
+ 修复了`跳过子弹阶段`可能导致崩溃的问题
|
||||
+ 使用Alt解锁科技时,现在`矿物利用`的科技解锁到10000级而不是7200级,因为UXAssist已修复对应bug
|
||||
* 2.3.2
|
||||
+ 母星系的选项移动到了[UniverseGenTweaks](https://dsp.thunderstore.io/package/soarqin/UniverseGenTweaks/)
|
||||
+ 优化了`快速吸收`,现在消耗更少的CPU,并且会轮流打向各节点
|
||||
+ `高速采集`现在可以保证油井的最大产出
|
||||
+ 修复了`传送带信号物品生成`在选项关闭后再次启用时不生效的问题
|
||||
+ 修复了`快速吸收`和`跳过子弹阶段`同时启用时可能导致吸收计算错误的问题
|
||||
+ 修复了一些选项可能导致崩溃的问题
|
||||
* 2.3.1
|
||||
+ 在manifest中添加UXAssist到依赖
|
||||
* 2.3.0
|
||||
+ 将部分功能移动到单独的mod:[UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist)
|
||||
+ 现在依赖[UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist),因此配置面板与UXAssist合并
|
||||
+ 从开发模式快捷键中移除`LCtrl+A`,以避免误操作
|
||||
+ 现在`建筑师模式`中配送机/物流机/物流船也无限了
|
||||
* 2.2.7
|
||||
+ 新功能:`只建造节点不建造框架`
|
||||
+ 打开设置面板时不再关闭背包面板
|
||||
+ 在`移除部分不影响游戏逻辑的建造条件`启用时移除`输入方向冲突`的检查条件
|
||||
+ 修复导致`传送带信号替换格式`不切换传送带信号数字格式的问题
|
||||
* 2.2.6
|
||||
+ 新功能:`可用节点全部造完时停止弹射`
|
||||
+ 修复了在未完成的节点上吸收太阳帆的问题
|
||||
* 2.2.5
|
||||
+ 在同时启用`快速吸收`、`跳过子弹阶段`和`跳过吸收阶段`时,所有弹射的太阳帆会跳过所有中间环节立即吸收
|
||||
+ 修复了`快速吸收`在大部分节点已满时无法立即吸收所有太阳帆的问题
|
||||
+ 修复了与一些mod的兼容性问题
|
||||
* 2.2.4
|
||||
+ 新功能:`在行星视图中允许玩家操作`
|
||||
+ 修复了UI显示问题
|
||||
* 2.2.3
|
||||
+ 新功能:`移除部分不影响游戏逻辑的建造条件`
|
||||
+ 修复了与一些mod的兼容性问题
|
||||
* 2.2.2
|
||||
+ 新功能:`将游戏绑定给当前账号`
|
||||
+ 新子功能:`传送带信号替换格式`
|
||||
+ 修复了`初始化本行星`可能导致崩溃的问题
|
||||
+ 修复了`建造秒完成`中传送带建造的问题
|
||||
* 2.2.1
|
||||
+ 即使在启用`无条件建造`时依然检查矿机的建造条件
|
||||
+ 修复一个可能导致`无条件建造`不生效的问题
|
||||
* 2.2.0
|
||||
+ 添加了一些发电相关功能
|
||||
+ 为传送带信号物品生成添加了一个子功能,在统计面板模拟了原材料和中间产物的生产过程
|
||||
+ 从建筑师模式中分离了一些功能
|
||||
* 2.1.0
|
||||
+ 传送带信号物品生成
|
||||
+ 修复窗口显示优先级可能导致提示信息被主窗口遮挡的问题
|
||||
* 2.0.0
|
||||
+ 重构代码
|
||||
+ UI实现
|
||||
+ 添加了很多功能
|
||||
* 1.0.0
|
||||
+ 初始版本
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>中文读我</summary>
|
||||
|
||||
***添加一些作弊功能,同时屏蔽异常检测***
|
||||
|
||||
## 使用说明
|
||||
|
||||
* 配置面板复用UXAssist
|
||||
* 标题界面和行星小地图旁也有按钮呼出主面板
|
||||
* 功能:
|
||||
+ 常规:
|
||||
+ 启用开发模式快捷键(使用说明见设置面板)
|
||||
+ 屏蔽异常检测
|
||||
+ 使用组合键解锁科技(Ctrl/Alt/Shift)
|
||||
+ 将游戏绑定给当前账号
|
||||
+ 工厂:
|
||||
+ 建造秒完成
|
||||
+ 建筑师模式(无限建筑)
|
||||
+ 无条件建造
|
||||
+ 无碰撞
|
||||
+ 传送带信号物品生成
|
||||
- 统计面板中计算所有原材料和中间产物
|
||||
- 传送带信号替换格式
|
||||
+ 风力发电机和太阳能板无间距限制
|
||||
+ 提升各种发电设备发电量
|
||||
+ 行星:
|
||||
+ 自然资源采集不消耗
|
||||
+ 高速采集
|
||||
+ 平地抽水
|
||||
+ 沙土不够时依然可以整改地形
|
||||
+ 戴森球:
|
||||
+ 跳过子弹阶段
|
||||
+ 跳过吸收阶段
|
||||
+ 快速吸收
|
||||
+ 全球弹射
|
||||
* 常规:
|
||||
* 启用开发模式快捷键(使用说明见设置面板)
|
||||
* 屏蔽异常检测
|
||||
* 使用组合键解锁科技(Ctrl/Alt/Shift)
|
||||
* 移除所有元数据消耗记录
|
||||
* 移除当前存档的元数据消耗记录
|
||||
* 解除当前存档因使用元数据导致的成就限制
|
||||
* 将游戏存档绑定给当前账号
|
||||
* 工厂:
|
||||
* 建造秒完成
|
||||
* 建筑师模式(无限建筑)
|
||||
* 无条件建造
|
||||
* 无碰撞
|
||||
* 传送带信号物品生成
|
||||
* 统计信息里将生成计算为产物
|
||||
* 统计信息里将移除计算为消耗
|
||||
* 统计面板中计算所有原材料和中间产物
|
||||
* 传送带信号替换格式
|
||||
* 提升物流塔和大型采矿机的最大功耗
|
||||
* 物流塔:将最大充电功率提高到3GW(星际物流塔)和600MW(行星物流塔)(原来的10倍)
|
||||
* 大型采矿机:将最大采矿速度提高到1000%
|
||||
* 在物流总控面板上可以从非本地行星取放物品
|
||||
* 风力发电机和太阳能板无间距限制
|
||||
* 风力涡轮机供电覆盖全球
|
||||
* 提升各种发电设备发电量
|
||||
* 行星:
|
||||
* 快速手动制造
|
||||
* 自然资源采集不消耗
|
||||
* 高速采集
|
||||
* 平地抽水
|
||||
* 沙土不够时依然可以整改地形
|
||||
* 快速传送(和沙盒模式一样)
|
||||
* 戴森球:
|
||||
* 跳过子弹阶段
|
||||
* 跳过吸收阶段
|
||||
* 快速吸收
|
||||
* 全球弹射
|
||||
* 解锁戴森球最大轨道半径
|
||||
* 立即完成戴森壳建造
|
||||
* 移除戴森球上的所有框架
|
||||
* 用于制作仙术戴森壳的按钮,你必须在设置文件里开启`DysonSphere`分类的`IllegalDysonShellFunctionsEnabled`才能看到后面两个按钮
|
||||
* 生成单层仙术戴森壳
|
||||
* 保留发电量最高的戴森壳并移除其他戴森壳
|
||||
* 从发电量最高的壳复制戴森壳
|
||||
* 机甲/战斗:
|
||||
* 机甲和战斗无人机无敌
|
||||
* 建筑无敌
|
||||
* 无需空间翘曲器即可曲速飞行
|
||||
* 传送到外太空
|
||||
* 传送到选定的天体
|
||||
|
||||
## 注意事项
|
||||
|
||||
* 如果和[BlueprintTweaks](https://dsp.thunderstore.io/package/kremnev8/BlueprintTweaks/)一起使用,请升级`BepInEx`到5.4.21或更高版本,以避免可能的冲突
|
||||
+ 你可以在[这里](https://github.com/bepinex/bepinex/releases/latest)(选择x64版本)下载`BepInEx`
|
||||
+ 如果使用r2modman,你可以点击`Settings` -> `Browse profile folder`,然后将下载的zip解压到该文件夹并覆盖现有文件
|
||||
* 你可以在[这里](https://github.com/bepinex/bepinex/releases/latest)(选择x64版本)下载`BepInEx`
|
||||
* 如果使用r2modman,你可以点击`Settings` -> `Browse profile folder`,然后将下载的zip解压到该文件夹并覆盖现有文件
|
||||
|
||||
## 鸣谢
|
||||
|
||||
* [戴森球计划](https://store.steampowered.com/app/1366540): 伟大的游戏
|
||||
* [BepInEx](https://bepinex.dev/): 基础模组框架
|
||||
* [Multifunction_mod](https://github.com/blacksnipebiu/Multifunction_mod): 一些作弊功能
|
||||
|
||||
</details>
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace CheatEnabler;
|
||||
|
||||
public static class ResourcePatch
|
||||
{
|
||||
public static ConfigEntry<bool> InfiniteResourceEnabled;
|
||||
public static ConfigEntry<bool> FastMiningEnabled;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
InfiniteResourceEnabled.SettingChanged += (_, _) => InfiniteResource.Enable(InfiniteResourceEnabled.Value);
|
||||
FastMiningEnabled.SettingChanged += (_, _) => FastMining.Enable(FastMiningEnabled.Value);
|
||||
InfiniteResource.Enable(InfiniteResourceEnabled.Value);
|
||||
FastMining.Enable(FastMiningEnabled.Value);
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
InfiniteResource.Enable(false);
|
||||
FastMining.Enable(false);
|
||||
}
|
||||
|
||||
private static class InfiniteResource
|
||||
{
|
||||
private static Harmony _patch;
|
||||
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(InfiniteResource));
|
||||
}
|
||||
else
|
||||
{
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(FactorySystem), "GameTick", typeof(long), typeof(bool))]
|
||||
[HarmonyPatch(typeof(FactorySystem), "GameTick", typeof(long), typeof(bool), typeof(int), typeof(int), typeof(int))]
|
||||
[HarmonyPatch(typeof(ItemProto), "GetPropValue")]
|
||||
[HarmonyPatch(typeof(PlanetTransport), "GameTick")]
|
||||
[HarmonyPatch(typeof(UIMinerWindow), "_OnUpdate")]
|
||||
[HarmonyPatch(typeof(UIMiningUpgradeLabel), "Update")]
|
||||
[HarmonyPatch(typeof(UIPlanetDetail), "OnPlanetDataSet")]
|
||||
[HarmonyPatch(typeof(UIPlanetDetail), "RefreshDynamicProperties")]
|
||||
[HarmonyPatch(typeof(UIStarDetail), "OnStarDataSet")]
|
||||
[HarmonyPatch(typeof(UIStarDetail), "RefreshDynamicProperties")]
|
||||
[HarmonyPatch(typeof(UIStationStorage), "RefreshValues")]
|
||||
[HarmonyPatch(typeof(UIVeinCollectorPanel), "_OnUpdate")]
|
||||
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(GameHistoryData), nameof(GameHistoryData.miningCostRate)))
|
||||
).Repeat(codeMatcher =>
|
||||
codeMatcher.RemoveInstruction().InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Pop),
|
||||
new CodeInstruction(OpCodes.Ldc_R4, 0f)
|
||||
)
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
private static class FastMining
|
||||
{
|
||||
private static Harmony _patch;
|
||||
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(FastMining));
|
||||
}
|
||||
else
|
||||
{
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(FactorySystem), "GameTick", typeof(long), typeof(bool))]
|
||||
[HarmonyPatch(typeof(FactorySystem), "GameTick", typeof(long), typeof(bool), typeof(int), typeof(int), typeof(int))]
|
||||
[HarmonyPatch(typeof(ItemProto), "GetPropValue")]
|
||||
[HarmonyPatch(typeof(PlanetTransport), "GameTick")]
|
||||
[HarmonyPatch(typeof(UIMinerWindow), "_OnUpdate")]
|
||||
[HarmonyPatch(typeof(UIMiningUpgradeLabel), "Update")]
|
||||
[HarmonyPatch(typeof(UIPlanetDetail), "OnPlanetDataSet")]
|
||||
[HarmonyPatch(typeof(UIPlanetDetail), "RefreshDynamicProperties")]
|
||||
[HarmonyPatch(typeof(UIStarDetail), "OnStarDataSet")]
|
||||
[HarmonyPatch(typeof(UIStarDetail), "RefreshDynamicProperties")]
|
||||
[HarmonyPatch(typeof(UIStationStorage), "RefreshValues")]
|
||||
[HarmonyPatch(typeof(UIVeinCollectorPanel), "_OnUpdate")]
|
||||
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(GameHistoryData), nameof(GameHistoryData.miningSpeedScale)))
|
||||
).Repeat(codeMatcher =>
|
||||
codeMatcher.RemoveInstruction().InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Pop),
|
||||
new CodeInstruction(OpCodes.Ldc_R4, 2400f)
|
||||
)
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace CheatEnabler;
|
||||
|
||||
public static class TechPatch
|
||||
{
|
||||
public static ConfigEntry<bool> Enabled;
|
||||
private static Harmony _patch;
|
||||
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
Enabled.SettingChanged += (_, _) => ValueChanged();
|
||||
ValueChanged();
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
|
||||
private static void ValueChanged()
|
||||
{
|
||||
if (Enabled.Value)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(TechPatch));
|
||||
}
|
||||
else
|
||||
{
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void UnlockTechRecursive([NotNull] TechProto techProto, int maxLevel = 10000)
|
||||
{
|
||||
var history = GameMain.history;
|
||||
var techStates = history.techStates;
|
||||
var techID = techProto.ID;
|
||||
if (techStates == null || !techStates.ContainsKey(techID))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var value = techStates[techID];
|
||||
if (value.unlocked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var maxLvl = Math.Min(maxLevel < 0 ? value.curLevel - maxLevel - 1 : maxLevel, value.maxLevel);
|
||||
|
||||
foreach (var preid in techProto.PreTechs)
|
||||
{
|
||||
var preProto = LDB.techs.Select(preid);
|
||||
if (preProto != null)
|
||||
UnlockTechRecursive(preProto, maxLevel);
|
||||
}
|
||||
|
||||
var techQueue = history.techQueue;
|
||||
if (techQueue != null)
|
||||
{
|
||||
for (var i = 0; i < techQueue.Length; i++)
|
||||
{
|
||||
if (techQueue[i] == techID)
|
||||
{
|
||||
techQueue[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (value.curLevel < techProto.Level) value.curLevel = techProto.Level;
|
||||
while (value.curLevel <= maxLvl)
|
||||
{
|
||||
if (value.curLevel == 0)
|
||||
{
|
||||
foreach (var recipe in techProto.UnlockRecipes)
|
||||
{
|
||||
history.UnlockRecipe(recipe);
|
||||
}
|
||||
}
|
||||
for (var j = 0; j < techProto.UnlockFunctions.Length; j++)
|
||||
{
|
||||
history.UnlockTechFunction(techProto.UnlockFunctions[j], techProto.UnlockValues[j], value.curLevel);
|
||||
}
|
||||
for (var k = 0; k < techProto.AddItems.Length; k++)
|
||||
{
|
||||
history.GainTechAwards(techProto.AddItems[k], techProto.AddItemCounts[k]);
|
||||
}
|
||||
value.curLevel++;
|
||||
}
|
||||
|
||||
value.unlocked = maxLvl >= value.maxLevel;
|
||||
value.curLevel = value.unlocked ? maxLvl : maxLvl + 1;
|
||||
value.hashNeeded = techProto.GetHashNeeded(value.curLevel);
|
||||
value.hashUploaded = value.unlocked ? value.hashNeeded : 0;
|
||||
techStates[techID] = value;
|
||||
history.RegFeatureKey(1000100);
|
||||
history.NotifyTechUnlock(techID, maxLvl, true);
|
||||
}
|
||||
|
||||
private static void OnClickTech(UITechNode node)
|
||||
{
|
||||
if (VFInput.shift)
|
||||
{
|
||||
if (VFInput.alt) return;
|
||||
if (VFInput.control)
|
||||
UnlockTechRecursive(node.techProto, -100);
|
||||
else
|
||||
UnlockTechRecursive(node.techProto, -1);
|
||||
return;
|
||||
}
|
||||
if (VFInput.control)
|
||||
{
|
||||
if (!VFInput.alt)
|
||||
UnlockTechRecursive(node.techProto, -10);
|
||||
}
|
||||
else if (VFInput.alt)
|
||||
{
|
||||
UnlockTechRecursive(node.techProto);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(UITechNode), nameof(UITechNode.OnPointerDown))]
|
||||
private static IEnumerable<CodeInstruction> UITechNode_OnPointerDown_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(UITechNode), nameof(UITechNode.tree))),
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(UITechTree), "get_selected"))
|
||||
);
|
||||
var labels = matcher.Labels;
|
||||
matcher.Labels = null;
|
||||
matcher.Insert(
|
||||
new CodeInstruction(OpCodes.Ldarg_0).WithLabels(labels),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(TechPatch), nameof(TechPatch.OnClickTech)))
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
}
|
||||
+258
-59
@@ -1,6 +1,9 @@
|
||||
using UnityEngine;
|
||||
using CheatEnabler.Functions;
|
||||
using CheatEnabler.Patches;
|
||||
using UnityEngine;
|
||||
using UXAssist.UI;
|
||||
using UXAssist.Common;
|
||||
using System;
|
||||
|
||||
namespace CheatEnabler;
|
||||
|
||||
@@ -9,11 +12,13 @@ public static class UIConfigWindow
|
||||
private static RectTransform _windowTrans;
|
||||
|
||||
private static UIButton _resignGameBtn;
|
||||
private static UIButton _clearBanBtn;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
I18N.Add("Factory", "Factory", "工厂");
|
||||
I18N.Add("Planet", "Planet", "行星");
|
||||
I18N.Add("Mecha/Combat", "Mecha/Combat", "机甲/战斗");
|
||||
I18N.Add("Enable Dev Shortcuts", "Enable Dev Shortcuts", "开发模式快捷键");
|
||||
I18N.Add("Disable Abnormal Checks", "Disable Abnormal Checks", "关闭数据异常检查");
|
||||
I18N.Add("Hotkey", "Hotkey", "快捷键");
|
||||
@@ -25,39 +30,116 @@ public static class UIConfigWindow
|
||||
I18N.Add("Unlock Tech with Key-Modifiers Tips",
|
||||
"Click tech on tree while holding:\n Shift: Tech level + 1\n Ctrl: Tech level + 10\n Ctrl + Shift: Tech level + 100\n Alt: Tech level to MAX\n\nNote: all direct prerequisites will be unlocked as well.",
|
||||
"按住以下组合键点击科技树:\n Shift:科技等级+1\n Ctrl:科技等级+10\n Ctrl+Shift:科技等级+100\n Alt:科技等级升到最大\n\n注意:所有直接前置科技也会被解锁");
|
||||
I18N.Add("Assign game to current account", "Assign game to current account", "将游戏绑定给当前账号");
|
||||
I18N.Add("Remove all metadata consumption records", "Remove all metadata consumption records", "移除所有元数据消耗记录");
|
||||
I18N.Add("Remove metadata consumption record in current game", "Remove metadata consumption record in current game", "移除当前存档的元数据消耗记录");
|
||||
I18N.Add("Clear metadata flag which bans achievements", "Clear metadata flag which bans achievements in current game", "解除当前存档因使用元数据导致的成就限制");
|
||||
I18N.Add("Assign gamesave to current account", "Assign gamesave to current account", "将游戏存档绑定给当前账号");
|
||||
I18N.Add("Finish build immediately", "Finish build immediately", "建造秒完成");
|
||||
I18N.Add("Architect mode", "Architect mode", "建筑师模式");
|
||||
I18N.Add("Build without condition", "Build without condition check", "无条件建造");
|
||||
I18N.Add("Build without condition is enabled!", "!!Build without condition is enabled!!", "!!无条件建造已开启!!");
|
||||
I18N.Add("No collision", "No collision", "无碰撞");
|
||||
I18N.Add("Belt signal generator", "Belt signal generator", "传送带信号物品生成");
|
||||
I18N.Add("Belt signal alt format", "Belt signal alt format", "传送带信号替换格式");
|
||||
I18N.Add("Belt signal alt format tips",
|
||||
"Belt signal number format alternative format:\n AAAABC by default\n BCAAAA as alternative\nAAAA=generation speed in minutes, B=proliferate points, C=stack count",
|
||||
"传送带信号物品生成数量格式:\n 默认为AAAABC\n 勾选替换为BCAAAA\nAAAA=生成速度,B=增产点数,C=堆叠数量");
|
||||
I18N.Add("Count all raws and intermediates in statistics","Count all raw materials in statistics", "统计信息里计算所有原料和中间产物");
|
||||
I18N.Add("Count generations as production in statistics", "Count generations as production in statistics", "统计信息里将生成计算为产物");
|
||||
I18N.Add("Count removals as consumption in statistics", "Count removals as consumption in statistics", "统计信息里将移除计算为消耗");
|
||||
I18N.Add("Count all raws and intermediates in statistics", "Count all raw materials in statistics", "统计信息里计算所有原料和中间产物");
|
||||
I18N.Add("Remove power space limit", "Remove space limit for winds and geothermals", "移除风力发电和地热发电的间距限制");
|
||||
I18N.Add("Boost wind power", "Boost wind power(x100,000)", "提升风力发电(x100,000)");
|
||||
I18N.Add("Boost solar power", "Boost solar power(x100,000)", "提升太阳能发电(x100,000)");
|
||||
I18N.Add("Boost fuel power", "Boost fuel power(x50,000)", "提升燃料发电(x50,000)");
|
||||
I18N.Add("Boost fuel power 2", "(x20,000 for deuteron, x10,000 for antimatter)", "(氘核燃料棒x20,000,反物质燃料棒x10,000)");
|
||||
I18N.Add("Wind Turbines do global power coverage", "Wind Turbines do global power coverage", "风力涡轮机供电覆盖全球");
|
||||
I18N.Add("Boost geothermal power", "Boost geothermal power(x50,000)", "提升地热发电(x50,000)");
|
||||
I18N.Add("Increase maximum power usage in Logistic Stations and Advanced Mining Machines", "Increase maximum power usage in Logistic Stations and Advanced Mining Machines",
|
||||
"提升物流塔和大型采矿机的最大功耗");
|
||||
I18N.Add("Retrieve/Place items from/to remote planets on logistics control panel", "Retrieve/Place items from/to remote planets on logistics control panel", "在物流总控面板上可以从非本地行星取放物品");
|
||||
I18N.Add("Infinite Natural Resources", "Infinite natural resources", "自然资源采集不消耗");
|
||||
I18N.Add("Fast Mining", "Fast mining", "高速采集");
|
||||
I18N.Add("Pump Anywhere", "Pump anywhere", "平地抽水");
|
||||
I18N.Add("Skip bullet period", "Skip bullet period", "跳过子弹阶段");
|
||||
I18N.Add("Fire all bullets at once", "Fire all bullets at once", "一次弹射所有太阳帆");
|
||||
I18N.Add("Skip absorption period", "Skip absorption period", "跳过吸收阶段");
|
||||
I18N.Add("Quick absorb", "Quick absorb", "快速吸收");
|
||||
I18N.Add("Eject anyway", "Eject anyway", "全球弹射");
|
||||
I18N.Add("Overclock Ejectors", "Overclock Ejectors (10x)", "高速弹射器(10倍射速)");
|
||||
I18N.Add("Overclock Silos", "Overclock Silos (10x)", "高速发射井(10倍射速)");
|
||||
I18N.Add("Terraform without enough sands", "Terraform without enough sands", "沙土不够时依然可以整改地形");
|
||||
I18N.Add("Unlock Dyson Sphere max orbit radius", "Unlock Dyson Sphere max orbit radius", "解锁戴森球最大轨道半径");
|
||||
I18N.Add("Complete Dyson Sphere shells instantly", "Complete Dyson Sphere shells instantly", "立即完成戴森壳建造");
|
||||
I18N.Add("Remove all frames on Dyson Sphere", "Remove all frames on Dyson Sphere", "移除戴森球上的所有框架");
|
||||
I18N.Add("Generate illegal dyson shell", "Generate an illegal dyson shell (!!1st shell layer will be replaced!!)", "生成单层仙术戴森壳(!!会先删除第一层戴森壳!!)");
|
||||
I18N.Add("Keep max production shells and remove others", "Keep max production shells and remove others", "保留发电量最高的戴森壳并移除其他戴森壳");
|
||||
I18N.Add("Duplicate shells from that with highest production", "Duplicate shells from that with highest production", "从发电量最高的壳复制戴森壳");
|
||||
I18N.Add("Generate illegal dyson shell quickly", "Generate illegal dyson shell quickly", "快速生成仙术戴森壳");
|
||||
I18N.Add("Shells count", "Shells count", "壳面数量");
|
||||
I18N.Add("WARNING: This operation can be very slow, continue?", "WARNING: This operation can be very slow, continue?", "警告:此操作可能非常慢,继续吗?");
|
||||
I18N.Add("WARNING: This operation is DANGEROUS, continue?", "WARNING: This operation is DANGEROUS, continue?", "警告:此操作非常危险,继续吗?");
|
||||
I18N.Add("Terraform without enough soil piles", "Terraform without enough soil piles", "沙土不够时依然可以整改地形");
|
||||
I18N.Add("Instant hand-craft", "Instant hand-craft", "快速手动制造");
|
||||
I18N.Add("Instant teleport (like that in Sandbox mode)", "Instant teleport (like that in Sandbox mode)", "快速传送(和沙盒模式一样)");
|
||||
I18N.Add("Mecha and Drones/Fleets invicible", "Mecha and Drones/Fleets invicible", "机甲和战斗无人机无敌");
|
||||
I18N.Add("Buildings invicible", "Buildings invincible", "建筑无敌");
|
||||
I18N.Add("Enable warp without space warpers", "Enable warp without space warpers", "无需空间翘曲器即可曲速飞行");
|
||||
I18N.Add("Teleport to outer space", "Teleport to outer space", "传送到外太空");
|
||||
I18N.Add("Teleport to selected astronomical", "Teleport to selected astronomical", "传送到选中的天体");
|
||||
I18N.Apply();
|
||||
MyConfigWindow.OnUICreated += CreateUI;
|
||||
MyConfigWindow.OnUpdateUI += UpdateUI;
|
||||
}
|
||||
|
||||
class MaxOrbitRadiusValueMapper : MyWindow.RangeValueMapper<float>
|
||||
{
|
||||
public MaxOrbitRadiusValueMapper() : base(1, 20)
|
||||
{
|
||||
}
|
||||
|
||||
public override int ValueToIndex(float value)
|
||||
{
|
||||
int result = Mathf.FloorToInt(value / 500_000f);
|
||||
if (result < 1) result = 1;
|
||||
if (result > 20) result = 20;
|
||||
return result;
|
||||
}
|
||||
|
||||
public override float IndexToValue(int index)
|
||||
{
|
||||
return index * 500_000f;
|
||||
}
|
||||
}
|
||||
|
||||
class ShellsCountMapper : MyWindow.RangeValueMapper<int>
|
||||
{
|
||||
public ShellsCountMapper() : base(1, 139)
|
||||
{
|
||||
}
|
||||
|
||||
public override int ValueToIndex(int value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
< 4 => value,
|
||||
< 64 => value / 4 + 3,
|
||||
< 256 => value / 16 + 15,
|
||||
< 4096 => value / 64 + 27,
|
||||
_ => value / 256 + 75,
|
||||
};
|
||||
}
|
||||
|
||||
public override int IndexToValue(int index)
|
||||
{
|
||||
return index switch
|
||||
{
|
||||
< 4 => index,
|
||||
< 19 => (index - 3) * 4,
|
||||
< 31 => (index - 15) * 16,
|
||||
< 91 => (index - 27) * 64,
|
||||
_ => (index - 75) * 256,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static void CreateUI(MyConfigWindow wnd, RectTransform trans)
|
||||
{
|
||||
_windowTrans = trans;
|
||||
@@ -67,73 +149,103 @@ public static class UIConfigWindow
|
||||
wnd.AddSplitter(trans, 10f);
|
||||
wnd.AddTabGroup(trans, "Cheat Enabler", "tab-group-cheatenabler");
|
||||
var tab1 = wnd.AddTab(_windowTrans, "General");
|
||||
MyCheckBox.CreateCheckBox(x, y, tab1, DevShortcuts.Enabled, "Enable Dev Shortcuts");
|
||||
var cb = wnd.AddCheckBox(x, y, tab1, GamePatch.DevShortcutsEnabled, "Enable Dev Shortcuts");
|
||||
x += cb.Width + 5f;
|
||||
y += 6f;
|
||||
wnd.AddTipsButton2(x, y, tab1, "Dev Shortcuts", "Dev Shortcuts Tips", "dev-shortcuts-tips");
|
||||
x = 0;
|
||||
y += 30f;
|
||||
wnd.AddCheckBox(x, y, tab1, GamePatch.AbnormalDisablerEnabled, "Disable Abnormal Checks");
|
||||
y += 36f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab1, AbnormalDisabler.Enabled, "Disable Abnormal Checks");
|
||||
cb = wnd.AddCheckBox(x, y, tab1, GamePatch.UnlockTechEnabled, "Unlock Tech with Key-Modifiers");
|
||||
x += cb.Width + 5f;
|
||||
y += 6f;
|
||||
wnd.AddTipsButton2(x, y, tab1, "Unlock Tech with Key-Modifiers", "Unlock Tech with Key-Modifiers Tips", "unlock-tech-tips");
|
||||
x = 0f;
|
||||
y += 30f + 36f;
|
||||
wnd.AddButton(x, y, 400f, tab1, "Remove all metadata consumption records", 16, "button-remove-all-metadata-consumption", PlayerFunctions.RemoveAllMetadataConsumptions);
|
||||
y += 36f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab1, TechPatch.Enabled, "Unlock Tech with Key-Modifiers");
|
||||
x = 156f;
|
||||
y = 16f;
|
||||
MyWindow.AddTipsButton(x, y, tab1, "Dev Shortcuts", "Dev Shortcuts Tips", "dev-shortcuts-tips");
|
||||
x += 52f;
|
||||
y += 72f;
|
||||
MyWindow.AddTipsButton(x, y, tab1, "Unlock Tech with Key-Modifiers", "Unlock Tech with Key-Modifiers Tips", "unlock-tech-tips");
|
||||
wnd.AddButton(x, y, 400f, tab1, "Remove metadata consumption record in current game", 16, "button-remove-current-metadata-consumption", PlayerFunctions.RemoveCurrentMetadataConsumptions);
|
||||
y += 36f;
|
||||
_clearBanBtn = wnd.AddButton(x, y, 400f, tab1, "Clear metadata flag which bans achievements", 16, "button-clear-ban-list", PlayerFunctions.ClearMetadataBanAchievements);
|
||||
x = 300f;
|
||||
y = 10f;
|
||||
_resignGameBtn = wnd.AddButton(x, y, 200f, tab1, "Assign game to current account", 16, "resign-game-btn", () => { GameMain.data.account = AccountData.me; });
|
||||
_resignGameBtn = wnd.AddButton(x, y, 300f, tab1, "Assign gamesave to current account", 16, "resign-game-btn", () => { GameMain.data.account = AccountData.me; });
|
||||
|
||||
var tab2 = wnd.AddTab(_windowTrans, "Factory");
|
||||
x = 0f;
|
||||
y = 10f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.ImmediateEnabled, "Finish build immediately");
|
||||
wnd.AddCheckBox(x, y, tab2, FactoryPatch.ImmediateEnabled, "Finish build immediately");
|
||||
y += 36f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.ArchitectModeEnabled, "Architect mode");
|
||||
wnd.AddCheckBox(x, y, tab2, FactoryPatch.ArchitectModeEnabled, "Architect mode");
|
||||
y += 36f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.NoConditionEnabled, "Build without condition");
|
||||
wnd.AddCheckBox(x, y, tab2, FactoryPatch.NoConditionEnabled, "Build without condition");
|
||||
y += 36f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.NoCollisionEnabled, "No collision");
|
||||
wnd.AddCheckBox(x, y, tab2, FactoryPatch.NoCollisionEnabled, "No collision");
|
||||
y += 36f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.BeltSignalGeneratorEnabled, "Belt signal generator");
|
||||
y += 26f;
|
||||
wnd.AddCheckBox(x, y, tab2, FactoryPatch.BeltSignalGeneratorEnabled, "Belt signal generator");
|
||||
x += 26f;
|
||||
var cb = MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.BeltSignalCountRecipeEnabled, "Count all raws and intermediates in statistics", 13);
|
||||
y += 26f;
|
||||
var cb2 = MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.BeltSignalNumberAltFormat, "Belt signal alt format", 13);
|
||||
x += 180f;
|
||||
var cb1 = wnd.AddCheckBox(x, y, tab2, FactoryPatch.BeltSignalCountGenEnabled, "Count generations as production in statistics", 13);
|
||||
y += 26f;
|
||||
var cb2 = wnd.AddCheckBox(x, y, tab2, FactoryPatch.BeltSignalCountRemEnabled, "Count removals as consumption in statistics", 13);
|
||||
y += 26f;
|
||||
var cb3 = wnd.AddCheckBox(x, y, tab2, FactoryPatch.BeltSignalCountRecipeEnabled, "Count all raws and intermediates in statistics", 13);
|
||||
y += 26f;
|
||||
var cb4 = wnd.AddCheckBox(x, y, tab2, FactoryPatch.BeltSignalNumberAltFormat, "Belt signal alt format", 13);
|
||||
x += cb4.Width + 5f;
|
||||
y += 6f;
|
||||
var tip1 = MyWindow.AddTipsButton(x, y, tab2, "Belt signal alt format", "Belt signal alt format tips", "belt-signal-alt-format-tips");
|
||||
|
||||
FactoryPatch.BeltSignalGeneratorEnabled.SettingChanged += (_, _) =>
|
||||
var tip1 = wnd.AddTipsButton2(x, y, tab2, "Belt signal alt format", "Belt signal alt format tips", "belt-signal-alt-format-tips");
|
||||
x = 0f;
|
||||
y += 30f;
|
||||
wnd.AddCheckBox(x, y, tab2, FactoryPatch.GreaterPowerUsageInLogisticsEnabled, "Increase maximum power usage in Logistic Stations and Advanced Mining Machines");
|
||||
y += 36f;
|
||||
wnd.AddCheckBox(x, y, tab2, FactoryPatch.ControlPanelRemoteLogisticsEnabled, "Retrieve/Place items from/to remote planets on logistics control panel");
|
||||
{
|
||||
OnBeltSignalChanged();
|
||||
};
|
||||
OnBeltSignalChanged();
|
||||
FactoryPatch.BeltSignalGeneratorEnabled.SettingChanged += OnBeltSignalChanged;
|
||||
wnd.OnFree += () => { FactoryPatch.BeltSignalGeneratorEnabled.SettingChanged -= OnBeltSignalChanged; };
|
||||
OnBeltSignalChanged(null, null);
|
||||
void OnBeltSignalChanged(object o, EventArgs e)
|
||||
{
|
||||
var on = FactoryPatch.BeltSignalGeneratorEnabled.Value;
|
||||
cb1.gameObject.SetActive(on);
|
||||
cb2.gameObject.SetActive(on);
|
||||
cb3.gameObject.SetActive(on);
|
||||
cb4.gameObject.SetActive(on);
|
||||
tip1.gameObject.SetActive(on);
|
||||
}
|
||||
}
|
||||
x = 350f;
|
||||
y = 10f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.RemovePowerSpaceLimitEnabled, "Remove power space limit");
|
||||
wnd.AddCheckBox(x, y, tab2, FactoryPatch.RemovePowerSpaceLimitEnabled, "Remove power space limit");
|
||||
y += 36f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.BoostWindPowerEnabled, "Boost wind power");
|
||||
wnd.AddCheckBox(x, y, tab2, FactoryPatch.WindTurbinesPowerGlobalCoverageEnabled, "Wind Turbines do global power coverage");
|
||||
y += 36f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.BoostSolarPowerEnabled, "Boost solar power");
|
||||
wnd.AddCheckBox(x, y, tab2, FactoryPatch.BoostWindPowerEnabled, "Boost wind power");
|
||||
y += 36f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.BoostGeothermalPowerEnabled, "Boost geothermal power");
|
||||
wnd.AddCheckBox(x, y, tab2, FactoryPatch.BoostSolarPowerEnabled, "Boost solar power");
|
||||
y += 36f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.BoostFuelPowerEnabled, "Boost fuel power");
|
||||
x += 32f;
|
||||
wnd.AddCheckBox(x, y, tab2, FactoryPatch.BoostGeothermalPowerEnabled, "Boost geothermal power");
|
||||
y += 36f;
|
||||
wnd.AddCheckBox(x, y, tab2, FactoryPatch.BoostFuelPowerEnabled, "Boost fuel power");
|
||||
y += 26f;
|
||||
MyWindow.AddText(x, y, tab2, "Boost fuel power 2", 13);
|
||||
wnd.AddText2(x + 32f, y, tab2, "Boost fuel power 2", 13);
|
||||
|
||||
// Planet Tab
|
||||
var tab3 = wnd.AddTab(_windowTrans, "Planet");
|
||||
x = 0f;
|
||||
y = 10f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab3, ResourcePatch.InfiniteResourceEnabled, "Infinite Natural Resources");
|
||||
wnd.AddCheckBox(x, y, tab3, ResourcePatch.InfiniteResourceEnabled, "Infinite Natural Resources");
|
||||
y += 36f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab3, ResourcePatch.FastMiningEnabled, "Fast Mining");
|
||||
wnd.AddCheckBox(x, y, tab3, ResourcePatch.FastMiningEnabled, "Fast Mining");
|
||||
y += 36f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab3, PlanetPatch.WaterPumpAnywhereEnabled, "Pump Anywhere");
|
||||
wnd.AddCheckBox(x, y, tab3, PlanetPatch.WaterPumpAnywhereEnabled, "Pump Anywhere");
|
||||
y += 36f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab3, PlanetPatch.TerraformAnywayEnabled, "Terraform without enough sands");
|
||||
wnd.AddCheckBox(x, y, tab3, PlanetPatch.TerraformAnywayEnabled, "Terraform without enough soil piles");
|
||||
y += 36f;
|
||||
wnd.AddCheckBox(x, y, tab3, PlayerPatch.InstantHandCraftEnabled, "Instant hand-craft");
|
||||
y += 36f;
|
||||
wnd.AddCheckBox(x, y, tab3, PlayerPatch.InstantTeleportEnabled, "Instant teleport (like that in Sandbox mode)");
|
||||
x = 400f;
|
||||
y = 10f;
|
||||
wnd.AddButton(x, y, 200f, tab3, "矿物掩埋标题", 16, "button-bury-all", () => { PlanetFunctions.BuryAllVeins(true); });
|
||||
@@ -160,37 +272,124 @@ public static class UIConfigWindow
|
||||
var tab4 = wnd.AddTab(_windowTrans, "Dyson Sphere");
|
||||
x = 0f;
|
||||
y = 10f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.SkipBulletEnabled, "Skip bullet period");
|
||||
wnd.AddCheckBox(x, y, tab4, DysonSpherePatch.SkipBulletEnabled, "Skip bullet period");
|
||||
y += 26f;
|
||||
wnd.AddCheckBox(x + 26f, y, tab4, DysonSpherePatch.FireAllBulletsEnabled, "Fire all bullets at once", 13);
|
||||
y += 36f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.SkipAbsorbEnabled, "Skip absorption period");
|
||||
wnd.AddCheckBox(x, y, tab4, DysonSpherePatch.SkipAbsorbEnabled, "Skip absorption period");
|
||||
y += 36f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.QuickAbsorbEnabled, "Quick absorb");
|
||||
wnd.AddCheckBox(x, y, tab4, DysonSpherePatch.QuickAbsorbEnabled, "Quick absorb");
|
||||
y += 36f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.EjectAnywayEnabled, "Eject anyway");
|
||||
wnd.AddCheckBox(x, y, tab4, DysonSpherePatch.EjectAnywayEnabled, "Eject anyway");
|
||||
y += 36f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.OverclockEjectorEnabled, "Overclock Ejectors");
|
||||
wnd.AddCheckBox(x, y, tab4, DysonSpherePatch.OverclockEjectorEnabled, "Overclock Ejectors");
|
||||
y += 36f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.OverclockSiloEnabled, "Overclock Silos");
|
||||
return;
|
||||
|
||||
void OnBeltSignalChanged()
|
||||
wnd.AddCheckBox(x, y, tab4, DysonSpherePatch.OverclockSiloEnabled, "Overclock Silos");
|
||||
y += 36f;
|
||||
wnd.AddCheckBox(x, y, tab4, DysonSpherePatch.UnlockMaxOrbitRadiusEnabled, "Unlock Dyson Sphere max orbit radius");
|
||||
y += 30f;
|
||||
{
|
||||
var on = FactoryPatch.BeltSignalGeneratorEnabled.Value;
|
||||
cb.gameObject.SetActive(on);
|
||||
cb2.gameObject.SetActive(on);
|
||||
tip1.gameObject.SetActive(on);
|
||||
var slider = wnd.AddSlider(x + 20, y, tab4, DysonSpherePatch.UnlockMaxOrbitRadiusValue, new MaxOrbitRadiusValueMapper(), "##,#m").WithSmallerHandle(-40f);
|
||||
DysonSpherePatch.UnlockMaxOrbitRadiusEnabled.SettingChanged += UnlockMaxOrbitRadiusChanged;
|
||||
wnd.OnFree += () => { DysonSpherePatch.UnlockMaxOrbitRadiusEnabled.SettingChanged -= UnlockMaxOrbitRadiusChanged; };
|
||||
UnlockMaxOrbitRadiusChanged(null, null);
|
||||
|
||||
void UnlockMaxOrbitRadiusChanged(object o, EventArgs e)
|
||||
{
|
||||
slider.slider.enabled = DysonSpherePatch.UnlockMaxOrbitRadiusEnabled.Value;
|
||||
}
|
||||
}
|
||||
x = 300f;
|
||||
y = 10f;
|
||||
wnd.AddButton(x, y, 300f, tab4, "Complete Dyson Sphere shells instantly", 16, "button-complete-dyson-sphere-shells-instantly", DysonSphereFunctions.CompleteShellsInstantly);
|
||||
y += 36f;
|
||||
wnd.AddButton(x, y, 300f, tab4, "Remove all frames on Dyson Sphere", 16, "button-remove-all-frames-on-dyson-sphere", DysonSphereFunctions.RemoveAllFrames);
|
||||
{
|
||||
y += 72f;
|
||||
var originalY = y;
|
||||
var btn1 = wnd.AddButton(x, y, 300f, tab4, "Generate illegal dyson shell", 16, "button-generate-illegal-dyson-shells", () =>
|
||||
{
|
||||
UIMessageBox.Show("Generate illegal dyson shell".Translate(), "WARNING: This operation can be very slow, continue?".Translate(), "取消".Translate(), "确定".Translate(), UIMessageBox.WARNING, null,
|
||||
() => { DysonSphereFunctions.CreateIllegalDysonShellWithMaxOutput(); });
|
||||
});
|
||||
y += 36f;
|
||||
var btn2 = wnd.AddButton(x, y, 300f, tab4, "Keep max production shells and remove others", 16, "button-keep-max-production-shells", () =>
|
||||
{
|
||||
UIMessageBox.Show("Keep max production shells and remove others".Translate(), "WARNING: This operation is DANGEROUS, continue?".Translate(), "取消".Translate(), "确定".Translate(), UIMessageBox.WARNING, null,
|
||||
() => { DysonSphereFunctions.KeepMaxProductionShells(); });
|
||||
});
|
||||
y += 36f;
|
||||
var btn3 = wnd.AddButton(x, y, 300f, tab4, "Duplicate shells from that with highest production", 16, "button-duplicate-shells-from-the-highest-production", () =>
|
||||
{
|
||||
UIMessageBox.Show("Duplicate shells from that with highest production".Translate(), "WARNING: This operation can be very slow, continue?".Translate(), "取消".Translate(), "确定".Translate(), UIMessageBox.WARNING, null,
|
||||
() => { DysonSphereFunctions.DuplicateShellsWithHighestProduction(); });
|
||||
});
|
||||
y += 30f;
|
||||
var slider1 = wnd.AddSlider(x + 20f, y, tab4, DysonSphereFunctions.ShellsCountForFunctions, new ShellsCountMapper());
|
||||
|
||||
y = originalY;
|
||||
var btn4 = wnd.AddButton(x, y, 300f, tab4, "Generate illegal dyson shell quickly", 16, "button-generate-illegal-dyson-shells-quickly", () =>
|
||||
{
|
||||
UIMessageBox.Show("Generate illegal dyson shell quickly".Translate(), "WARNING: This operation can be very slow, continue?".Translate(), "取消".Translate(), "确定".Translate(), UIMessageBox.WARNING, null,
|
||||
() => { DysonSphereFunctions.CreateIllegalDysonShellQuickly(DysonSphereFunctions.ShellsCountForFunctions.Value); });
|
||||
});
|
||||
y += 30f;
|
||||
var txt2 = wnd.AddText2(x, y, tab4, "Shells count", 15, "text-shells-count");
|
||||
var slider2 = wnd.AddSlider(x + txt2.preferredWidth + 5f, y + 6f, tab4, DysonSphereFunctions.ShellsCountForFunctions, new ShellsCountMapper());
|
||||
|
||||
Functions.DysonSphereFunctions.IllegalDysonShellFunctionsEnabled.SettingChanged += onIllegalDysonShellFunctionsChanged;
|
||||
wnd.OnFree += () => { Functions.DysonSphereFunctions.IllegalDysonShellFunctionsEnabled.SettingChanged -= onIllegalDysonShellFunctionsChanged; };
|
||||
onIllegalDysonShellFunctionsChanged(null, null);
|
||||
void onIllegalDysonShellFunctionsChanged(object o, EventArgs e)
|
||||
{
|
||||
var enabled = Functions.DysonSphereFunctions.IllegalDysonShellFunctionsEnabled.Value;
|
||||
btn1.gameObject.SetActive(enabled);
|
||||
btn2.gameObject.SetActive(enabled);
|
||||
btn3.gameObject.SetActive(enabled);
|
||||
slider1.gameObject.SetActive(enabled);
|
||||
|
||||
btn4.gameObject.SetActive(!enabled);
|
||||
txt2.gameObject.SetActive(!enabled);
|
||||
slider2.gameObject.SetActive(!enabled);
|
||||
}
|
||||
}
|
||||
|
||||
var tab5 = wnd.AddTab(_windowTrans, "Mecha/Combat");
|
||||
x = 0f;
|
||||
y = 10f;
|
||||
wnd.AddCheckBox(x, y, tab5, CombatPatch.MechaInvincibleEnabled, "Mecha and Drones/Fleets invicible");
|
||||
y += 36f;
|
||||
wnd.AddCheckBox(x, y, tab5, CombatPatch.BuildingsInvincibleEnabled, "Buildings invicible");
|
||||
y += 36f;
|
||||
wnd.AddCheckBox(x, y, tab5, PlayerPatch.WarpWithoutSpaceWarpersEnabled, "Enable warp without space warpers");
|
||||
x = 400f;
|
||||
y = 10f;
|
||||
wnd.AddButton(x, y, 200f, tab5, "Teleport to outer space", 16, "button-teleport-to-outer-space", PlayerFunctions.TeleportToOuterSpace);
|
||||
y += 36f;
|
||||
wnd.AddButton(x, y, 200f, tab5, "Teleport to selected astronomical", 16, "button-teleport-to-selected-astronomical", PlayerFunctions.TeleportToSelectedAstronomical);
|
||||
}
|
||||
|
||||
private static void UpdateUI()
|
||||
{
|
||||
UpdateResignButton();
|
||||
UpdateButtons();
|
||||
}
|
||||
|
||||
private static void UpdateResignButton()
|
||||
private static void UpdateButtons()
|
||||
{
|
||||
var resignEnabled = GameMain.data.account != AccountData.me;
|
||||
if (_resignGameBtn.gameObject.activeSelf == resignEnabled) return;
|
||||
_resignGameBtn.gameObject.SetActive(resignEnabled);
|
||||
var data = GameMain.data;
|
||||
if (data == null) return;
|
||||
var resignEnabled = data.account != AccountData.me;
|
||||
if (_resignGameBtn.gameObject.activeSelf != resignEnabled)
|
||||
{
|
||||
_resignGameBtn.gameObject.SetActive(resignEnabled);
|
||||
}
|
||||
|
||||
var history = data.history;
|
||||
if (history == null) return;
|
||||
var banEnabled = history.hasUsedPropertyBanAchievement;
|
||||
if (_clearBanBtn.gameObject.activeSelf != banEnabled)
|
||||
{
|
||||
_clearBanBtn.gameObject.SetActive(banEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "CheatEnabler",
|
||||
"version_number": "2.3.9",
|
||||
"version_number": "2.4.2",
|
||||
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/CheatEnabler",
|
||||
"description": "Add various cheat functions while disabling abnormal determinants / 添加一些作弊功能,同时屏蔽异常检测",
|
||||
"dependencies": [
|
||||
"xiaoye97-BepInEx-5.4.17",
|
||||
"soarqin-UXAssist-1.0.2"
|
||||
"soarqin-UXAssist-1.4.0"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# CompressSave
|
||||
|
||||
#### Moved [here](https://github.com/soarqin/DSP_Mods_TO/tree/master/CompressSave)
|
||||
Moved [to another repo](https://github.com/soarqin/DSP_Mods_TO/tree/master/CompressSave)
|
||||
|
||||
+12
-27
@@ -1,5 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UXAssist", "UXAssist\UXAssist.csproj", "{9C048229-6A50-4642-BC5E-02CD39D3869A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CheatEnabler", "CheatEnabler\CheatEnabler.csproj", "{F9F16B62-D1D3-466B-BE22-E64B9EA957C2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogisticMiner", "LogisticMiner\LogisticMiner.csproj", "{7149D717-C913-4153-9425-38CB9D087F83}"
|
||||
@@ -11,35 +13,30 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dustbin", "Dustbin\Dustbin.
|
||||
{B8EB3D8D-5613-42F0-9040-EAA11A38C6AC} = {B8EB3D8D-5613-42F0-9040-EAA11A38C6AC}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OCBatchBuild", "OCBatchBuild\OCBatchBuild.csproj", "{E8FB30A0-29BF-4CF0-8E08-9784962A8656}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniverseGenTweaks", "UniverseGenTweaks\UniverseGenTweaks.csproj", "{9534694E-14F0-4498-852D-BBB3FCA986CD}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OverclockEverything", "OverclockEverything\OverclockEverything.csproj", "{0168941C-EEA6-49CF-9A67-E829FE06CF9B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MechaDronesTweaks", "MechaDronesTweaks\MechaDronesTweaks.csproj", "{15B8BC2E-93E0-4454-8F8F-BF1FA8DC90F4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LabOpt", "LabOpt\LabOpt.csproj", "{DD76B77C-68D8-4A4C-B98E-CBEECEDC49FB}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{F2D5EBE8-7D9D-4572-9A3E-4DD1114FD99F} = {F2D5EBE8-7D9D-4572-9A3E-4DD1114FD99F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LabOptPreloader", "LabOptPreloader\LabOptPreloader.csproj", "{F2D5EBE8-7D9D-4572-9A3E-4DD1114FD99F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DustbinPreloader", "DustbinPreloader\DustbinPreloader.csproj", "{B8EB3D8D-5613-42F0-9040-EAA11A38C6AC}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PoolOpt", "PoolOpt\PoolOpt.csproj", "{8BE61246-2C9D-4088-AA33-5AFF22C5046E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UXAssist", "UXAssist\UXAssist.csproj", "{9C048229-6A50-4642-BC5E-02CD39D3869A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserCloak", "UserCloak\UserCloak.csproj", "{096D2E4B-D1CE-424D-9954-C36A23E9E279}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LuaScriptEngine", "LuaScriptEngine\LuaScriptEngine.csproj", "{E9375F0E-26DC-4CEC-80DC-9C48F23340BC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{9C048229-6A50-4642-BC5E-02CD39D3869A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9C048229-6A50-4642-BC5E-02CD39D3869A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9C048229-6A50-4642-BC5E-02CD39D3869A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9C048229-6A50-4642-BC5E-02CD39D3869A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F9F16B62-D1D3-466B-BE22-E64B9EA957C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F9F16B62-D1D3-466B-BE22-E64B9EA957C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F9F16B62-D1D3-466B-BE22-E64B9EA957C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@@ -56,10 +53,6 @@ Global
|
||||
{931F0230-5941-4E49-AB19-66921AF14096}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{931F0230-5941-4E49-AB19-66921AF14096}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{931F0230-5941-4E49-AB19-66921AF14096}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E8FB30A0-29BF-4CF0-8E08-9784962A8656}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E8FB30A0-29BF-4CF0-8E08-9784962A8656}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E8FB30A0-29BF-4CF0-8E08-9784962A8656}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E8FB30A0-29BF-4CF0-8E08-9784962A8656}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9534694E-14F0-4498-852D-BBB3FCA986CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9534694E-14F0-4498-852D-BBB3FCA986CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9534694E-14F0-4498-852D-BBB3FCA986CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@@ -72,14 +65,6 @@ Global
|
||||
{15B8BC2E-93E0-4454-8F8F-BF1FA8DC90F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{15B8BC2E-93E0-4454-8F8F-BF1FA8DC90F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{15B8BC2E-93E0-4454-8F8F-BF1FA8DC90F4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DD76B77C-68D8-4A4C-B98E-CBEECEDC49FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DD76B77C-68D8-4A4C-B98E-CBEECEDC49FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DD76B77C-68D8-4A4C-B98E-CBEECEDC49FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DD76B77C-68D8-4A4C-B98E-CBEECEDC49FB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F2D5EBE8-7D9D-4572-9A3E-4DD1114FD99F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F2D5EBE8-7D9D-4572-9A3E-4DD1114FD99F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F2D5EBE8-7D9D-4572-9A3E-4DD1114FD99F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F2D5EBE8-7D9D-4572-9A3E-4DD1114FD99F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B8EB3D8D-5613-42F0-9040-EAA11A38C6AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B8EB3D8D-5613-42F0-9040-EAA11A38C6AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B8EB3D8D-5613-42F0-9040-EAA11A38C6AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@@ -88,13 +73,13 @@ Global
|
||||
{8BE61246-2C9D-4088-AA33-5AFF22C5046E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8BE61246-2C9D-4088-AA33-5AFF22C5046E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8BE61246-2C9D-4088-AA33-5AFF22C5046E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9C048229-6A50-4642-BC5E-02CD39D3869A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9C048229-6A50-4642-BC5E-02CD39D3869A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9C048229-6A50-4642-BC5E-02CD39D3869A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9C048229-6A50-4642-BC5E-02CD39D3869A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{096D2E4B-D1CE-424D-9954-C36A23E9E279}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{096D2E4B-D1CE-424D-9954-C36A23E9E279}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{096D2E4B-D1CE-424D-9954-C36A23E9E279}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{096D2E4B-D1CE-424D-9954-C36A23E9E279}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E9375F0E-26DC-4CEC-80DC-9C48F23340BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E9375F0E-26DC-4CEC-80DC-9C48F23340BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E9375F0E-26DC-4CEC-80DC-9C48F23340BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E9375F0E-26DC-4CEC-80DC-9C48F23340BC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
+61
-37
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
@@ -14,9 +13,8 @@ public static class BeltSignal
|
||||
private static HashSet<int>[] _signalBelts;
|
||||
private static int _signalBeltsCapacity;
|
||||
private static bool _initialized;
|
||||
private static AssetBundle _bundle;
|
||||
private static Harmony _patch;
|
||||
|
||||
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
@@ -33,12 +31,40 @@ public static class BeltSignal
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix, HarmonyPriority(Priority.Last), HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")]
|
||||
private static byte[] LoadEmbeddedResource(string path, Assembly assembly = null)
|
||||
{
|
||||
if (assembly == null)
|
||||
{
|
||||
assembly = Assembly.GetCallingAssembly();
|
||||
}
|
||||
var info = assembly.GetName();
|
||||
var name = info.Name;
|
||||
using var stream = assembly.GetManifestResourceStream($"{name}.{path.Replace('/', '.')}")!;
|
||||
var buffer = new byte[stream.Length];
|
||||
_ = stream.Read(buffer, 0, buffer.Length);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private static Texture2D LoadEmbeddedTexture(string path, Assembly assembly = null)
|
||||
{
|
||||
var fileData = LoadEmbeddedResource(path, assembly);
|
||||
var tex = new Texture2D(2, 2);
|
||||
tex.LoadImage(fileData);
|
||||
return tex;
|
||||
}
|
||||
|
||||
private static Sprite LoadEmbeddedSprite(string path, Assembly assembly = null)
|
||||
{
|
||||
var tex = LoadEmbeddedTexture(path, assembly);
|
||||
return Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
|
||||
}
|
||||
|
||||
[HarmonyPostfix, HarmonyPriority(Priority.Last)]
|
||||
[HarmonyPatch(typeof(VFPreload), nameof(VFPreload.InvokeOnLoadWorkEnded))]
|
||||
private static void VFPreload_InvokeOnLoadWorkEnded_Postfix()
|
||||
{
|
||||
if (_initialized) return;
|
||||
var pluginfolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
_bundle = AssetBundle.LoadFromFile($"{pluginfolder}/dustbin.assetbundle");
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
var signals = LDB._signals;
|
||||
var index = signals.dataArray.Length;
|
||||
var p = new SignalProto
|
||||
@@ -47,7 +73,7 @@ public static class BeltSignal
|
||||
Name = "DUSTBIN",
|
||||
GridIndex = 3110,
|
||||
IconPath = "Assets/signal-410.png",
|
||||
_iconSprite = _bundle.LoadAsset<Sprite>("Assets/signal-410.png"),
|
||||
_iconSprite = LoadEmbeddedSprite("assets/icon/signal-410.png", assembly),
|
||||
SID = ""
|
||||
};
|
||||
p.name = p.Name.Translate();
|
||||
@@ -86,7 +112,7 @@ public static class BeltSignal
|
||||
var signalBelts = GetOrCreateSignalBelts(factory);
|
||||
signalBelts.Add(beltId);
|
||||
}
|
||||
|
||||
|
||||
private static HashSet<int> GetOrCreateSignalBelts(int index)
|
||||
{
|
||||
HashSet<int> obj;
|
||||
@@ -114,7 +140,7 @@ public static class BeltSignal
|
||||
{
|
||||
return index >= 0 && index < _signalBeltsCapacity ? _signalBelts[index] : null;
|
||||
}
|
||||
|
||||
|
||||
private static void RemoveSignalBelt(int factory, int beltId)
|
||||
{
|
||||
GetSignalBelts(factory)?.Remove(beltId);
|
||||
@@ -124,7 +150,7 @@ public static class BeltSignal
|
||||
{
|
||||
GetSignalBelts(factory)?.Clear();
|
||||
}
|
||||
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(DigitalSystem), MethodType.Constructor, typeof(PlanetData))]
|
||||
private static void DigitalSystem_Constructor_Postfix(PlanetData _planet)
|
||||
@@ -172,40 +198,38 @@ public static class BeltSignal
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(GameData), "GameTick")]
|
||||
[HarmonyPatch(typeof(GameData), nameof(GameData.GameTick))]
|
||||
public static IEnumerable<CodeInstruction> GameData_GameTick_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(PerformanceMonitor), nameof(PerformanceMonitor.EndSample)))
|
||||
).Advance(1).Insert(
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(BeltSignal), nameof(ProcessBeltSignals)))
|
||||
Transpilers.EmitDelegate(() =>
|
||||
{
|
||||
var factories = GameMain.data?.factories;
|
||||
if (factories == null) return;
|
||||
foreach (var factory in factories)
|
||||
{
|
||||
if (factory == null) continue;
|
||||
var index = factory.index;
|
||||
var belts = GetSignalBelts(index);
|
||||
if (belts == null || belts.Count == 0) continue;
|
||||
var consumeRegister = GameMain.statistics.production.factoryStatPool[index].consumeRegister;
|
||||
var cargoTraffic = factory.cargoTraffic;
|
||||
foreach (var beltId in belts)
|
||||
{
|
||||
ref var belt = ref cargoTraffic.beltPool[beltId];
|
||||
var cargoPath = cargoTraffic.GetCargoPath(belt.segPathId);
|
||||
if (cargoPath == null) continue;
|
||||
int itemId;
|
||||
if ((itemId = cargoPath.TryPickItem(belt.segIndex + belt.segPivotOffset - 5, 12, out var stack, out _)) <= 0) continue;
|
||||
consumeRegister[itemId] += stack;
|
||||
Dustbin.CalcGetSands(itemId, stack);
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
public static void ProcessBeltSignals()
|
||||
{
|
||||
var factories = GameMain.data?.factories;
|
||||
if (factories == null) return;
|
||||
foreach (var factory in factories)
|
||||
{
|
||||
if (factory == null) continue;
|
||||
var index = factory.index;
|
||||
var belts = GetSignalBelts(index);
|
||||
if (belts == null || belts.Count == 0) continue;
|
||||
var consumeRegister = GameMain.statistics.production.factoryStatPool[index].consumeRegister;
|
||||
var cargoTraffic = factory.cargoTraffic;
|
||||
foreach (var beltId in belts)
|
||||
{
|
||||
ref var belt = ref cargoTraffic.beltPool[beltId];
|
||||
var cargoPath = cargoTraffic.GetCargoPath(belt.segPathId);
|
||||
if (cargoPath == null) continue;
|
||||
int itemId;
|
||||
if ((itemId = cargoPath.TryPickItem(belt.segIndex + belt.segPivotOffset - 5, 12, out var stack, out _)) <= 0) continue;
|
||||
consumeRegister[itemId] += stack;
|
||||
Dustbin.CalcGetSands(itemId, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<details>
|
||||
<summary>Read me in English</summary>
|
||||
|
||||
## Changelog
|
||||
|
||||
* 1.4.0
|
||||
* Refactorying Tank input logic codes, for better performance, and resolve a bug [#53](https://github.com/soarqin/DSP_Mods/issues/53)
|
||||
* Remove use of AssetBundle, move the belt signal icon into `Assembly Resources`, for better flexibility.
|
||||
|
||||
* 1.3.3
|
||||
* Support for NebulaMultiplayerModApi 2.0.0
|
||||
|
||||
* 1.3.2
|
||||
* Fix a display issue that the dustbin checkbox is overlapped with the filter button in storage UI.
|
||||
|
||||
* 1.3.1
|
||||
* Support for game version 0.10.28.20759
|
||||
|
||||
* 1.3.0
|
||||
* Add a belt signal(you can find it in first tab of signal selection panel) as dustbin, which is the simplest way to destroy items.
|
||||
* Reworked dustbin support for Tanks, to improve performance and resolve known bugs.
|
||||
* Be note that the whole tank logic is optimized which may get a slight better performance even if you don't use them as dustbin.
|
||||
* Config entry for soil piless gain from destroyed items are changed to a more flexible format.
|
||||
* [Nebula Mupltiplayer Mod](https://dsp.thunderstore.io/package/nebula/NebulaMultiplayerMod/) and bug fixes from [ModFixerOne](https://dsp.thunderstore.io/package/starfi5h/ModFixerOne/) by [starfi5h](https://github.com/starfi5h/).
|
||||
|
||||
* 1.2.1
|
||||
* Fix dynamic array bug in codes, which causes various bugs and errors.
|
||||
|
||||
* 1.2.0
|
||||
* Use [DSPModSave](https://dsp.thunderstore.io/package/CommonAPI/DSPModSave/) to save dustbin specified data now, which fixes [#1](https://github.com/soarqin/DSP_Mods/issues/1).
|
||||
* Fix issue for storages on multiple planets.
|
||||
* Fix issue for multi-level tanks.
|
||||
* Add a note in README for known bug on tank.
|
||||
|
||||
* 1.1.0
|
||||
* Rewrite whole plugin, make a checkbox on UI so that you can turn storages into dustbin by just ticking it.
|
||||
* Can turn tank into dustbin now.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>中文读我</summary>
|
||||
|
||||
## 更新日志
|
||||
|
||||
* 1.4.0
|
||||
* 重构储液罐的输入逻辑代码,以提高性能并解决bug [#53](https://github.com/soarqin/DSP_Mods/issues/53)
|
||||
* 移除了AssetBundle的使用,将传送带信号图标移入`Assembly资源`,以获得更好的灵活性
|
||||
|
||||
* 1.3.3
|
||||
* 支持NebulaMultiplayerModApi 2.0.0
|
||||
|
||||
* 1.3.2
|
||||
* 修正了储物仓UI中的垃圾桶勾选框与筛选按钮重叠的显示问题
|
||||
|
||||
* 1.3.1
|
||||
* 支持游戏版本 0.10.28.20759
|
||||
|
||||
* 1.3.0
|
||||
* 添加了一个传送带信号(可以在信号选择面板的第一个页签中找到)作为垃圾桶,这是目前销毁物品最简单的方法
|
||||
* 重写了储液罐的垃圾桶实现,以提高性能并解决已知的bug
|
||||
* 注意:整个储液罐逻辑都被优化了,即使你不把他们作为垃圾桶使用,也可能会获得轻微的性能提升
|
||||
* 从销毁的物品中获得沙子的配置已变为更灵活的设置项格式
|
||||
* [Nebula Mupltiplayer Mod](https://dsp.thunderstore.io/package/nebula/NebulaMultiplayerMod/)支持和Bug修正来自[starfi5h](https://github.com/starfi5h/)的[ModFixerOne](https://dsp.thunderstore.io/package/starfi5h/ModFixerOne/)
|
||||
|
||||
* 1.2.1
|
||||
* 修正了代码中的动态数组Bug,该Bug可能导致各种问题
|
||||
|
||||
* 1.2.0
|
||||
* 现在使用[DSPModSave](https://dsp.thunderstore.io/package/CommonAPI/DSPModSave/)来保存垃圾桶的数据,修正了[#1](https://github.com/soarqin/DSP_Mods/issues/1)
|
||||
* 修正了多星球上的储物仓问题
|
||||
* 修正了多层储液罐的问题
|
||||
* 在README中添加了一个已知储液罐Bug的说明
|
||||
|
||||
* 1.1.0
|
||||
* 重写了整个插件,现在可以在仓储类建筑的UI上勾选来将其转变为垃圾桶
|
||||
* 现在可以将储液罐转变为垃圾桶
|
||||
|
||||
</details>
|
||||
+10
-12
@@ -5,12 +5,13 @@ using System.Runtime.CompilerServices;
|
||||
using BepInEx;
|
||||
using crecheng.DSPModSave;
|
||||
using NebulaAPI;
|
||||
using NebulaAPI.Interfaces;
|
||||
|
||||
namespace Dustbin;
|
||||
|
||||
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
|
||||
[BepInDependency(DSPModSavePlugin.MODGUID)]
|
||||
[BepInDependency(NebulaModAPI.API_GUID)]
|
||||
[BepInDependency(NebulaModAPI.API_GUID, BepInDependency.DependencyFlags.SoftDependency)]
|
||||
public class Dustbin : BaseUnityPlugin, IModCanSave, IMultiplayerMod
|
||||
{
|
||||
public string Version => PluginInfo.PLUGIN_VERSION;
|
||||
@@ -30,7 +31,7 @@ public class Dustbin : BaseUnityPlugin, IModCanSave, IMultiplayerMod
|
||||
var storageDustbin = Config.Bind("General", "StorageDustbin", true, "Can turn storages into dustbins").Value;
|
||||
var tankDustbin = Config.Bind("General", "TankDustbin", true, "Can turn tanks into dustbins").Value;
|
||||
var belgSignalDustbin = Config.Bind("General", "BeltSignalDustbin", true, "Add belt signal as dustbin").Value;
|
||||
var sandsFactorsStr = Config.Bind("General", "SandsFactors", "", "Sands get from different items\nFormat: id1:value1|id2:value2|...").Value;
|
||||
var sandsFactorsStr = Config.Bind("General", "SandsFactors", "", "Soil piles get from different items\nFormat: id1:value1|id2:value2|...").Value;
|
||||
foreach (var s in sandsFactorsStr.Split('|'))
|
||||
{
|
||||
var sp = s.Split(':');
|
||||
@@ -41,16 +42,13 @@ public class Dustbin : BaseUnityPlugin, IModCanSave, IMultiplayerMod
|
||||
}
|
||||
if (storageDustbin) StoragePatch.Enable(true);
|
||||
if (tankDustbin) TankPatch.Enable(true);
|
||||
|
||||
if (storageDustbin || tankDustbin)
|
||||
{
|
||||
NebulaModAPI.RegisterPackets(Assembly.GetExecutingAssembly());
|
||||
NebulaModAPI.OnPlanetLoadFinished += RequestPlanetDustbinData;
|
||||
}
|
||||
|
||||
if (belgSignalDustbin) BeltSignal.Enable(true);
|
||||
|
||||
if (!BepInEx.Bootstrap.Chainloader.PluginInfos.ContainsKey("dsp.nebula-multiplayer") || (!storageDustbin && !tankDustbin)) return;
|
||||
NebulaModAPI.RegisterPackets(Assembly.GetExecutingAssembly());
|
||||
NebulaModAPI.OnPlanetLoadFinished += RequestPlanetDustbinData;
|
||||
}
|
||||
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
TankPatch.Enable(false);
|
||||
@@ -70,7 +68,7 @@ public class Dustbin : BaseUnityPlugin, IModCanSave, IMultiplayerMod
|
||||
return count;
|
||||
}
|
||||
|
||||
#region IModCanSave
|
||||
#region IModCanSave
|
||||
private const ushort ModSaveVersion = 1;
|
||||
|
||||
public void Export(BinaryWriter w)
|
||||
@@ -178,7 +176,7 @@ public class Dustbin : BaseUnityPlugin, IModCanSave, IMultiplayerMod
|
||||
|
||||
public void RequestPlanetDustbinData(int planetId)
|
||||
{
|
||||
if (NebulaModAPI.IsMultiplayerActive && NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient)
|
||||
if (NebulaModAPI.IsMultiplayerActive && NebulaModAPI.MultiplayerSession.IsClient)
|
||||
NebulaModAPI.MultiplayerSession.Network.SendPacket(new NebulaSupport.Packet.ToggleEvent(planetId, 0, false));
|
||||
}
|
||||
#endregion
|
||||
|
||||
+20
-12
@@ -5,7 +5,7 @@
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<BepInExPluginGuid>org.soardev.dustbin</BepInExPluginGuid>
|
||||
<Description>DSP MOD - Dustbin</Description>
|
||||
<Version>1.3.2</Version>
|
||||
<Version>1.4.0</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageId>Dustbin</PackageId>
|
||||
@@ -16,23 +16,31 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BepInEx.Core" Version="5.*" />
|
||||
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
|
||||
<PackageReference Include="DysonSphereProgram.GameLibs" Version="*-r.*" />
|
||||
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
|
||||
<PackageReference Include="DysonSphereProgram.Modding.DSPModSave" Version="1.*" />
|
||||
<PackageReference Include="DysonSphereProgram.Modding.NebulaMultiplayerModApi" Version="1.3.1" />
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" />
|
||||
<PackageReference Include="DysonSphereProgram.Modding.NebulaMultiplayerModApi" Version="2.0.0" />
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
|
||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>GameAssembly\Assembly-CSharp.dll</HintPath>
|
||||
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UI">
|
||||
<HintPath>..\AssemblyFromGame\UnityEngine.UI.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip
IF NOT EXIST package\plugins (mkdir package\plugins)
copy /y $(TargetPath) package\plugins\
zip -9 -j package/$(ProjectName)-$(Version).zip package/icon.png package/manifest.json README.md
cd package
zip -9 -r $(ProjectName)-$(Version).zip patchers plugins" />
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="assets/icon/signal-410.png" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
|
||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
|
||||
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip
|
||||
IF NOT EXIST package\plugins (mkdir package\plugins)
copy /y $(TargetPath) package\plugins\
cd package
powershell Compress-Archive -Force -DestinationPath '$(ProjectName)-$(Version).zip' -Path patchers, plugins, icon.png, manifest.json, ../README.md, ../CHANGELOG.md" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using NebulaAPI;
|
||||
using NebulaAPI.Networking;
|
||||
using NebulaAPI.Packets;
|
||||
|
||||
namespace Dustbin.NebulaSupport
|
||||
{
|
||||
@@ -59,19 +61,19 @@ namespace Dustbin.NebulaSupport
|
||||
NebulaModAPI.MultiplayerSession.Network.SendPacket(new SyncPlanetData(Dustbin.ExportData(factory)));
|
||||
return;
|
||||
case < 0:
|
||||
{
|
||||
var tankPool = factory.factoryStorage.tankPool;
|
||||
tankPool[-storageId].IsDustbin = packet.Enable;
|
||||
TankPatch.Reset();
|
||||
return;
|
||||
}
|
||||
{
|
||||
var tankPool = factory.factoryStorage.tankPool;
|
||||
tankPool[-storageId].IsDustbin = packet.Enable;
|
||||
TankPatch.Reset();
|
||||
return;
|
||||
}
|
||||
case > 0:
|
||||
{
|
||||
var storagePool = factory.factoryStorage.storagePool;
|
||||
storagePool[storageId].IsDustbin = packet.Enable;
|
||||
StoragePatch.Reset();
|
||||
return;
|
||||
}
|
||||
{
|
||||
var storagePool = factory.factoryStorage.storagePool;
|
||||
storagePool[storageId].IsDustbin = packet.Enable;
|
||||
StoragePatch.Reset();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-55
@@ -1,72 +1,29 @@
|
||||
# Dustbin
|
||||
|
||||
#### Can turn Storages and Tanks into Dustbin(Destroy incoming items)
|
||||
#### 储物仓和储液罐可以转变为垃圾桶(销毁送进的物品)
|
||||
<details>
|
||||
<summary>Read me in English</summary>
|
||||
|
||||
## Changelog
|
||||
* 1.3.2
|
||||
+ Fix a display issue that the dustbin checkbox is overlapped with the filter button in storage UI.
|
||||
|
||||
* 1.3.1
|
||||
+ Support for game version 0.10.28.20759
|
||||
|
||||
* 1.3.0
|
||||
+ Add a belt signal(you can find it in first tab of signal selection panel) as dustbin, which is the simplest way to destroy items.
|
||||
+ Reworked dustbin support for Tanks, to improve performance and resolve known bugs.
|
||||
- Be note that the whole tank logic is optimized which may get a slight better performance even if you don't use them as dustbin.
|
||||
+ Config entry for sands gain from destroyed items are changed to a more flexible format.
|
||||
+ [Nebula Mupltiplayer Mod](https://dsp.thunderstore.io/package/nebula/NebulaMultiplayerMod/) and bug fixes from [ModFixerOne](https://dsp.thunderstore.io/package/starfi5h/ModFixerOne/) by [starfi5h](https://github.com/starfi5h/).
|
||||
|
||||
* 1.2.1
|
||||
+ Fix dynamic array bug in codes, which causes various bugs and errors.
|
||||
|
||||
* 1.2.0
|
||||
+ Use [DSPModSave](https://dsp.thunderstore.io/package/CommonAPI/DSPModSave/) to save dustbin specified data now, which fixes [#1](https://github.com/soarqin/DSP_Mods/issues/1).
|
||||
+ Fix issue for storages on multiple planets.
|
||||
+ Fix issue for multi-level tanks.
|
||||
+ Add a note in README for known bug on tank.
|
||||
|
||||
* 1.1.0
|
||||
+ Rewrite whole plugin, make a checkbox on UI so that you can turn storages into dustbin by just ticking it.
|
||||
+ Can turn tank into dustbin now.
|
||||
***Can turn Storages and Tanks into Dustbin(Destroy incoming items)***
|
||||
|
||||
## Usage
|
||||
|
||||
* A checkbox is added to Storages and Tanks UI, which turns them into dustbins.
|
||||
* Items sent into dustbins are removed immediately.
|
||||
* Can get sands from destroyed items, configurable through a json encoded config entry.
|
||||
+ You can get item ID list [here](https://dsp-wiki.com/Modding:Items_IDs).
|
||||
* Can get soil piless from destroyed items, configurable through a json encoded config entry.
|
||||
* You can get item ID list from [dsp-wiki](https://dsp-wiki.com/Modding:Items_IDs).
|
||||
|
||||
## 更新日志
|
||||
* 1.3.2
|
||||
+ 修正了储物仓UI中的垃圾桶勾选框与筛选按钮重叠的显示问题
|
||||
</details>
|
||||
|
||||
* 1.3.1
|
||||
+ 支持游戏版本 0.10.28.20759
|
||||
<details>
|
||||
<summary>中文读我</summary>
|
||||
|
||||
* 1.3.0
|
||||
+ 添加了一个传送带信号(可以在信号选择面板的第一个页签中找到)作为垃圾桶,这是目前销毁物品最简单的方法
|
||||
+ 重写了储液罐的垃圾桶实现,以提高性能并解决已知的bug
|
||||
- 注意:整个储液罐逻辑都被优化了,即使你不把他们作为垃圾桶使用,也可能会获得轻微的性能提升
|
||||
+ 从销毁的物品中获得沙子的配置已变为更灵活的设置项格式
|
||||
+ [Nebula Mupltiplayer Mod](https://dsp.thunderstore.io/package/nebula/NebulaMultiplayerMod/)支持和Bug修正来自[starfi5h](https://github.com/starfi5h/)的[ModFixerOne](https://dsp.thunderstore.io/package/starfi5h/ModFixerOne/)
|
||||
|
||||
* 1.2.1
|
||||
+ 修正了代码中的动态数组Bug,该Bug可能导致各种问题
|
||||
|
||||
* 1.2.0
|
||||
+ 现在使用[DSPModSave](https://dsp.thunderstore.io/package/CommonAPI/DSPModSave/)来保存垃圾桶的数据,修正了[#1](https://github.com/soarqin/DSP_Mods/issues/1)
|
||||
+ 修正了多星球上的储物仓问题
|
||||
+ 修正了多层储液罐的问题
|
||||
+ 在README中添加了一个已知储液罐Bug的说明
|
||||
|
||||
* 1.1.0
|
||||
+ 重写了整个插件,现在可以在仓储类建筑的UI上勾选来将其转变为垃圾桶
|
||||
+ 现在可以将储液罐转变为垃圾桶
|
||||
***储物仓和储液罐可以转变为垃圾桶(销毁送进的物品)***
|
||||
|
||||
## 使用说明
|
||||
|
||||
* 在储物仓和储液罐上增加一个垃圾桶的勾选框。
|
||||
* 送进垃圾桶的物品会立即被移除。
|
||||
* 可以从移除的物品中获得沙子,可以通过json编码的设置项进行配置。
|
||||
+ 可以在[这里](https://dsp-wiki.com/Modding:Items_IDs)获得物品ID列表。
|
||||
* 可以在[这里](https://dsp-wiki.com/Modding:Items_IDs)获得物品ID列表。
|
||||
|
||||
</details>
|
||||
|
||||
@@ -13,7 +13,7 @@ public static class StoragePatch
|
||||
private static UI.MyCheckBox _storageDustbinCheckBox;
|
||||
private static int _lastStorageId;
|
||||
private static Harmony _patch;
|
||||
|
||||
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
@@ -96,14 +96,14 @@ public static class StoragePatch
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(GameMain), "Start")]
|
||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.Start))]
|
||||
private static void GameMain_Start_Prefix()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(UIStorageWindow), "_OnCreate")]
|
||||
[HarmonyPatch(typeof(UIStorageWindow), nameof(UIStorageWindow._OnCreate))]
|
||||
private static void UIStorageWindow__OnCreate_Postfix(UIStorageWindow __instance)
|
||||
{
|
||||
_storageDustbinCheckBox = UI.MyCheckBox.CreateCheckBox(false, __instance.transform, 50f, 50f, Localization.CurrentLanguageLCID == Localization.LCID_ZHCN ? "垃圾桶" : "Dustbin");
|
||||
@@ -123,7 +123,7 @@ public static class StoragePatch
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(UIStorageWindow), "_OnUpdate")]
|
||||
[HarmonyPatch(typeof(UIStorageWindow), nameof(UIStorageWindow._OnUpdate))]
|
||||
private static void UIStorageWindow__OnUpdate_Postfix(UIStorageWindow __instance)
|
||||
{
|
||||
var storageId = __instance.storageId;
|
||||
@@ -138,10 +138,10 @@ public static class StoragePatch
|
||||
_storageDustbinCheckBox.rectTrans.anchoredPosition3D = new Vector3(190, 57 - rectTrans.sizeDelta.y, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Adopt fix from starfi5h's NebulaCompatiblilityAssist */
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(UIStorageGrid), "OnStorageSizeChanged")]
|
||||
[HarmonyPatch(typeof(UIStorageGrid), nameof(UIStorageGrid.OnStorageSizeChanged))]
|
||||
private static void UIStorageGrid_OnStorageSizeChanged_Postfix()
|
||||
{
|
||||
// Due to storage window is empty when open in client, the size will change after receiving data from host
|
||||
@@ -149,8 +149,8 @@ public static class StoragePatch
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(StorageComponent), "AddItem", new[] { typeof(int), typeof(int), typeof(int), typeof(int), typeof(bool) },
|
||||
new[] { ArgumentType.Normal, ArgumentType.Normal, ArgumentType.Normal, ArgumentType.Out, ArgumentType.Normal })]
|
||||
[HarmonyPatch(typeof(StorageComponent), nameof(StorageComponent.AddItem), [typeof(int), typeof(int), typeof(int), typeof(int), typeof(bool)],
|
||||
[ArgumentType.Normal, ArgumentType.Normal, ArgumentType.Normal, ArgumentType.Out, ArgumentType.Normal])]
|
||||
private static IEnumerable<CodeInstruction> StorageComponent_AddItem_HarmonyTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
@@ -172,7 +172,7 @@ public static class StoragePatch
|
||||
|
||||
/* We keep this to make MOD compatible with older version */
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(StorageComponent), "Import")]
|
||||
[HarmonyPatch(typeof(StorageComponent), nameof(StorageComponent.Import))]
|
||||
private static void StorageComponent_Import_Postfix(StorageComponent __instance)
|
||||
{
|
||||
if (__instance.bans >= 0)
|
||||
|
||||
+42
-68
@@ -11,7 +11,7 @@ public static class TankPatch
|
||||
private static UI.MyCheckBox _tankDustbinCheckBox;
|
||||
private static int _lastTankId;
|
||||
private static Harmony _patch;
|
||||
|
||||
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
@@ -100,14 +100,14 @@ public static class TankPatch
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(GameMain), "Start")]
|
||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.Start))]
|
||||
private static void GameMain_Start_Prefix()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(UITankWindow), "_OnCreate")]
|
||||
[HarmonyPatch(typeof(UITankWindow), nameof(UITankWindow._OnCreate))]
|
||||
private static void UITankWindow__OnCreate_Postfix(UITankWindow __instance)
|
||||
{
|
||||
_tankDustbinCheckBox = UI.MyCheckBox.CreateCheckBox(false, __instance.transform, 120f, 20f, Localization.CurrentLanguageLCID == Localization.LCID_ZHCN ? "垃圾桶" : "Dustbin");
|
||||
@@ -127,7 +127,7 @@ public static class TankPatch
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(UITankWindow), "_OnUpdate")]
|
||||
[HarmonyPatch(typeof(UITankWindow), nameof(UITankWindow._OnUpdate))]
|
||||
private static void UITankWindow__OnUpdate_Postfix(UITankWindow __instance)
|
||||
{
|
||||
var tankId = __instance.tankId;
|
||||
@@ -142,7 +142,7 @@ public static class TankPatch
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(TankComponent), "GameTick")]
|
||||
[HarmonyPatch(typeof(TankComponent), nameof(TankComponent.GameTick))]
|
||||
private static bool TankComponent_GameTick_Prefix(ref TankComponent __instance, PlanetFactory factory)
|
||||
{
|
||||
if (__instance.fluidInc < 0)
|
||||
@@ -183,94 +183,68 @@ public static class TankPatch
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static void TankComponentUpdateBelt(ref TankComponent thisTank, int belt, bool isOutput, ref CargoTraffic cargoTraffic, ref TankComponent[] tankPool)
|
||||
{
|
||||
switch (isOutput)
|
||||
if (isOutput)
|
||||
{
|
||||
case true when thisTank.outputSwitch:
|
||||
if (thisTank.outputSwitch)
|
||||
{
|
||||
if (thisTank.fluidId <= 0 || thisTank.fluidCount <= 0) return;
|
||||
var inc = thisTank.fluidInc == 0 ? 0 : thisTank.fluidInc / thisTank.fluidCount;
|
||||
if (!cargoTraffic.TryInsertItemAtHead(belt, thisTank.fluidId, 1, (byte)inc)) return;
|
||||
thisTank.fluidCount--;
|
||||
thisTank.fluidInc -= inc;
|
||||
return;
|
||||
}
|
||||
case false when thisTank.inputSwitch:
|
||||
}
|
||||
else
|
||||
{
|
||||
if (thisTank.inputSwitch)
|
||||
{
|
||||
byte stack;
|
||||
byte inc;
|
||||
switch (thisTank.fluidId)
|
||||
var thisFluidId = thisTank.fluidId;
|
||||
if (thisTank.fluidCount <= 0)
|
||||
{
|
||||
case > 0 when thisTank.fluidCount < thisTank.fluidCapacity && cargoTraffic.TryPickItemAtRear(belt, thisTank.fluidId, null, out stack, out inc) > 0 &&
|
||||
!thisTank.IsDustbin:
|
||||
thisTank.fluidCount += stack;
|
||||
thisTank.fluidInc += inc;
|
||||
return;
|
||||
case 0:
|
||||
{
|
||||
var count = cargoTraffic.TryPickItemAtRear(belt, 0, ItemProto.fluids, out stack, out inc);
|
||||
if (count <= 0 || thisTank.IsDustbin) return;
|
||||
thisTank.fluidId = count;
|
||||
thisTank.fluidCount += stack;
|
||||
thisTank.fluidInc += inc;
|
||||
return;
|
||||
}
|
||||
var fluidId = cargoTraffic.TryPickItemAtRear(belt, 0, ItemProto.fluids, out stack, out inc);
|
||||
if (fluidId <= 0 || thisTank.IsDustbin) return;
|
||||
thisTank.fluidId = fluidId;
|
||||
thisTank.fluidCount = stack;
|
||||
thisTank.fluidInc = inc;
|
||||
return;
|
||||
}
|
||||
|
||||
if (thisTank.fluidCount < thisTank.fluidCapacity || cargoTraffic.GetItemIdAtRear(belt) != thisTank.fluidId || thisTank.nextTankId <= 0) return;
|
||||
ref var targetTank = ref tankPool[thisTank.nextTankId];
|
||||
while (targetTank.fluidCount >= targetTank.fluidCapacity)
|
||||
if (thisTank.fluidCount < thisTank.fluidCapacity || thisTank.IsDustbin)
|
||||
{
|
||||
ref var lastTank = ref tankPool[targetTank.lastTankId];
|
||||
if (targetTank.fluidId != lastTank.fluidId)
|
||||
if (cargoTraffic.GetItemIdAtRear(belt) != thisFluidId || thisTank.nextTankId <= 0) return;
|
||||
if (cargoTraffic.TryPickItemAtRear(belt, thisFluidId, null, out stack, out inc) <= 0 || thisTank.IsDustbin) return;
|
||||
thisTank.fluidCount += stack;
|
||||
thisTank.fluidInc += inc;
|
||||
return;
|
||||
}
|
||||
if (thisTank.nextTankId <= 0) return;
|
||||
ref var targetTank = ref tankPool[thisTank.nextTankId];
|
||||
while (true)
|
||||
{
|
||||
if (targetTank.fluidCount < targetTank.fluidCapacity || targetTank.IsDustbin)
|
||||
{
|
||||
if (lastTank.id == thisTank.id || targetTank.fluidCount >= targetTank.fluidCapacity) return;
|
||||
targetTank = ref lastTank;
|
||||
if (!targetTank.inputSwitch) return;
|
||||
var targetFluidId = targetTank.fluidId;
|
||||
if (targetFluidId != 0 && targetFluidId != thisFluidId) return;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!targetTank.inputSwitch)
|
||||
{
|
||||
if (lastTank.id == thisTank.id || targetTank.fluidCount >= targetTank.fluidCapacity) return;
|
||||
targetTank = ref lastTank;
|
||||
break;
|
||||
}
|
||||
|
||||
if (targetTank.nextTankId <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (targetTank.nextTankId <= 0) return;
|
||||
targetTank = ref tankPool[targetTank.nextTankId];
|
||||
}
|
||||
|
||||
ref var lastTank2 = ref tankPool[targetTank.lastTankId];
|
||||
if (!targetTank.inputSwitch)
|
||||
if (cargoTraffic.TryPickItemAtRear(belt, thisFluidId, null, out stack, out inc) <= 0 || targetTank.IsDustbin) return;
|
||||
if (targetTank.fluidCount <= 0)
|
||||
{
|
||||
targetTank = ref lastTank2;
|
||||
targetTank.fluidId = thisFluidId;
|
||||
targetTank.fluidCount = stack;
|
||||
targetTank.fluidInc = inc;
|
||||
}
|
||||
else
|
||||
{
|
||||
var fluidId = targetTank.fluidId;
|
||||
if (fluidId != 0 && fluidId != lastTank2.fluidId)
|
||||
{
|
||||
if (lastTank2.id == thisTank.id || targetTank.fluidCount >= targetTank.fluidCapacity) return;
|
||||
targetTank = ref lastTank2;
|
||||
}
|
||||
else if (!lastTank2.outputSwitch)
|
||||
{
|
||||
return;
|
||||
}
|
||||
targetTank.fluidCount += stack;
|
||||
targetTank.fluidInc += inc;
|
||||
}
|
||||
|
||||
if (cargoTraffic.TryPickItemAtRear(belt, thisTank.fluidId, null, out stack, out inc) <= 0 || targetTank.IsDustbin) return;
|
||||
if (targetTank.fluidCount == 0)
|
||||
{
|
||||
targetTank.fluidId = thisTank.fluidId;
|
||||
}
|
||||
|
||||
targetTank.fluidCount += stack;
|
||||
targetTank.fluidInc += inc;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "Dustbin",
|
||||
"version_number": "1.3.2",
|
||||
"version_number": "1.4.0",
|
||||
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/Dustbin",
|
||||
"description": "Can turn Storages and Tanks into Dustbin(Destroy incoming items) / 储物仓和储液罐可以转变为垃圾桶(销毁送进的物品)",
|
||||
"dependencies": [
|
||||
"xiaoye97-BepInEx-5.4.17",
|
||||
"CommonAPI-DSPModSave-1.1.4",
|
||||
"nebula-NebulaMultiplayerModApi-1.3.1"
|
||||
"nebula-NebulaMultiplayerModApi-2.0.0"
|
||||
]
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -7,7 +7,7 @@ namespace DustbinPreloader;
|
||||
|
||||
public static class Preloader
|
||||
{
|
||||
private static readonly ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource("Dustbin Preloader");
|
||||
private static readonly ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource("Dustbin Preloader");
|
||||
public static IEnumerable<string> TargetDLLs { get; } = new[] { "Assembly-CSharp.dll" };
|
||||
|
||||
public static void Patch(AssemblyDefinition assembly)
|
||||
|
||||
@@ -14,15 +14,24 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BepInEx.Core" Version="5.*" />
|
||||
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
|
||||
<PackageReference Include="DysonSphereProgram.GameLibs" Version="*-r.*" />
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" />
|
||||
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UI">
|
||||
<HintPath>..\AssemblyFromGame\UnityEngine.UI.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
|
||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
|
||||
<Exec Command="IF NOT EXIST ..\Dustbin\package\patchers (mkdir ..\Dustbin\package\patchers)
copy /y $(TargetPath) ..\Dustbin\package\patchers\" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<details>
|
||||
<summary>Read me in English</summary>
|
||||
|
||||
## Changelog
|
||||
|
||||
* 1.0.4
|
||||
* Remove `Disable title screen demo scene loading`, as it is buggy in recent updates.
|
||||
* Fix a bug that when tutorials are not added to the guides panel when they are hidden by this MOD.
|
||||
* 1.0.3
|
||||
* Add config entries to disable research completion tips/popup windows
|
||||
* Add a note to README for mod compatibility on `Disable title screen demo scene loading`.
|
||||
* 1.0.2
|
||||
* Add a config entry to disable title screen demo scene loading
|
||||
* 1.0.1
|
||||
* Hide 3 more random tutorial tips popup from bottom-right panel
|
||||
* 1.0.0
|
||||
* Initial release
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>中文读我</summary>
|
||||
|
||||
## 更新日志
|
||||
|
||||
* 1.0.4
|
||||
* 移除`关闭标题画面的演示场景加载`设置,因为在最近的更新中有较多bug。
|
||||
* 修复了一个bug,当教程指引被这个MOD隐藏时,它们不会被添加到教程面板。
|
||||
* 1.0.3
|
||||
* 增加设置项以关闭研究完成的提示/弹窗
|
||||
* 在README中增加了一个关于`关闭标题画面的演示场景加载`设置的兼容性说明
|
||||
* 1.0.2
|
||||
* 增加设置项以关闭标题画面的演示场景加载
|
||||
* 1.0.1
|
||||
* 可屏蔽右下面板的3种随机提醒
|
||||
* 1.0.0
|
||||
* 初始版本
|
||||
|
||||
</details>
|
||||
+34
-26
@@ -20,7 +20,7 @@ public class HideTips : BaseUnityPlugin
|
||||
private static bool _noResearchCompletionPopups = true;
|
||||
private static bool _noResearchCompletionTips;
|
||||
private static bool _skipPrologue = true;
|
||||
private static bool _hideMenuDemo;
|
||||
// private static bool _hideMenuDemo;
|
||||
|
||||
private static Harmony _patch;
|
||||
|
||||
@@ -34,13 +34,15 @@ public class HideTips : BaseUnityPlugin
|
||||
_noResearchCompletionPopups = Config.Bind("General", "NoResearchCompletionPopups", _noResearchCompletionPopups, "Disable Research Completion Popup Windows").Value;
|
||||
_noResearchCompletionTips = Config.Bind("General", "NoResearchCompletionTips", _noResearchCompletionTips, "Disable Research Completion Tips").Value;
|
||||
_skipPrologue = Config.Bind("General", "SkipPrologue", _skipPrologue, "Skip prologue for new game").Value;
|
||||
_hideMenuDemo = Config.Bind("General", "HideMenuDemo", _hideMenuDemo, "Disable title screen demo scene loading").Value;
|
||||
// _hideMenuDemo = Config.Bind("General", "HideMenuDemo", _hideMenuDemo, "Disable title screen demo scene loading").Value;
|
||||
if (!_cfgEnabled) return;
|
||||
Harmony.CreateAndPatchAll(typeof(HideTips));
|
||||
/*
|
||||
if (_hideMenuDemo)
|
||||
{
|
||||
_patch = Harmony.CreateAndPatchAll(typeof(HideMenuDemo));
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
@@ -48,7 +50,7 @@ public class HideTips : BaseUnityPlugin
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(VFPreload), nameof(VFPreload.Start))]
|
||||
private static void VFPreload_Start_Prefix(VFPreload __instance)
|
||||
@@ -57,7 +59,7 @@ public class HideTips : BaseUnityPlugin
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(UIBuildMenu), "_OnCreate")]
|
||||
[HarmonyPatch(typeof(UIBuildMenu), nameof(UIBuildMenu._OnCreate))]
|
||||
private static void ClearRandReminderTips(UIBuildMenu __instance)
|
||||
{
|
||||
if (!_noRandomReminderTips) return;
|
||||
@@ -68,48 +70,52 @@ public class HideTips : BaseUnityPlugin
|
||||
randTip._Free();
|
||||
}
|
||||
}
|
||||
|
||||
__instance.randRemindTips = Array.Empty<UIRandomTip>();
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(UIGameMenu), "_OnCreate")]
|
||||
[HarmonyPatch(typeof(UIGameMenu), nameof(UIGameMenu._OnCreate))]
|
||||
private static void UIGameMenu__OnCreate_Postfix(UIGameMenu __instance)
|
||||
{
|
||||
if (!_noRandomReminderTips) return;
|
||||
__instance.randTipButton0.pop = __instance.randTipButton0.popCount;
|
||||
__instance.randTipButton1.pop = __instance.randTipButton1.popCount;
|
||||
__instance.randTipButton2.pop = __instance.randTipButton2.popCount;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(UITutorialTip), "PopupTutorialTip")]
|
||||
private static bool UITutorialTip_PopupTutorialTip_Prefix()
|
||||
[HarmonyPatch(typeof(UITutorialTip), nameof(UITutorialTip.PopupTutorialTip))]
|
||||
private static bool UITutorialTip_PopupTutorialTip_Prefix(int tutorialId)
|
||||
{
|
||||
return !_noTutorialTips;
|
||||
if (!_noTutorialTips) return true;
|
||||
GameMain.history.UnlockTutorial(tutorialId);
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(UIVariousPopupGroup), "CreateAchievementPopupCard")]
|
||||
[HarmonyPatch(typeof(UIVariousPopupGroup), nameof(UIVariousPopupGroup.CreateAchievementPopupCard))]
|
||||
private static bool UIVariousPopupGroup_CreateAchievementPopupCard_Prefix()
|
||||
{
|
||||
return !_noAchievementCardPopups;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(UIVariousPopupGroup), "CreateMilestonePopupCard")]
|
||||
[HarmonyPatch(typeof(UIVariousPopupGroup), nameof(UIVariousPopupGroup.CreateMilestonePopupCard))]
|
||||
private static bool UIVariousPopupGroup_CreateMilestonePopupCard_Prefix()
|
||||
{
|
||||
return !_noMilestoneCardPopups;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(UIResearchResultWindow), "SetTechId")]
|
||||
[HarmonyPatch(typeof(UIResearchResultWindow), nameof(UIResearchResultWindow.SetTechId))]
|
||||
private static bool UIResearchResultWindow_SetTechId_Prefix()
|
||||
{
|
||||
return !_noResearchCompletionPopups;
|
||||
}
|
||||
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(UIGeneralTips), "OnTechUnlocked")]
|
||||
[HarmonyPatch(typeof(UIGeneralTips), nameof(UIGeneralTips.OnTechUnlocked))]
|
||||
private static IEnumerable<CodeInstruction> UIGeneralTips_OnTechUnlocked_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
@@ -132,7 +138,7 @@ public class HideTips : BaseUnityPlugin
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(DSPGame), "StartGame", typeof(GameDesc))]
|
||||
[HarmonyPatch(typeof(DSPGame), nameof(DSPGame.StartGame), typeof(GameDesc))]
|
||||
private static bool DSPGame_StartGame_Prefix(GameDesc _gameDesc)
|
||||
{
|
||||
if (!_skipPrologue) return true;
|
||||
@@ -141,11 +147,12 @@ public class HideTips : BaseUnityPlugin
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
[HarmonyPatch]
|
||||
class HideMenuDemo
|
||||
{
|
||||
[HarmonyPriority(Priority.First), HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(DSPGame), "StartDemoGame", typeof(int))]
|
||||
[HarmonyPatch(typeof(DSPGame), nameof(DSPGame.StartDemoGame), typeof(int))]
|
||||
private static bool DSPGame_StartDemoGame_Prefix()
|
||||
{
|
||||
if (DSPGame.Game != null)
|
||||
@@ -171,7 +178,7 @@ class HideMenuDemo
|
||||
GameMain.universeSimulator = UnityEngine.Object.Instantiate(Configs.builtin.universeSimulatorPrefab);
|
||||
GameMain.universeSimulator.spaceAudio = new GameObject("Space Audio")
|
||||
{
|
||||
transform =
|
||||
transform =
|
||||
{
|
||||
parent = GameMain.universeSimulator.transform
|
||||
}
|
||||
@@ -179,28 +186,28 @@ class HideMenuDemo
|
||||
GameMain.Begin();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
[HarmonyPriority(Priority.First), HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(VFPreload), "IsMenuDemoLoaded")]
|
||||
[HarmonyPatch(typeof(VFPreload), nameof(VFPreload.IsMenuDemoLoaded))]
|
||||
private static bool VFPreload_IsMenuDemoLoaded_Prefix(ref bool __result)
|
||||
{
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
[HarmonyPriority(Priority.First), HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(DSPGame), "LateUpdate")]
|
||||
[HarmonyPatch(typeof(GameMain), "LateUpdate")]
|
||||
[HarmonyPatch(typeof(GameMain), "FixedUpdate")]
|
||||
[HarmonyPatch(typeof(GameMain), "Update")]
|
||||
[HarmonyPatch(typeof(GameCamera), "LateUpdate")]
|
||||
[HarmonyPatch(typeof(DSPGame), nameof(DSPGame.LateUpdate))]
|
||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.LateUpdate))]
|
||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.FixedUpdate))]
|
||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.Update))]
|
||||
[HarmonyPatch(typeof(GameCamera), nameof(GameCamera.LateUpdate))]
|
||||
private static bool DSPGame_LateUpdate_Prefix()
|
||||
{
|
||||
return !DSPGame.IsMenuDemo;
|
||||
}
|
||||
|
||||
[HarmonyPriority(Priority.First), HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(GameMain), "Begin")]
|
||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.Begin))]
|
||||
private static bool GameMain_Begin_Prefix()
|
||||
{
|
||||
if (!DSPGame.IsMenuDemo) return true;
|
||||
@@ -208,4 +215,5 @@ class HideMenuDemo
|
||||
DSPGame.Game._running = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -6,7 +6,7 @@
|
||||
<AssemblyName>HideTips</AssemblyName>
|
||||
<BepInExPluginGuid>org.soardev.hidetips</BepInExPluginGuid>
|
||||
<Description>DSP MOD - HideTips</Description>
|
||||
<Version>1.0.3</Version>
|
||||
<Version>1.0.4</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<RestoreAdditionalProjectSources>https://nuget.bepinex.dev/v3/index.json</RestoreAdditionalProjectSources>
|
||||
@@ -15,15 +15,24 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BepInEx.Core" Version="5.*" />
|
||||
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
|
||||
<PackageReference Include="DysonSphereProgram.GameLibs" Version="*-r.*" />
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" />
|
||||
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UI">
|
||||
<HintPath>..\AssemblyFromGame\UnityEngine.UI.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
|
||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip
zip -9 -j package/$(ProjectName)-$(Version).zip $(TargetPath) package/icon.png package/manifest.json README.md" />
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
|
||||
<Exec Command="powershell Compress-Archive -Force -DestinationPath 'package/$(ProjectName)-$(Version).zip' -Path '$(TargetPath)', package/icon.png, package/manifest.json, README.md" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
||||
+11
-26
@@ -1,38 +1,23 @@
|
||||
# HideTips
|
||||
|
||||
#### Hide/Disable various tutorial tips/messages
|
||||
#### 隐藏/屏蔽各种引导提示/消息
|
||||
<details>
|
||||
<summary>Read me in English</summary>
|
||||
|
||||
## Changelog
|
||||
* 1.0.3
|
||||
+ Add config entries to disable research completion tips/popup windows
|
||||
+ Add a note to README for mod compatibility on `Disable title screen demo scene loading`.
|
||||
* 1.0.2
|
||||
+ Add a config entry to disable title screen demo scene loading
|
||||
* 1.0.1
|
||||
+ Hide 3 more random tutorial tips popup from bottom-right panel
|
||||
* 1.0.0
|
||||
+ Initial release
|
||||
***Hide/Disable various tutorial tips/messages***
|
||||
|
||||
## Usage
|
||||
* Tips/messages that can be hidden: random-reminder, tutorial, achievement/milestone card, research completion tips/popup windows.
|
||||
* Skip prologue for new game.
|
||||
* Disable title screen demo scene loading. Be note that this may conflict with some mods, disable this if you get any error popup on title screen.
|
||||
* Each type of tips/messages is configurable individually.
|
||||
|
||||
## 更新日志
|
||||
* 1.0.3
|
||||
+ 增加设置项以关闭研究完成的提示/弹窗
|
||||
+ 在README中增加了一个关于`关闭标题画面的演示场景加载`设置的兼容性说明
|
||||
* 1.0.2
|
||||
+ 增加设置项以关闭标题画面的演示场景加载
|
||||
* 1.0.1
|
||||
+ 可屏蔽右下面板的3种随机提醒
|
||||
* 1.0.0
|
||||
+ 初始版本
|
||||
***隐藏/屏蔽各种引导提示/消息***
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>中文读我</summary>
|
||||
|
||||
## 使用说明
|
||||
* 可以屏蔽的消息:随机提醒,教程,成就/里程碑卡片,研究完成的提示/弹窗。
|
||||
* 跳过新游戏引导动画。
|
||||
* 关闭标题画面的演示场景加载。注意这可能会和其他mod冲突,如果在标题画面出现错误弹窗请关闭这个设置。
|
||||
* 各种屏蔽功能都可以在配置文件里开关。
|
||||
|
||||
</details>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "HideTips",
|
||||
"version_number": "1.0.3",
|
||||
"version_number": "1.0.4",
|
||||
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/HideTips",
|
||||
"description": "Hide/Disable various tutorial tips/messages / 隐藏/屏蔽各种引导提示/消息",
|
||||
"dependencies": [
|
||||
|
||||
+67
-67
@@ -410,30 +410,30 @@ public static class LabOptPatchFunctions
|
||||
public static void SetFunctionInternal(ref LabComponent lab, bool researchMode, int recpId, int techId, SignData[] signPool, LabComponent[] labPool)
|
||||
{
|
||||
// LabOptPatch.Logger.LogDebug($"SetFunctionInternal: id={lab.id} root={(int)RootLabIdField.GetValue(lab)} research={researchMode} recp={recpId} tech={techId}");
|
||||
lab.replicating = false;
|
||||
lab.time = 0;
|
||||
lab.hashBytes = 0;
|
||||
lab.extraHashBytes = 0;
|
||||
lab.extraTime = 0;
|
||||
lab.extraSpeed = 0;
|
||||
lab.extraPowerRatio = 0;
|
||||
lab.productive = false;
|
||||
if (researchMode)
|
||||
{
|
||||
lab.forceAccMode = false;
|
||||
lab.researchMode = true;
|
||||
lab.recipeId = 0;
|
||||
lab.techId = 0;
|
||||
lab.timeSpend = 0;
|
||||
lab.extraTimeSpend = 0;
|
||||
lab.requires = null;
|
||||
lab.requireCounts = null;
|
||||
lab.served = null;
|
||||
lab.incServed = null;
|
||||
lab.products = null;
|
||||
lab.productCounts = null;
|
||||
lab.produced = null;
|
||||
lab.productive = true;
|
||||
lab.replicating = false;
|
||||
lab.time = 0;
|
||||
lab.hashBytes = 0;
|
||||
lab.extraHashBytes = 0;
|
||||
lab.extraTime = 0;
|
||||
lab.extraSpeed = 0;
|
||||
lab.extraPowerRatio = 0;
|
||||
lab.productive = false;
|
||||
if (researchMode)
|
||||
{
|
||||
lab.forceAccMode = false;
|
||||
lab.researchMode = true;
|
||||
lab.recipeId = 0;
|
||||
lab.techId = 0;
|
||||
lab.timeSpend = 0;
|
||||
lab.extraTimeSpend = 0;
|
||||
lab.requires = null;
|
||||
lab.requireCounts = null;
|
||||
lab.served = null;
|
||||
lab.incServed = null;
|
||||
lab.products = null;
|
||||
lab.productCounts = null;
|
||||
lab.produced = null;
|
||||
lab.productive = true;
|
||||
var rootLabId = lab.pcId;
|
||||
if (rootLabId > 0)
|
||||
{
|
||||
@@ -480,29 +480,29 @@ public static class LabOptPatchFunctions
|
||||
}
|
||||
}
|
||||
signPool[lab.entityId].iconId0 = (uint)lab.techId;
|
||||
signPool[lab.entityId].iconType = lab.techId == 0 ? 0U : 3U;
|
||||
return;
|
||||
}
|
||||
lab.researchMode = false;
|
||||
lab.recipeId = 0;
|
||||
lab.techId = 0;
|
||||
lab.matrixPoints = null;
|
||||
lab.matrixServed = null;
|
||||
lab.matrixIncServed = null;
|
||||
RecipeProto recipeProto = null;
|
||||
if (recpId > 0)
|
||||
{
|
||||
recipeProto = LDB.recipes.Select(recpId);
|
||||
}
|
||||
if (recipeProto != null && recipeProto.Type == ERecipeType.Research)
|
||||
{
|
||||
lab.recipeId = recipeProto.ID;
|
||||
lab.speed = 10000;
|
||||
lab.speedOverride = lab.speed;
|
||||
lab.timeSpend = recipeProto.TimeSpend * 10000;
|
||||
lab.extraTimeSpend = recipeProto.TimeSpend * 100000;
|
||||
lab.productive = recipeProto.productive;
|
||||
lab.forceAccMode &= lab.productive;
|
||||
signPool[lab.entityId].iconType = lab.techId == 0 ? 0U : 3U;
|
||||
return;
|
||||
}
|
||||
lab.researchMode = false;
|
||||
lab.recipeId = 0;
|
||||
lab.techId = 0;
|
||||
lab.matrixPoints = null;
|
||||
lab.matrixServed = null;
|
||||
lab.matrixIncServed = null;
|
||||
RecipeProto recipeProto = null;
|
||||
if (recpId > 0)
|
||||
{
|
||||
recipeProto = LDB.recipes.Select(recpId);
|
||||
}
|
||||
if (recipeProto != null && recipeProto.Type == ERecipeType.Research)
|
||||
{
|
||||
lab.recipeId = recipeProto.ID;
|
||||
lab.speed = 10000;
|
||||
lab.speedOverride = lab.speed;
|
||||
lab.timeSpend = recipeProto.TimeSpend * 10000;
|
||||
lab.extraTimeSpend = recipeProto.TimeSpend * 100000;
|
||||
lab.productive = recipeProto.productive;
|
||||
lab.forceAccMode &= lab.productive;
|
||||
var rootLabId = lab.pcId;
|
||||
if (rootLabId > 0)
|
||||
{
|
||||
@@ -544,26 +544,26 @@ public static class LabOptPatchFunctions
|
||||
Array.Clear(lab.produced, 0, lab.produced.Length);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lab.forceAccMode = false;
|
||||
lab.recipeId = 0;
|
||||
lab.speed = 0;
|
||||
lab.speedOverride = 0;
|
||||
lab.timeSpend = 0;
|
||||
lab.extraTimeSpend = 0;
|
||||
lab.requires = null;
|
||||
lab.requireCounts = null;
|
||||
lab.served = null;
|
||||
lab.incServed = null;
|
||||
lab.needs = null;
|
||||
lab.products = null;
|
||||
lab.productCounts = null;
|
||||
lab.produced = null;
|
||||
}
|
||||
signPool[lab.entityId].iconId0 = (uint)lab.recipeId;
|
||||
signPool[lab.entityId].iconType = lab.recipeId == 0 ? 0U : 2U;
|
||||
}
|
||||
else
|
||||
{
|
||||
lab.forceAccMode = false;
|
||||
lab.recipeId = 0;
|
||||
lab.speed = 0;
|
||||
lab.speedOverride = 0;
|
||||
lab.timeSpend = 0;
|
||||
lab.extraTimeSpend = 0;
|
||||
lab.requires = null;
|
||||
lab.requireCounts = null;
|
||||
lab.served = null;
|
||||
lab.incServed = null;
|
||||
lab.needs = null;
|
||||
lab.products = null;
|
||||
lab.productCounts = null;
|
||||
lab.produced = null;
|
||||
}
|
||||
signPool[lab.entityId].iconId0 = (uint)lab.recipeId;
|
||||
signPool[lab.entityId].iconType = lab.recipeId == 0 ? 0U : 2U;
|
||||
}
|
||||
|
||||
public static int InsertIntoLab(PlanetFactory factory, int labId, int itemId, byte itemCount, byte itemInc, ref byte remainInc, int[] needs)
|
||||
{
|
||||
|
||||
+3
-3
@@ -18,7 +18,7 @@ public class LabOptPatch : BaseUnityPlugin
|
||||
{
|
||||
Harmony.CreateAndPatchAll(typeof(LabOptPatch));
|
||||
}
|
||||
|
||||
|
||||
// Patch LabComponent.Export() to save zero value if rootLabId > 0.
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(LabComponent), nameof(LabComponent.Export))]
|
||||
@@ -274,7 +274,7 @@ public class LabOptPatch : BaseUnityPlugin
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
|
||||
// Change locks on PlanetFactory.InsertInto(), by calling LabOptPatchFunctions.InsertIntoLab()
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(PlanetFactory), nameof(PlanetFactory.InsertInto))]
|
||||
@@ -332,7 +332,7 @@ public class LabOptPatch : BaseUnityPlugin
|
||||
{
|
||||
LabOptPatchFunctions.SetRootId(ref __instance, 0);
|
||||
}
|
||||
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(LabOptPatchFunctions), nameof(LabOptPatchFunctions.SetRootId))]
|
||||
[HarmonyPatch(typeof(LabOptPatchFunctions), nameof(LabOptPatchFunctions.SetRootLabIdForStacking))]
|
||||
|
||||
+14
-5
@@ -15,15 +15,24 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BepInEx.Core" Version="5.*" />
|
||||
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
|
||||
<PackageReference Include="DysonSphereProgram.GameLibs" Version="*-r.*" />
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" />
|
||||
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UI">
|
||||
<HintPath>..\AssemblyFromGame\UnityEngine.UI.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
|
||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip
IF NOT EXIST package\plugins (mkdir package\plugins)
copy /y $(TargetPath) package\plugins\
zip -9 -j package/$(ProjectName)-$(Version).zip package/icon.png package/manifest.json README.md
cd package
zip -9 -r $(ProjectName)-$(Version).zip patchers plugins" />
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
|
||||
<Exec Command="IF NOT EXIST package\plugins (mkdir package\plugins)
copy /y $(TargetPath) package\plugins\
cd package
powershell Compress-Archive -Force -DestinationPath '$(ProjectName)-$(Version).zip' -Path patchers, plugins, icon.png, manifest.json, ../README.md" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace LabOptPreloader;
|
||||
|
||||
public static class Preloader
|
||||
{
|
||||
private static readonly ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource("LabOpt Preloader");
|
||||
private static readonly ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource("LabOpt Preloader");
|
||||
public static IEnumerable<string> TargetDLLs { get; } = new[] { "Assembly-CSharp.dll" };
|
||||
|
||||
public static void Patch(AssemblyDefinition assembly)
|
||||
|
||||
@@ -14,15 +14,24 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BepInEx.Core" Version="5.*" />
|
||||
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
|
||||
<PackageReference Include="DysonSphereProgram.GameLibs" Version="*-r.*" />
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" />
|
||||
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UI">
|
||||
<HintPath>..\AssemblyFromGame\UnityEngine.UI.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
|
||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
|
||||
<Exec Command="IF NOT EXIST ..\LabOpt\package\patchers (mkdir ..\LabOpt\package\patchers)
copy /y $(TargetPath) ..\LabOpt\package\patchers\" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
||||
@@ -15,11 +15,11 @@ public class LogisticMiner : BaseUnityPlugin
|
||||
|
||||
private static long _oreEnergyConsume = 2000000;
|
||||
private static long _oilEnergyConsume = 3600000;
|
||||
private static long _waterEnergyConsume = 20000000;
|
||||
private static int _waterSpeed = 100;
|
||||
private static long _waterEnergyConsume = 2000000;
|
||||
private static int _waterSpeed = 10;
|
||||
private static int _miningScale;
|
||||
private static int _fuelIlsSlot = 3;
|
||||
private static int _fuelPlsSlot = 2;
|
||||
private static int _fuelPlsSlot = 3;
|
||||
|
||||
private static float _frame;
|
||||
private static float _miningCostRateByTech;
|
||||
@@ -31,8 +31,8 @@ public class LogisticMiner : BaseUnityPlugin
|
||||
private static uint _miningCostBarrierOil;
|
||||
|
||||
private static uint _seed = (uint)Random.Range(int.MinValue, int.MaxValue);
|
||||
private static readonly Dictionary<int, VeinCacheData> PlanetVeinCacheData = new();
|
||||
private static readonly Dictionary<int, (long, bool)> Fuels = new();
|
||||
private static readonly Dictionary<int, VeinCacheData> PlanetVeinCacheData = [];
|
||||
private static readonly Dictionary<int, (long, bool)> Fuels = [];
|
||||
|
||||
private bool _cfgEnabled = true;
|
||||
|
||||
@@ -52,11 +52,11 @@ public class LogisticMiner : BaseUnityPlugin
|
||||
.Value;
|
||||
_fuelIlsSlot = Config.Bind("General", "ILSFuelSlot", _fuelIlsSlot + 1,
|
||||
new ConfigDescription("Fuel slot for ILS, set to 0 to disable",
|
||||
new AcceptableValueRange<int>(0, 5), Array.Empty<object>()))
|
||||
new AcceptableValueRange<int>(0, 5), []))
|
||||
.Value - 1;
|
||||
_fuelPlsSlot = Config.Bind("General", "PLSFuelSlot", _fuelPlsSlot + 1,
|
||||
new ConfigDescription("Fuel slot for PLS, set to 0 to disable",
|
||||
new AcceptableValueRange<int>(0, 4), Array.Empty<object>()))
|
||||
new AcceptableValueRange<int>(0, 4), []))
|
||||
.Value - 1;
|
||||
if (!_cfgEnabled) return;
|
||||
|
||||
@@ -98,8 +98,8 @@ public class LogisticMiner : BaseUnityPlugin
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(DSPGame), "StartGame", typeof(GameDesc))]
|
||||
[HarmonyPatch(typeof(DSPGame), "StartGame", typeof(string))]
|
||||
[HarmonyPatch(typeof(DSPGame), nameof(DSPGame.StartGame), typeof(GameDesc))]
|
||||
[HarmonyPatch(typeof(DSPGame), nameof(DSPGame.StartGame), typeof(string))]
|
||||
private static void OnGameStart()
|
||||
{
|
||||
Logger.LogInfo("Game Start");
|
||||
@@ -119,7 +119,7 @@ public class LogisticMiner : BaseUnityPlugin
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GameMain), "Start")]
|
||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.Start))]
|
||||
private static void OnGameLoaded()
|
||||
{
|
||||
_frame = 0f;
|
||||
@@ -130,7 +130,7 @@ public class LogisticMiner : BaseUnityPlugin
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GameHistoryData), "UnlockTechFunction")]
|
||||
[HarmonyPatch(typeof(GameHistoryData), nameof(GameHistoryData.UnlockTechFunction))]
|
||||
private static void OnUnlockTech(int func)
|
||||
{
|
||||
switch (func)
|
||||
@@ -145,7 +145,7 @@ public class LogisticMiner : BaseUnityPlugin
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GameData), "GameTick")]
|
||||
[HarmonyPatch(typeof(GameLogic), nameof(GameLogic.OnFactoryFrameBegin))]
|
||||
private static void FrameTick()
|
||||
{
|
||||
var main = GameMain.instance;
|
||||
@@ -165,7 +165,7 @@ public class LogisticMiner : BaseUnityPlugin
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GameHistoryData), "UnlockRecipe")]
|
||||
[HarmonyPatch(typeof(GameHistoryData), nameof(GameHistoryData.UnlockRecipe))]
|
||||
private static void OnUnlockRecipe(int recipeId)
|
||||
{
|
||||
if (recipeId == 119)
|
||||
@@ -175,9 +175,9 @@ public class LogisticMiner : BaseUnityPlugin
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlanetFactory), "Init")]
|
||||
[HarmonyPatch(typeof(PlanetFactory), "RecalculateVeinGroup")]
|
||||
[HarmonyPatch(typeof(PlanetFactory), "RecalculateAllVeinGroups")]
|
||||
[HarmonyPatch(typeof(PlanetFactory), nameof(PlanetFactory.Init))]
|
||||
[HarmonyPatch(typeof(PlanetFactory), nameof(PlanetFactory.RecalculateVeinGroup))]
|
||||
[HarmonyPatch(typeof(PlanetFactory), nameof(PlanetFactory.RecalculateAllVeinGroups))]
|
||||
private static void NeedRecalcVeins(PlanetFactory __instance)
|
||||
{
|
||||
RecalcVeins(__instance);
|
||||
@@ -204,13 +204,12 @@ public class LogisticMiner : BaseUnityPlugin
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(FactorySystem), "CheckBeforeGameTick")]
|
||||
private static void FactorySystemLogisticMiner(FactorySystem __instance)
|
||||
[HarmonyPatch(typeof(PlanetFactory), nameof(PlanetFactory.BeforeGameTick))]
|
||||
private static void FactorySystemLogisticMiner(PlanetFactory __instance)
|
||||
{
|
||||
if (_miningSpeedScaleLong <= 0)
|
||||
return;
|
||||
var factory = __instance.factory;
|
||||
var planetId = factory.planetId;
|
||||
var planetId = __instance.planetId;
|
||||
lock (PlanetVeinCacheData)
|
||||
{
|
||||
if (PlanetVeinCacheData.TryGetValue(planetId, out var vcd))
|
||||
@@ -227,11 +226,11 @@ public class LogisticMiner : BaseUnityPlugin
|
||||
return;
|
||||
}
|
||||
|
||||
var planetTransport = __instance.planet.factory.transport;
|
||||
var planetTransport = __instance.transport;
|
||||
var factoryProductionStat =
|
||||
GameMain.statistics.production.factoryStatPool[__instance.factory.index];
|
||||
GameMain.statistics.production.factoryStatPool[__instance.index];
|
||||
var productRegister = factoryProductionStat?.productRegister;
|
||||
PerformanceMonitor.BeginSample(ECpuWorkEntry.Miner);
|
||||
DeepProfiler.BeginSample(DPEntry.Miner);
|
||||
do
|
||||
{
|
||||
for (var j = 1; j < planetTransport.stationCursor; j++)
|
||||
@@ -271,7 +270,7 @@ public class LogisticMiner : BaseUnityPlugin
|
||||
|
||||
if (isVein)
|
||||
{
|
||||
(amount, energyConsume) = vcd.Mine(factory, stationStore.itemId, miningScale,
|
||||
(amount, energyConsume) = vcd.Mine(__instance, stationStore.itemId, miningScale,
|
||||
_miningSpeedScaleLong,
|
||||
stationComponent.energy);
|
||||
if (amount < 0)
|
||||
@@ -334,7 +333,7 @@ public class LogisticMiner : BaseUnityPlugin
|
||||
vcd.FrameNext += _miningFrames;
|
||||
} while (vcd.FrameNext <= _frame);
|
||||
|
||||
PerformanceMonitor.EndSample(ECpuWorkEntry.Miner);
|
||||
DeepProfiler.EndSample(DPEntry.Miner);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,7 +342,7 @@ public class LogisticMiner : BaseUnityPlugin
|
||||
public float FrameNext;
|
||||
|
||||
/* stores list of indices to veinData, with an extra INT which indicates cout of veinGroups at last */
|
||||
private Dictionary<int, List<int>> _veins = new();
|
||||
private Dictionary<int, List<int>> _veins = [];
|
||||
private int _mineIndex = -1;
|
||||
|
||||
public bool HasVein(int productId)
|
||||
@@ -353,9 +352,9 @@ public class LogisticMiner : BaseUnityPlugin
|
||||
|
||||
public void GenVeins(PlanetFactory factory)
|
||||
{
|
||||
_veins = new Dictionary<int, List<int>>();
|
||||
_veins = [];
|
||||
var veinPool = factory.veinPool;
|
||||
var vg = new Dictionary<int, HashSet<int>>();
|
||||
Dictionary<int, HashSet<int>> vg = [];
|
||||
for (var i = 0; i < veinPool.Length; i++)
|
||||
{
|
||||
if (veinPool[i].amount <= 0 || veinPool[i].type == EVeinType.None) continue;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<AssemblyName>LogisticMiner</AssemblyName>
|
||||
<BepInExPluginGuid>org.soardev.logisticminer</BepInExPluginGuid>
|
||||
<Description>DSP MOD - LogisticMiner</Description>
|
||||
<Version>0.1.0</Version>
|
||||
<Version>0.2.0</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<RestoreAdditionalProjectSources>https://nuget.bepinex.dev/v3/index.json</RestoreAdditionalProjectSources>
|
||||
@@ -15,8 +15,17 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BepInEx.Core" Version="5.*" />
|
||||
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
|
||||
<PackageReference Include="DysonSphereProgram.GameLibs" Version="*-r.*" />
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" />
|
||||
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UI">
|
||||
<HintPath>..\AssemblyFromGame\UnityEngine.UI.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
reaches Advanced Mining Machine, otherwise 100.
|
||||
* 100/s for water by default.
|
||||
* Energy costs: 1MW/vein-group & 10MW/water-slot & 1.8MW/oil-seep(configurable)
|
||||
* Fuels burning slot. Default: 4th for ILS, 3rd for PLS. Set to 0 to disable it.
|
||||
* Fuels burning slot. Default: 4th for ILS, 4th for PLS. Set to 0 to disable it.
|
||||
|
||||
## 使用说明
|
||||
|
||||
@@ -47,4 +47,4 @@
|
||||
倍率可以设置为0(默认),此时倍率会随科技解锁而变化,默认是100%,解锁高级采矿机后变为300%。
|
||||
* 水的采集速度默认为100/s。
|
||||
* 能耗:每矿物组 1MW,单格水 10MW,每油井 1.8MW。
|
||||
* 燃料格位置。默认:星际物流塔第4格,行星内物流塔第3格。设为0则关闭燃料补充能量功能。
|
||||
* 燃料格位置。默认:星际物流塔第4格,行星内物流塔第4格。设为0则关闭燃料补充能量功能。
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "LogisticMiner",
|
||||
"version_number": "0.1.0",
|
||||
"version_number": "0.2.0",
|
||||
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/LogisticMiner",
|
||||
"description": "Logistic Storages can mine all ores/water on current planet / 物流塔可以采集当前星球的全部矿产(以及水)",
|
||||
"dependencies": [
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
## Changlog
|
||||
* 1.0.0
|
||||
+ Initial release
|
||||
|
||||
## 更新日志
|
||||
* 1.0.0
|
||||
+ 初始版本
|
||||
@@ -0,0 +1,287 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using BepInEx;
|
||||
using BepInEx.Logging;
|
||||
using HarmonyLib;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLua;
|
||||
using OBSWebsocketDotNet;
|
||||
|
||||
namespace LuaScriptEngine;
|
||||
|
||||
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
|
||||
public class LuaScriptEngine : BaseUnityPlugin
|
||||
{
|
||||
private readonly OBSWebsocket _obs = new();
|
||||
private readonly Dictionary<string, string> _scheduledText = [];
|
||||
|
||||
private class Timer(LuaFunction func, long startInterval, long repeatInterval = 0L)
|
||||
{
|
||||
public bool Check(long gameTick)
|
||||
{
|
||||
if (gameTick < _nextTick) return false;
|
||||
try
|
||||
{
|
||||
_func.Call();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError($"Error in Lua script: {e}");
|
||||
}
|
||||
|
||||
if (_repeatInterval <= 0L) return true;
|
||||
_nextTick += _repeatInterval;
|
||||
if (_nextTick < gameTick)
|
||||
_nextTick = gameTick + 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Reset(long gameTick)
|
||||
{
|
||||
if (_repeatInterval <= 0L) return true;
|
||||
_nextTick = gameTick + _repeatInterval;
|
||||
return false;
|
||||
}
|
||||
|
||||
private readonly LuaFunction _func = func;
|
||||
private readonly long _repeatInterval = repeatInterval;
|
||||
private long _nextTick = GameMain.gameTick + startInterval;
|
||||
}
|
||||
|
||||
public new static readonly ManualLogSource Logger =
|
||||
BepInEx.Logging.Logger.CreateLogSource(PluginInfo.PLUGIN_NAME);
|
||||
|
||||
private Harmony _harmony;
|
||||
|
||||
private static readonly Lua LuaState = new();
|
||||
private static readonly List<LuaFunction> PostDataLoadedFuncs = [];
|
||||
private static readonly List<LuaFunction> PreUpdateFuncs = [];
|
||||
private static readonly List<LuaFunction> PostUpdateFuncs = [];
|
||||
private static readonly List<LuaFunction> PreGameBeginFuncs = [];
|
||||
private static readonly List<LuaFunction> PostGameBeginFuncs = [];
|
||||
private static readonly List<LuaFunction> PreGameEndFuncs = [];
|
||||
private static readonly List<LuaFunction> PostGameEndFuncs = [];
|
||||
private static readonly HashSet<Timer> Timers = [];
|
||||
private static readonly List<Timer> TimersToRemove = [];
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
LuaState.State.Encoding = Encoding.UTF8;
|
||||
LuaState.LoadCLRPackage();
|
||||
LuaState.DoString("import('Assembly-CSharp')");
|
||||
LuaState["register_callback"] = (string tp, LuaFunction action) =>
|
||||
{
|
||||
switch (tp)
|
||||
{
|
||||
case "data_loaded":
|
||||
PostDataLoadedFuncs.Add(action);
|
||||
break;
|
||||
case "pre_update":
|
||||
PreUpdateFuncs.Add(action);
|
||||
break;
|
||||
case "post_update":
|
||||
PostUpdateFuncs.Add(action);
|
||||
break;
|
||||
case "pre_game_begin":
|
||||
PreGameBeginFuncs.Add(action);
|
||||
break;
|
||||
case "post_game_begin":
|
||||
PostGameBeginFuncs.Add(action);
|
||||
break;
|
||||
case "pre_game_end":
|
||||
PreGameEndFuncs.Add(action);
|
||||
break;
|
||||
case "post_game_end":
|
||||
PostGameEndFuncs.Add(action);
|
||||
break;
|
||||
}
|
||||
};
|
||||
LuaState["add_timer"] = Timer (LuaFunction func, long firstInterval, long repeatInterval) =>
|
||||
{
|
||||
var timer = new Timer(func, firstInterval, repeatInterval);
|
||||
Timers.Add(timer);
|
||||
return timer;
|
||||
};
|
||||
LuaState["remove_timer"] = void (Timer timer) => { Timers.Remove(timer); };
|
||||
LuaState["obs_connect"] = void (string server, string password) =>
|
||||
{
|
||||
_obs.Connected += (_, _) =>
|
||||
{
|
||||
Logger.LogDebug("Connected to OBS");
|
||||
foreach (var (sourceName, text) in _scheduledText)
|
||||
{
|
||||
_obs.SetInputSettings(sourceName,
|
||||
new JObject
|
||||
{
|
||||
{ "text", text }
|
||||
});
|
||||
}
|
||||
|
||||
_scheduledText.Clear();
|
||||
};
|
||||
_obs.Disconnected += (_, _) =>
|
||||
{
|
||||
Logger.LogDebug("Disconnected from OBS");
|
||||
_obs.ConnectAsync(server, password);
|
||||
};
|
||||
_obs.ConnectAsync(server, password);
|
||||
};
|
||||
LuaState["obs_set_source_text"] = void (string sourceName, string text) =>
|
||||
{
|
||||
if (_obs.IsConnected)
|
||||
{
|
||||
try
|
||||
{
|
||||
_obs.SetInputSettings(sourceName, new JObject
|
||||
{
|
||||
{ "text", text }
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError($"Error setting source text: {e}");
|
||||
_obs.Disconnect();
|
||||
_scheduledText[sourceName] = text;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_scheduledText[sourceName] = text;
|
||||
}
|
||||
};
|
||||
var assemblyPath = System.IO.Path.Combine(
|
||||
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)!,
|
||||
"scripts"
|
||||
);
|
||||
LuaState.DoString($"package.path = '{assemblyPath.Replace('\\', '/')}/?.lua'");
|
||||
|
||||
foreach (var file in System.IO.Directory.GetFiles(assemblyPath, "*.lua"))
|
||||
{
|
||||
Logger.LogInfo($"Loading Lua script: {file}");
|
||||
LuaState.DoFile(file);
|
||||
}
|
||||
|
||||
_harmony = Harmony.CreateAndPatchAll(typeof(Patches));
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
Timers.Clear();
|
||||
PreUpdateFuncs.Clear();
|
||||
PostUpdateFuncs.Clear();
|
||||
PreGameBeginFuncs.Clear();
|
||||
PostGameBeginFuncs.Clear();
|
||||
PreGameEndFuncs.Clear();
|
||||
PostGameEndFuncs.Clear();
|
||||
|
||||
_harmony?.UnpatchSelf();
|
||||
LuaState.Dispose();
|
||||
}
|
||||
|
||||
private static class Patches
|
||||
{
|
||||
private static void LoopCall(List<LuaFunction> funcs)
|
||||
{
|
||||
foreach (var func in funcs)
|
||||
{
|
||||
try
|
||||
{
|
||||
func.Call();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError($"Error in Lua script: {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(VFPreload), nameof(VFPreload.InvokeOnLoadWorkEnded))]
|
||||
private static void VFPreload_InvokeOnLoadWorkEnded_Postfix()
|
||||
{
|
||||
LoopCall(PostDataLoadedFuncs);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.FixedUpdate))]
|
||||
private static void GameMain_FixedUpdate_Prefix()
|
||||
{
|
||||
if (Timers.Count > 0)
|
||||
{
|
||||
var gameTick = GameMain.gameTick;
|
||||
foreach (var timer in Timers)
|
||||
{
|
||||
if (timer == null || !timer.Check(gameTick)) continue;
|
||||
TimersToRemove.Add(timer);
|
||||
}
|
||||
|
||||
if (TimersToRemove.Count > 0)
|
||||
{
|
||||
foreach (var timer in TimersToRemove)
|
||||
{
|
||||
Timers.Remove(timer);
|
||||
}
|
||||
|
||||
TimersToRemove.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
LoopCall(PreUpdateFuncs);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.FixedUpdate))]
|
||||
private static void GameMain_FixedUpdate_Postfix()
|
||||
{
|
||||
LoopCall(PostUpdateFuncs);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.Begin))]
|
||||
private static void GameMain_Begin_Prefix()
|
||||
{
|
||||
var tick = GameMain.gameTick;
|
||||
foreach (var timer in Timers)
|
||||
{
|
||||
if (timer.Reset(tick))
|
||||
{
|
||||
TimersToRemove.Add(timer);
|
||||
}
|
||||
}
|
||||
|
||||
if (TimersToRemove.Count > 0)
|
||||
{
|
||||
foreach (var timer in TimersToRemove)
|
||||
{
|
||||
Timers.Remove(timer);
|
||||
}
|
||||
|
||||
TimersToRemove.Clear();
|
||||
}
|
||||
|
||||
LoopCall(PreGameBeginFuncs);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.Begin))]
|
||||
private static void GameMain_Begin_Postfix()
|
||||
{
|
||||
LoopCall(PostGameBeginFuncs);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.End))]
|
||||
private static void GameMain_End_Prefix()
|
||||
{
|
||||
LoopCall(PreGameEndFuncs);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.End))]
|
||||
private static void GameMain_End_Postfix()
|
||||
{
|
||||
LoopCall(PostGameEndFuncs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<AssemblyName>LuaScriptEngine</AssemblyName>
|
||||
<BepInExPluginGuid>org.soardev.luascriptengine</BepInExPluginGuid>
|
||||
<Description>DSP MOD - LuaScriptEngine</Description>
|
||||
<Version>1.0.0</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
|
||||
<RestoreAdditionalProjectSources>https://nuget.bepinex.dev/v3/index.json</RestoreAdditionalProjectSources>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NLua" Version="1.*" />
|
||||
<PackageReference Include="BepInEx.Core" Version="5.*" />
|
||||
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
|
||||
<PackageReference Include="obs-websocket-dotnet" Version="5.*" />
|
||||
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="*-r.*" /> -->
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UI">
|
||||
<HintPath>..\AssemblyFromGame\UnityEngine.UI.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
|
||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,8 @@
|
||||
# LuaScriptEngine
|
||||
|
||||
#### Write mod functions in lua scripts
|
||||
#### 用lua脚本编写mod功能
|
||||
|
||||
## Usage
|
||||
|
||||
## 使用说明
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "LuaScriptEngine",
|
||||
"version_number": "1.0.0",
|
||||
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/LuaScriptEngine",
|
||||
"description": "Write mod functions in lua scripts / 用lua脚本编写mod功能",
|
||||
"dependencies": [
|
||||
"xiaoye97-BepInEx-5.4.17"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<details>
|
||||
<summary>Read me in English</summary>
|
||||
|
||||
## Changelog
|
||||
|
||||
* 1.1.4
|
||||
* Fixed support for game version 0.10.29
|
||||
|
||||
* 1.1.3
|
||||
* Support for game version 0.10.28.20759+
|
||||
* Fixed a minor bug that `RemoveSpeedLimitForStage1` not working while `UseFixedSpeed` set to false and `SpeedMultiplier` set to 1
|
||||
|
||||
* 1.1.2
|
||||
* `RemoveBuildRangeLimit`, `LargerAreaForUpgradeAndDismantle` and `LargerAreaForTerraform` are moved to [UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist)
|
||||
|
||||
* 1.1.1
|
||||
* Fixed crash in `LargeAreaForTerraform` functions.
|
||||
|
||||
* 1.1.0
|
||||
* Added `RemoveBuildRangeLimit`, `LargerAreaForUpgradeAndDismantle` and `LargerAreaForTerraform` options (Check Usage for details).
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>中文读我</summary>
|
||||
|
||||
## 更新日志
|
||||
|
||||
* 1.1.4
|
||||
* 修复了对游戏版本0.10.29的支持
|
||||
|
||||
* 1.1.3
|
||||
* 支持游戏版本0.10.28.20759+
|
||||
* 修复了当`UseFixedSpeed`设置为false且`SpeedMultiplier`设置为1时`RemoveSpeedLimitForStage1`无效的问题
|
||||
|
||||
* 1.1.2
|
||||
* `RemoveBuildRangeLimit`, `LargerAreaForUpgradeAndDismantle` 和 `LargerAreaForTerraform` 移动到了 MOD [UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist) 中
|
||||
|
||||
* 1.1.1
|
||||
* 修复了 `LargeAreaForTerraform` 功能可能导致崩溃的问题。
|
||||
|
||||
* 1.1.0
|
||||
* 添加了 `RemoveBuildRangeLimit`, `LargerAreaForUpgradeAndDismantle` 和 `LargerAreaForTerraform` 选项 (详情见使用说明)。
|
||||
|
||||
</details>
|
||||
@@ -73,7 +73,6 @@ public static class MechaDronesTweaks
|
||||
public static float EnergyMultiplier = 0.1f;
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(ConstructionModuleComponent), nameof(ConstructionModuleComponent.SearchForNewTargets))]
|
||||
[HarmonyPatch(typeof(ConstructionSystem), nameof(ConstructionSystem.UpdateDrones))]
|
||||
[HarmonyPatch(typeof(UIMechaWindow), nameof(UIMechaWindow.UpdateProps))]
|
||||
[HarmonyPatch(typeof(UITechTree), nameof(UITechTree.RefreshDataValueText))]
|
||||
@@ -112,7 +111,7 @@ public static class MechaDronesTweaks
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldc_I4_1),
|
||||
new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(DroneComponent), nameof(DroneComponent.stage)))
|
||||
).Operand = 2;
|
||||
).Opcode = OpCodes.Ldc_I4_2;
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
@@ -191,4 +190,4 @@ public static class MechaDronesTweaks
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<AssemblyName>MechaDronesTweaks</AssemblyName>
|
||||
<BepInExPluginGuid>org.soardev.mechadronestweaks</BepInExPluginGuid>
|
||||
<Description>DSP MOD - MechaDronesTweaks</Description>
|
||||
<Version>1.1.3</Version>
|
||||
<Version>1.1.4</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<RestoreAdditionalProjectSources>https://nuget.bepinex.dev/v3/index.json</RestoreAdditionalProjectSources>
|
||||
@@ -15,15 +15,24 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BepInEx.Core" Version="5.*" />
|
||||
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
|
||||
<PackageReference Include="DysonSphereProgram.GameLibs" Version="*-r.*" />
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" />
|
||||
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UI">
|
||||
<HintPath>..\AssemblyFromGame\UnityEngine.UI.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
|
||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip
zip -9 -j package/$(ProjectName)-$(Version).zip $(TargetPath) package/icon.png package/manifest.json README.md" />
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
|
||||
<Exec Command="powershell Compress-Archive -Force -DestinationPath 'package/$(ProjectName)-$(Version).zip' -Path '$(TargetPath)', package/icon.png, package/manifest.json, README.md" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
||||
+21
-18
@@ -1,23 +1,30 @@
|
||||
# MechaDronesTweaks
|
||||
|
||||
#### Some tweaks for mecha drones(Successor to FastDrones MOD)
|
||||
#### 机甲建设机调整(FastDrones MOD的后继者)
|
||||
<details>
|
||||
<summary>Read me in English</summary>
|
||||
|
||||
***Some tweaks for mecha drones(Successor to FastDrones MOD)***
|
||||
|
||||
## Updates
|
||||
|
||||
* 1.1.4
|
||||
* Fixed support for game version 0.10.29
|
||||
|
||||
* 1.1.3
|
||||
+ Support for game version 0.10.28.20759+
|
||||
+ Fixed a minor bug that `RemoveSpeedLimitForStage1` not working while `UseFixedSpeed` set to false and `SpeedMultiplier` set to 1
|
||||
* Support for game version 0.10.28.20759+
|
||||
* Fixed a minor bug that `RemoveSpeedLimitForStage1` not working while `UseFixedSpeed` set to false and `SpeedMultiplier` set to 1
|
||||
|
||||
* 1.1.2
|
||||
+ `RemoveBuildRangeLimit`, `LargerAreaForUpgradeAndDismantle` and `LargerAreaForTerraform` are moved to [UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist)
|
||||
* `RemoveBuildRangeLimit`, `LargerAreaForUpgradeAndDismantle` and `LargerAreaForTerraform` are moved to [UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist)
|
||||
|
||||
* 1.1.1
|
||||
+ Fixed crash in `LargeAreaForTerraform` functions.
|
||||
* Fixed crash in `LargeAreaForTerraform` functions.
|
||||
|
||||
* 1.1.0
|
||||
+ Added `RemoveBuildRangeLimit`, `LargerAreaForUpgradeAndDismantle` and `LargerAreaForTerraform` options (Check Usage for details).
|
||||
* Added `RemoveBuildRangeLimit`, `LargerAreaForUpgradeAndDismantle` and `LargerAreaForTerraform` options (Check Usage for details).
|
||||
|
||||
## Usage
|
||||
|
||||
* Inspired by [FastDrones](https://dsp.thunderstore.io/package/dkoppstein/FastDrones/), but patching IL codes, consuming less CPU to reduce lags on massive builds especially blueprints' put.
|
||||
* Does not affect current game-saves, which means:
|
||||
* All values are patched in memory but written to game-saves so that you can play with normal mecha drone parameters while disabling this MOD.
|
||||
@@ -34,21 +41,15 @@
|
||||
* `EnergyMultiplier` [Default Value: 0.1]: Energy consumption multiplier for mecha drones.
|
||||
* Note: This MOD will disable `FastDrones` if the MOD is installed, to avoid conflict in functions.
|
||||
|
||||
## 更新日志
|
||||
* 1.1.3
|
||||
+ 支持游戏版本0.10.28.20759+
|
||||
+ 修复了当`UseFixedSpeed`设置为false且`SpeedMultiplier`设置为1时`RemoveSpeedLimitForStage1`无效的问题
|
||||
</details>
|
||||
|
||||
* 1.1.2
|
||||
+ `RemoveBuildRangeLimit`, `LargerAreaForUpgradeAndDismantle` 和 `LargerAreaForTerraform` 移动到了 MOD [UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist) 中
|
||||
<details>
|
||||
<summary>中文读我</summary>
|
||||
|
||||
* 1.1.1
|
||||
+ 修复了 `LargeAreaForTerraform` 功能可能导致崩溃的问题。
|
||||
|
||||
* 1.1.0
|
||||
+ 添加了 `RemoveBuildRangeLimit`, `LargerAreaForUpgradeAndDismantle` 和 `LargerAreaForTerraform` 选项 (详情见使用说明)。
|
||||
***机甲建设机调整(FastDrones MOD的后继者)***
|
||||
|
||||
## 使用说明
|
||||
|
||||
* 功能参考 [FastDrones](https://dsp.thunderstore.io/package/dkoppstein/FastDrones/),但主要对IL代码进行Patch因此消耗更少的CPU,尤其在大规模建造比如放置蓝图的时候可以大大减少卡顿。
|
||||
* 不影响当前游戏存档:
|
||||
* 所有修改参数都在内存中Patch不会写入存档,禁用此MOD后可恢复正常建设机参数。
|
||||
@@ -64,3 +65,5 @@
|
||||
* `SpeedMultiplier` [默认值: 4]: 速度倍数。
|
||||
* `EnergyMultiplier` [默认值: 0.1]: 能量消耗倍数。
|
||||
* 说明: 如果安装了`FastDrones`本MOD会将其禁用避免功能冲突。
|
||||
|
||||
</details>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "MechaDronesTweaks",
|
||||
"version_number": "1.1.3",
|
||||
"version_number": "1.1.4",
|
||||
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/MechaDronesTweaks",
|
||||
"description": "Some tweaks for mecha drones and build functions(Successor to FastDrones MOD) / 机甲建设机和建设功能调整(FastDrones MOD的后继者)",
|
||||
"dependencies": [
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<AssemblyName>OCBatchBuild</AssemblyName>
|
||||
<BepInExPluginGuid>org.soardev.ocbatchbuild</BepInExPluginGuid>
|
||||
<Description>DSP MOD - OCBatchBuild</Description>
|
||||
<Version>1.2.0</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<RestoreAdditionalProjectSources>https://nuget.bepinex.dev/v3/index.json</RestoreAdditionalProjectSources>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BepInEx.Core" Version="5.*" />
|
||||
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
|
||||
<PackageReference Include="DysonSphereProgram.GameLibs" Version="*-r.*" />
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
|
||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip
zip -9 -j package/$(ProjectName)-$(Version).zip $(TargetPath) package/icon.png package/manifest.json README.md" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -1,129 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using BepInEx;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace OCBatchBuild;
|
||||
|
||||
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
|
||||
public class OrbitalCollectorBatchBuild : BaseUnityPlugin
|
||||
{
|
||||
private new static readonly BepInEx.Logging.ManualLogSource Logger =
|
||||
BepInEx.Logging.Logger.CreateLogSource(PluginInfo.PLUGIN_NAME);
|
||||
|
||||
private bool _cfgEnabled = true;
|
||||
private static int _maxBuildCount;
|
||||
private static bool _instantBuild;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_cfgEnabled = Config.Bind("General", "Enabled", _cfgEnabled, "enable/disable this plugin").Value;
|
||||
_maxBuildCount = Config.Bind("General", "MaxBuildCount", _maxBuildCount, "Maximum Orbital Collectors to build once, set to 0 to build as many as possible").Value;
|
||||
_instantBuild = Config.Bind("General", "InstantBuild", _instantBuild, "Enable to make Orbital Collectors built instantly. This is thought to be game logic breaking.").Value;
|
||||
Harmony.CreateAndPatchAll(typeof(OrbitalCollectorBatchBuild));
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(BuildTool_Click), "CreatePrebuilds")]
|
||||
private static void CreatePrebuilds(BuildTool_Click __instance)
|
||||
{
|
||||
/* Check Gas Planet */
|
||||
if (__instance.planet.type != EPlanetType.Gas) return;
|
||||
if (__instance.buildPreviews.Count == 0) return;
|
||||
|
||||
var buildPreview = __instance.buildPreviews[0];
|
||||
/* Check if is collector station */
|
||||
if (!buildPreview.desc.isCollectStation) return;
|
||||
|
||||
var factory = __instance.factory;
|
||||
var stationPool = factory.transport.stationPool;
|
||||
var entityPool = factory.entityPool;
|
||||
var stationCursor = factory.transport.stationCursor;
|
||||
var pos = buildPreview.lpos;
|
||||
var pos2 = buildPreview.lpos2;
|
||||
var itemId = buildPreview.item.ID;
|
||||
var countToBuild = _maxBuildCount - 1;
|
||||
if (countToBuild == 0) return;
|
||||
var prebuilds = new List<int> {-buildPreview.objId};
|
||||
var player = __instance.player;
|
||||
var firstPos = pos;
|
||||
var cellCount = PlanetGrid.DetermineLongitudeSegmentCount(0, factory.planet.aux.mainGrid.segment) * 5;
|
||||
var cellRad = Math.PI / cellCount;
|
||||
var distRadCount = 0;
|
||||
for (var i = 1; i <= cellCount; i++)
|
||||
{
|
||||
pos = Maths.RotateLF(0.0, 1.0, 0.0, cellRad, pos);
|
||||
if ((firstPos - pos).sqrMagnitude < 14297f) continue;
|
||||
distRadCount = i;
|
||||
break;
|
||||
}
|
||||
|
||||
if (distRadCount == 0) return;
|
||||
pos = firstPos;
|
||||
/* rotate for a minimal distance for next OC on sphere */
|
||||
pos = Maths.RotateLF(0.0, 1.0, 0.0, cellRad * distRadCount, pos);
|
||||
pos2 = Maths.RotateLF(0.0, 1.0, 0.0, cellRad * distRadCount, pos2);
|
||||
for (var i = distRadCount; i < cellCount && countToBuild != 0;)
|
||||
{
|
||||
/* Check for collision */
|
||||
var collide = false;
|
||||
for (var j = 1; j < stationCursor; j++)
|
||||
{
|
||||
if (stationPool[j] == null || stationPool[j].id != j) continue;
|
||||
if ((entityPool[stationPool[j].entityId].pos - pos).sqrMagnitude >= 14297f) continue;
|
||||
collide = true;
|
||||
break;
|
||||
}
|
||||
if (collide)
|
||||
{
|
||||
/* rotate for a small cell on sphere */
|
||||
pos = Maths.RotateLF(0.0, 1.0, 0.0, cellRad, pos);
|
||||
pos2 = Maths.RotateLF(0.0, 1.0, 0.0, cellRad, pos2);
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (player.inhandItemId == itemId && player.inhandItemCount > 0)
|
||||
{
|
||||
player.UseHandItems(1, out var _);
|
||||
}
|
||||
else
|
||||
{
|
||||
var count = 1;
|
||||
player.package.TakeTailItems(ref itemId, ref count, out var _);
|
||||
if (count == 0) break;
|
||||
}
|
||||
|
||||
var rot = Maths.SphericalRotation(pos, 0f);
|
||||
var rot2 = Maths.SphericalRotation(pos2, 0f);
|
||||
var prebuild = default(PrebuildData);
|
||||
prebuild.protoId = (short)buildPreview.item.ID;
|
||||
prebuild.modelIndex = (short)buildPreview.desc.modelIndex;
|
||||
prebuild.pos = pos;
|
||||
prebuild.pos2 = pos2;
|
||||
prebuild.rot = rot;
|
||||
prebuild.rot2 = rot2;
|
||||
prebuild.pickOffset = (short)buildPreview.inputOffset;
|
||||
prebuild.insertOffset = (short)buildPreview.outputOffset;
|
||||
prebuild.recipeId = buildPreview.recipeId;
|
||||
prebuild.filterId = buildPreview.filterId;
|
||||
prebuild.InitParametersArray(buildPreview.paramCount);
|
||||
for (var j = 0; j < buildPreview.paramCount; j++)
|
||||
{
|
||||
prebuild.parameters[j] = buildPreview.parameters[j];
|
||||
}
|
||||
prebuilds.Add(factory.AddPrebuildDataWithComponents(prebuild));
|
||||
countToBuild--;
|
||||
/* rotate for minimal distance for next OC on sphere */
|
||||
pos = Maths.RotateLF(0.0, 1.0, 0.0, cellRad * distRadCount, pos);
|
||||
pos2 = Maths.RotateLF(0.0, 1.0, 0.0, cellRad * distRadCount, pos2);
|
||||
i += distRadCount;
|
||||
}
|
||||
|
||||
if (!_instantBuild) return;
|
||||
foreach (var id in prebuilds)
|
||||
{
|
||||
factory.BuildFinally(player, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
# OrbitalCollectorBatchBuild
|
||||
|
||||
#### Batch build Orbital Collectors
|
||||
#### 轨道采集器快速批量建造
|
||||
|
||||
## Updates
|
||||
### 1.2.0
|
||||
* Support for mods that change default radius of Gas Planets, e.g. `GalacticScale`.
|
||||
* Remove maximum build count limit in config.
|
||||
|
||||
### 1.1.0
|
||||
* Add `InstantBuild` to config
|
||||
|
||||
## Usage
|
||||
* Build any orbital collector on a Gas Giant to trigger building all placable orbital collectors.
|
||||
* Can set maximum orbital collectors to build once in config.
|
||||
* Note: Collectors are placed as prebuilt status, you still need to fly around the Gas Giant to complete building. This is designed not to break much game logic.
|
||||
You can set `InstantBuild` to `true` in config to make them built instantly.
|
||||
|
||||
## 使用说明
|
||||
* 在气态星球上建造任何一个轨道采集器触发所有可建造采集器的放置。
|
||||
* 可以在设置文件中配置一次批量建造的最大轨道采集器数量。
|
||||
* 提示:轨道采集器会处于待建造状态,你仍然需要绕行气态行星一圈以完成建造。这个机制是为了尽可能减少对原有游戏逻辑的破坏。
|
||||
在配置文件里设置`InstantBuild`为`true`可以使采集器的建造立即完成。
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 53 KiB |
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"name": "OrbitalCollectorBatchBuild",
|
||||
"version_number": "1.2.0",
|
||||
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/OCBatchBuild",
|
||||
"description": "Batch build Orbital Collectors / 轨道采集器快速批量建造",
|
||||
"dependencies": [
|
||||
"xiaoye97-BepInEx-5.4.17"
|
||||
]
|
||||
}
|
||||
@@ -186,7 +186,7 @@ public class Patch : BaseUnityPlugin, IModCanSave
|
||||
sorter.stt = sorter.stt * om / nm;
|
||||
if (sorter.time > sorter.stt)
|
||||
{
|
||||
sorter.time = sorter.stt - sorter.speed;
|
||||
sorter.time = sorter.stt - InserterComponent.speed;
|
||||
}
|
||||
|
||||
if (powerSystem == null) continue;
|
||||
|
||||
@@ -16,16 +16,25 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BepInEx.Core" Version="5.*" />
|
||||
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
|
||||
<PackageReference Include="DysonSphereProgram.GameLibs" Version="*-r.*" />
|
||||
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
|
||||
<PackageReference Include="DysonSphereProgram.Modding.DSPModSave" Version="1.*" />
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" />
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UI">
|
||||
<HintPath>..\AssemblyFromGame\UnityEngine.UI.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
|
||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip
zip -9 -j package/$(ProjectName)-$(Version).zip $(TargetPath) package/icon.png package/manifest.json README.md" />
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
|
||||
<Exec Command="powershell Compress-Archive -Force -DestinationPath 'package/$(ProjectName)-$(Version).zip' -Path '$(TargetPath)', package/icon.png, package/manifest.json, README.md" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
# OverclockEverything
|
||||
|
||||
#### Boost nearly all structures
|
||||
#### 加速几乎所有建筑功能
|
||||
|
||||
## Usage
|
||||
***Boost nearly all structures***
|
||||
|
||||
* Boost power generation, assembling speed, belt and sorter speed.
|
||||
|
||||
## 使用说明
|
||||
***加速几乎所有建筑功能***
|
||||
|
||||
* 加快发电,制造,传送带和分拣器速度。
|
||||
|
||||
+15
-6
@@ -15,15 +15,24 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BepInEx.Core" Version="5.*" />
|
||||
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
|
||||
<PackageReference Include="DysonSphereProgram.GameLibs" Version="*-r.*" />
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" />
|
||||
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
|
||||
<PackageReference Include="UnityEngine.Modules" Version="2022.3.62" IncludeAssets="compile" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\AssemblyFromGame\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UI">
|
||||
<HintPath>..\AssemblyFromGame\UnityEngine.UI.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
|
||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip
zip -9 -j package/$(ProjectName)-$(Version).zip $(TargetPath) package/icon.png package/manifest.json README.md" />
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
|
||||
<Exec Command="powershell Compress-Archive -Force -DestinationPath 'package/$(ProjectName)-$(Version).zip' -Path '$(TargetPath)', package/icon.png, package/manifest.json, README.md" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
||||
@@ -1,67 +1,66 @@
|
||||
## DSP Mods by Soar Qin
|
||||
# DSP Mods by Soar Qin
|
||||
|
||||
# [CheatEnabler](CheatEnabler)
|
||||
## [CheatEnabler](CheatEnabler)
|
||||
|
||||
Add various cheat functions while disabling abnormal determinants
|
||||
Add various cheat functions while disabling abnormal determinants
|
||||
添加一些作弊功能,同时屏蔽异常检测
|
||||
|
||||
# [CompressSave](CompressSave)
|
||||
## [CompressSave](CompressSave)
|
||||
|
||||
Moved [here](https://github.com/soarqin/DSP_Mods_TO/tree/master/CompressSave)
|
||||
Moved [to another repo](https://github.com/soarqin/DSP_Mods_TO/tree/master/CompressSave)
|
||||
|
||||
# [LogisticMiner](LogisticMiner)
|
||||
## [Dustbin](Dustbin)
|
||||
|
||||
Logistic Storages can mine all ores/water on current planet
|
||||
物流塔可以采集当前星球的全部矿产(以及水)
|
||||
|
||||
# [HideTips](HideTips)
|
||||
|
||||
Hide/Disable various tutorial tips/messages
|
||||
隐藏/屏蔽各种引导提示/消息
|
||||
|
||||
# [Dustbin](Dustbin)
|
||||
|
||||
Can turn Storages and Tanks into Dustbin(Destroy incoming items)
|
||||
Can turn Storages and Tanks into Dustbin(Destroy incoming items)
|
||||
储物仓和储液罐可以转变为垃圾桶(销毁送进的物品)
|
||||
|
||||
# [OverclockEverything](OverclockEverything)
|
||||
## [HideTips](HideTips)
|
||||
|
||||
Boost nearly all structures
|
||||
加速几乎所有建筑功能
|
||||
Hide/Disable various tutorial tips/messages
|
||||
隐藏/屏蔽各种引导提示/消息
|
||||
|
||||
# [OrbitalCollectorBatchBuild](OCBatchBuild)
|
||||
## [LabOpt](LabOpt)
|
||||
|
||||
Batch build Orbital Collectors
|
||||
轨道采集器快速批量建造
|
||||
|
||||
# [UniverseGenTweaks](UniverseGenTweaks)
|
||||
|
||||
Universe Generator Tweak
|
||||
宇宙生成参数调节
|
||||
|
||||
# [MechaDronesTweaks](MechaDronesTweaks)
|
||||
|
||||
Some tweaks for mecha drones and build functions(Successor to FastDrones MOD)
|
||||
机甲建设机和建设功能调整(FastDrones MOD的后继者)
|
||||
|
||||
# [LabOpt](LabOpt)
|
||||
|
||||
Performance optimizations for Matrix Labs
|
||||
Performance optimizations for Matrix Labs
|
||||
Marked as obsoleted temporarily, needs more investigation about LabComponent's mechanism
|
||||
优化研究站性能
|
||||
暂时标识为过期,需要更多关于LabComponent机制的研究
|
||||
|
||||
# [PoolOpt](PoolOpt)
|
||||
## [LogisticMiner](LogisticMiner)
|
||||
|
||||
Optimize memory pools on loading gamesaves
|
||||
Logistic Storages can mine all ores/water on current planet
|
||||
物流塔可以采集当前星球的全部矿产(以及水)
|
||||
|
||||
## [LuaScriptEngine](LuaScriptEngine)
|
||||
Write mod functions in lua scripts
|
||||
用lua脚本编写mod功能
|
||||
|
||||
## [MechaDronesTweaks](MechaDronesTweaks)
|
||||
|
||||
Some tweaks for mecha drones and build functions(Successor to FastDrones MOD)
|
||||
机甲建设机和建设功能调整(FastDrones MOD的后继者)
|
||||
|
||||
## [OverclockEverything](OverclockEverything)
|
||||
|
||||
Boost nearly all structures
|
||||
加速几乎所有建筑功能
|
||||
|
||||
## [PoolOpt](PoolOpt)
|
||||
|
||||
Optimize memory pools on loading gamesaves
|
||||
加载游戏存档时优化内存池的使用
|
||||
|
||||
# [UserCloak](UserCloak)
|
||||
## [UniverseGenTweaks](UniverseGenTweaks)
|
||||
|
||||
Cloak(Fake) user account info
|
||||
Universe Generator Tweak
|
||||
宇宙生成参数调节
|
||||
|
||||
## [UserCloak](UserCloak)
|
||||
|
||||
Cloak(Fake) user account info
|
||||
隐匿(伪装)用户账号信息
|
||||
|
||||
# [UXAssist](UXAssist)
|
||||
## [UXAssist](UXAssist)
|
||||
|
||||
Some functions and patches for better user experience
|
||||
一些提升用户体验的功能和补丁
|
||||
Some functions and patches for better user experience
|
||||
一些提升用户体验的功能和补丁
|
||||
|
||||
@@ -0,0 +1,731 @@
|
||||
<details>
|
||||
<summary>Read me in English</summary>
|
||||
|
||||
## Changlog
|
||||
|
||||
* 1.5.2
|
||||
* Fix crash while error occurs on milkyway login/upload.
|
||||
* 1.5.1
|
||||
* Support game version 0.10.34.28392
|
||||
* 1.5.0
|
||||
* Support game version 0.10.34
|
||||
* New features:
|
||||
* `Show top players in milkyway`: The button is available on top-left corner of Milkyway View
|
||||
* `Show recent milkyway upload results`: The button is on UXAssist `General` tab.
|
||||
* `Night Sunlight`: Fix bugs that sunlight angle is not updated after loading a save.
|
||||
* `Enhanced control for logistic storage capacities`: Working for Logistics Control Panel now.
|
||||
* `Protect veins from exhaustion`: Fix a minor bug.
|
||||
* `Re-intialize planet`: Improve stability and fix some bugs.
|
||||
* 1.4.5
|
||||
* New feature: `Ctrl+Shift+Click to pick items from whole belts`, with 2 suboptions: `Include branches of belts` and `Include connected inserters`
|
||||
* Patch [BlueprintTweaks](https://thunderstore.io/c/dyson-sphere-program/p/kremnev8/BlueprintTweaks/) temporarily to fix `Drag Remove` functions (And wait for limoka to merge the [Pull Request](https://github.com/limoka/DSP-Mods/pull/133)):
|
||||
* Ground rendering is correct now.
|
||||
* Dismantle logic follows offcial's implementation to avoid possible crashes.
|
||||
* Fixed CommonAPI patch to make shortcut key settings saved as expect now, sorry for wrong implementation in last version.
|
||||
* 1.4.4
|
||||
* `Remember window position and size on last exit`: Fix compatiblity for game patch 0.10.33
|
||||
* `Real-time logistic stations info panel`: Try to fix a display issue.
|
||||
* Patch [CommonAPI](https://thunderstore.io/c/dyson-sphere-program/p/CommonAPI/CommonAPI/) temporarily to fix a known issue that shortcut key settings are not saved to config, while its [PR](https://github.com/limoka/CommonAPI/pull/14) is not merged yet.
|
||||
* 1.4.3
|
||||
* `Build Tesla Tower and Wireless Power Tower alternately`:
|
||||
* Fix wrong implementation for latest game patch.
|
||||
* Cannot use Tesla Tower as start Power Tower now, due to new rectangular area build mechanism.
|
||||
* `Planet Vein Untilization`: Support mods that add new vein types.
|
||||
* `Real-time logistic stations info panel`: Try to fix possible crash.
|
||||
* 1.4.2
|
||||
* Fixed a crash issue.
|
||||
* 1.4.1
|
||||
* Fixed a compatible issue with latest game patch.
|
||||
* 1.4.0
|
||||
* Support game version 0.10.33, with some features removed:
|
||||
* Remove `Scale up mouse cursor`: Unity 2022 set cursor size from system settings, software rendering does not affect its size now.
|
||||
* Remove `Set enabled CPU threads`: They are officially supported.
|
||||
* `Dismantle blueprint selected buildings`: Fixed an issue that proliferator points are lost for items dropped from logstic stroages.
|
||||
* `Sort blueprint structures before saving`: Improved sorting rules.
|
||||
* `Starmap filter`: Now star indices (as in galaxy generation order) are displayed as prefix.
|
||||
* Embedded [Planet Vein Untilization](https://thunderstore.io/c/dyson-sphere-program/p/testpushpleaseignore/Planet_Vein_Utilization/) due to its lack of maintainance, with minor bug fixes.
|
||||
* `Remove some build conditions`: Fix a wrong logic.
|
||||
* `Real-time logistic stations info panel`: Fix some display issues.
|
||||
* Fix background image issue for tab buttons on config window.
|
||||
* Now build in C# `Debug` Configuration, to avoid some issues caused by optimizations in `Release` Configuration.
|
||||
* 1.3.7
|
||||
* `Re-initialize planet`: Fix a possible crash.
|
||||
* `Auto-config logistic stations`: Add `Set default remote logic to storage`
|
||||
* 1.3.6
|
||||
* `Dismantle blueprint selected buildings`:
|
||||
* Fix a crash on dismantling preview buildings.
|
||||
* Rename to `Shortcut keys for Blueprint Copy mode`, while adding a shortcut key to select all buildings (Ctrl+A by default).
|
||||
* `Allow overflow for Logistic Stations and Advanced Mining Machines`: Working for Logistics Control Panel now.
|
||||
* `Tweak building buffer`: add buffer tweaking for 2 new buildings
|
||||
* `Ejector Solar Sails buffer count`: Range 5-400 (step by 5), default is 20 (same as game)
|
||||
* `Silo Rockets buffer count`: Range 1-20, default is 20 (same as game)
|
||||
* 1.3.5
|
||||
* `Mod manager profile based save folder`: Fix crash on game startup
|
||||
* 1.3.4
|
||||
* `Auto-config logistic stations`: Fix a bug that some settings are not applied to Advanced Mining Machines and Logistics Distributors
|
||||
* 1.3.3
|
||||
* `Starmap filter`: Hide top overlaping windows while the filter UI is shown.
|
||||
* `Auto-config logistic stations`: Can set Max. Charging Power for Battlefield Analysis Base now.
|
||||
* `Re-initialize planet`: Fix a crash.
|
||||
* `Auto navigation on sailings`:
|
||||
* Add a button to enable/disable `Auto-cruise` quickly.
|
||||
* Do not auto-use Warper if required Tech is not researched.
|
||||
* `Dismantle blueprint selected buildings`: Fix an issue that belt connected buildings are dismantled unexpectly.
|
||||
* `Mod manager profile based save folder`: Fix compatibility with [SaveTheWindows](https://thunderstore.io/c/dyson-sphere-program/p/starfi5h/SaveTheWindows/).
|
||||
* `Enhanced control for logistic storage capacities` & `Allow overflow for Logistic Stations and Advanced Mining Machines`:
|
||||
* Logistic storage capacities are not scaled on upgrading `Logistics Carrier Capacity`, if they are already greater than upgraded maximum capacity.
|
||||
* Logistic storage capacities will be reduced to tech capacity limits on pasting blueprints.
|
||||
* `Real-time logistic stations info panel`: Support for mods that change slot count of logistic stations.
|
||||
* 1.3.2
|
||||
* New feature: `Disable battle-related techs in Peace mode`
|
||||
* New button: `Unlock all techs with metadata`
|
||||
* Add a checkbox to make union of results in starmap filter.
|
||||
* Fix some starmap vein/planet filter conditions.
|
||||
* Fix a crash caused by `Re-initialize planet` in peace mode.
|
||||
* Fix compatibility with `NebulaMultiplayerMod`.
|
||||
* 1.3.1
|
||||
* Fix an issue that some UI elements are hidden while hitting the newly added combobox on Starmap.
|
||||
* Fix an issue that star name filter is not applied if `Shortcut keys for showing stars` is not enabled.
|
||||
* `Dismantle blueprint selected buildings`: Fix an issue that items in Logistic Station slots are not dropped out.
|
||||
* Tweak star name filter's planet type list.
|
||||
* 1.3.0
|
||||
* New feature for starmap view:
|
||||
* Add a star name filter, you can filter displayed star names by ores or planet types now.
|
||||
* Add a dropdown box to show all stars' distance and/or planet count.
|
||||
* `Cut conveyor belt`: Fix input issue.
|
||||
* `Shortcut keys for showing stars`: Fix an issue that toggle key is read when Starmap View is not opened.
|
||||
* `Dismantle blueprint selected buildings`: Fix an issue that preview buildings are not dismantled.
|
||||
* `Remember window position and size on last exit`: Optimized implementation
|
||||
* `Auto-config logistic stations`: Add an option `Limit auto-replenish count to config values`
|
||||
* Optimized some UI codes.
|
||||
* 1.2.20
|
||||
* New feature: `Dismantle blueprint selected buildings`
|
||||
* Press shortcut key in blueprint copy mode to dismantle selected buildings.
|
||||
* The default shortcut key is Ctrl+X, you can set it in system options panel.
|
||||
* New feature: `Auto-config logistic stations`
|
||||
* Auto-config buildings include: Logistics Distributor, PLS, ILS, Advanced Mining Machine.
|
||||
* `Night Sunlight`: Fix bugs that sunlight angle is not updated as expected again.
|
||||
* 1.2.19
|
||||
* New feature: `Tweak building buffer`
|
||||
* Factory recipe buffer formula: take the larger value between `Assembler buffer time multiplier(in seconds) * items needed per second` and `Assembler buffer minimum multiplier * items needed per recipe`
|
||||
* `Assembler buffer time multiplier(in seconds)`: Range 2-10, default is 4 (same as game)
|
||||
* `Assembler buffer minimum multiplier`: Range 2-10, default is 2 (same as game)
|
||||
* Matrix Lab assembly mode formula: Default buffer is `Buffer count for assembling in labs`, when using Self-evolution Lab, if recipe's original production time is not greater than 9 seconds, add `Extra buffer count for Self-evolution Labs` * (`Lab speed` - 1)
|
||||
* `Buffer count for assembling in labs`: Range 2-20, default is 6 (same as game)
|
||||
* `Extra buffer count for Self-evolution Labs`: Range 1-10, default is 3 (same as game)
|
||||
* `Buffer count for researching in labs`: Range 2-20, default is 10 (same as game)
|
||||
* `Ray Receiver Graviton Lens buffer count`: Range 1-20, default is 1 (game default is 20)
|
||||
* New feature: `Shortcut keys for showing stars' name`
|
||||
* Add a shortcut key to always show all star names in starmap when holding, default is `Alt`
|
||||
* Add a shortcut key to toggle between three star name display states in starmap: `Original state`, `Show all names`, `Hide all names`, default is `Tab`, will restore to original state when closing starmap
|
||||
* `Cut conveyor belt`: Fix a bug that entity logic connection is not cut so that belt is not cut off on copying as a blueprint.
|
||||
* 1.2.18
|
||||
* `Protect veins from exhaustion`: Optimized implementation, now veins will not be protected once you have upgrade `Veins Utilization` to level 390+, while the cost rate becomes absolute 0.
|
||||
* `Night Sunlight`: Fix bugs that sunlight angle is not updated as expected.
|
||||
* 1.2.17
|
||||
* Fix wrong implementation of `Protect veins from exhaustion` which causes wrong display of vein stats and veins not consumed.
|
||||
* 1.2.16
|
||||
* New feature: `Cut conveyor belt`
|
||||
* Press shortcut key to cut conveyor belt under cursor.
|
||||
* The default shortcut key is Alt+X, you can set it in system options panel.
|
||||
* New feature: `Profile based option`
|
||||
* Option file is stored as `Options\<ProfileName>.xml`.
|
||||
* Fix compatibility with game update 0.10.32.25779
|
||||
* 1.2.15
|
||||
* `Off-grid building and stepped rotation`: Fix compatibility with DSP 0.10.32.25682. (#57)
|
||||
* `Enhanced control for logistic storage capacities`: Try to fix possible crash. (#54)
|
||||
* 1.2.14
|
||||
* Fix an issue that an unexpected menu icon is shown in the top-right corner of the config panel.
|
||||
* `Stop ejectors when available nodes are all filled up`: Fix compatibility with `Dyson Sphere Program v0.10.32.25496`.
|
||||
* 1.2.13
|
||||
* `Belt signals for buy out dark fog items automatically`: Fix possible crashes.
|
||||
* `Logistics Control Panel Improvement`: Auto apply filter with in-hand item now.
|
||||
* Fix an alignment issue on UI panel.
|
||||
* 1.2.12
|
||||
* `Construct only structure points but frames`: Fix a bug that frames are still not constructed when this function is disabled.
|
||||
* `Drag building power poles in maximum connection range`: Fix a bug that single power pole cannot be placed at some positions.
|
||||
* 1.2.11
|
||||
* Fix an issue caused by game update: tips are not shown when mouse hovering on tips button.
|
||||
* 1.2.10
|
||||
* `Set enabled CPU threads`: Fix hybrid-architect check for CPUs without hyper-threading
|
||||
* `Re-initialize Dyson Spheres` and `Quick dismantle Dyson Shells`: Fix possible crashes and a display issue, while Dyson Sphere panel is actived.
|
||||
* 1.2.9
|
||||
* `Protect veins from exhaustion`:
|
||||
* Fix a bug that vein protection causes crashes (#50).
|
||||
* Fix a bug that minimum oil speed in config is not working (#50).
|
||||
* Fix a bug that oil is not extracted when vein protection is enabled in infinite resource mode (#52).
|
||||
* 1.2.8
|
||||
* New feature: `Fast fill in to and take out from tanks`
|
||||
* You can set multiplier for tanks' operation speed
|
||||
* This affects manually fill in to and/or take out from tanks, as well as transfer from upper to lower level.
|
||||
* Fixes to `Append mod profile name to game window title`:
|
||||
* Fix a bug that window title is not set correctly when multiple instance is launched.
|
||||
* Fix a bug that window title is not set correctly if BepInEx debug console is enabled.
|
||||
* `Real-time logistic stations info panel`: Fix a bug that item status bar appears unexpectedly.
|
||||
* 1.2.7
|
||||
* Fix some minor issues
|
||||
* 1.2.6
|
||||
* `Remember window position and size on last exit`
|
||||
* Fix a bug that window position is restored even the option is disabled.
|
||||
* Fix a bug that the last window position is wrongly remembere when game is closed at minimized state.
|
||||
* 1.2.5
|
||||
* New feature: `Set process priority`
|
||||
* New feature: `Set enabled CPU threads`
|
||||
* `Drag building power poles in maximum connection range`: Add a new config option `Build Tesla Tower and Wireless Power Tower alternately`
|
||||
* 1.2.4
|
||||
* `Sunlight at night`:
|
||||
* Fix flickering issue while mecha is sailing.
|
||||
* Can configure the light angles now.
|
||||
* `Scale up mouse cursor`: Fix known issues.
|
||||
* `Buy out techs with their prerequisites`: Fix a bug that warning popup from invalid data.
|
||||
* Does not patch `BulletTime`'s speed control now, as `BulletTime` has been updated to support configurable maximum speed.
|
||||
* Some minor fixes and tweaks.
|
||||
* 1.2.3
|
||||
* `Real-time logistic stations info panel`: Fix bar length not match with item amount when item amount is more than capacity.
|
||||
* `Sunlight at night`: Fix not working.
|
||||
* 1.2.2
|
||||
* `Real-time logistic stations info panel`: Fix text color mismatch sometimes
|
||||
* `Logical Frame Rate`: Set default shortcut key to `Ctrl`+`-/+` to avoid conflict with other shortcut keys
|
||||
* 1.2.1
|
||||
* `Off-grid building and stepped rotation`:
|
||||
* Fix off-grid building's default shortcut key for belts
|
||||
* Fix coordinate display issue
|
||||
* 1.2.0
|
||||
* New feature: `Logical Frame Rate`
|
||||
* This will change game running speed, down to 0.1x slower and up to 10x faster.
|
||||
* A pair of shortcut keys (`-` and `+`) to change the logical frame rate by -0.5x and +0.5x.
|
||||
* Note:
|
||||
* High logical frame rate is not guaranteed to be stable, especially when factories are under heavy load.
|
||||
* This will not affect some game animations.
|
||||
* When set game speed in mod `Auxilaryfunction`, this feature will be disabled.
|
||||
* When mod `BulletTime` is installed, this feature will be hidden, but patch `BulletTime`'s speed control, to make its maximum speed 10x.
|
||||
* `Off-grid building and stepped rotation`: Due to conflict with shortcut key in new game update, the shortcut key for belts is changed to `Ctrl` by default, and can be set in system options now.
|
||||
* `Real-time logistic stations info panel`: Fix a crash issue.
|
||||
* `Dyson Sphere "Auto Fast Build"`: Fix possible wrong production records.
|
||||
* Codes refactored, for better maintainability.
|
||||
* 1.1.6
|
||||
* New feature: `Scale up mouse cursor`
|
||||
* Note: This will enable software cursor mode, which may cause mouse movement lag on heavy load.
|
||||
* New feature: `Real-time logistic stations info panel`
|
||||
* Note: This function will be hidden if you enabled `Show station info` in mod `Auxilaryfunction`.
|
||||
* Fix an issue that `Dyson Sphere "Auto Fast Build"` does not generate production records for solar sails.
|
||||
* Remove use of AssetBundle, move all icons into `Assembly Resources`, for better flexibility.
|
||||
* 1.1.5
|
||||
* New feature: `Logistics Control Panel Improvement`
|
||||
* Auto apply filter with item under mouse cursor while opening the panel
|
||||
* Quick-set item filter while right-clicking item icons in storage list on the panel
|
||||
* New feature: `Dyson Sphere "Auto Fast Build" speed multiplier`
|
||||
* Note: this only applies to `Dyson Sphere "Auto Fast Build"` in sandbox mode
|
||||
* New feature: `Mod manager profile based save folder`
|
||||
* Save files are stored in `Save\<ProfileName>` folder.
|
||||
* Will use original save location if matching default profile name.
|
||||
* `Quick build and dismantle stacking labs`: works for storages and tanks now
|
||||
* `Enable game window resize`: Keep window resizable on applying game options.
|
||||
* `Remember window position and size on last exit`: Do not resize window on applying game options if resolution related config entries are not changed.
|
||||
* Auto resize panel to fit content, for better support of multilanguages and mods dependent on UX Assist config panel functions.
|
||||
* 1.1.4
|
||||
* Fix `Remove some build conditions`
|
||||
* 1.1.3
|
||||
* UI texts are updated following game settings now
|
||||
* Fix hover area for checkboxes in config panel
|
||||
* Fix an issue which makes `Convert Peace-Mode saves to Combat-Mode on loading` not working
|
||||
* 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
|
||||
* Fix assetbundle loading issue
|
||||
* 1.1.0
|
||||
* `Stop ejectors when available nodes are all filled up`: Show `No node to fill` on ejector panel when all dyson sphere nodes are filled up.
|
||||
* Append mod profile name to game window title, if using mod managers (`Thunderstore Mod Manager` or `r2modman`).
|
||||
* New features:
|
||||
* `Buy out techs with their prerequisites`: This enables batch buying out techs with their prerequisites. Buy-out button is shown for all locked techs/upgrads.
|
||||
* `Belt signals for buy out dark fog items automatically`, while enabled:
|
||||
* 6 belt signals are added to the signal panel, which can be used to buy out dark fog items automatically.
|
||||
* Generated items are stacked in 4 items.
|
||||
* Exchange ratio is following the original game design, aka:
|
||||
* 1 Metaverse = 20 Dark Fog Matrices
|
||||
* 1 Metaverse = 60 Engery Shards
|
||||
* 1 Metaverse = 30 Silicon-based Neurons
|
||||
* 1 Metaverse = 30 Negentropy Singularities
|
||||
* 1 Metaverse = 30 Matter Recombinators
|
||||
* 1 Metaverse = 10 Core Elements
|
||||
* 1.0.26
|
||||
* New features:
|
||||
* Restore upgrades of `Sorter Cargo Stacking` on panel
|
||||
* Set `Sorter Cargo Stacking` to unresearched state
|
||||
* Changes to `Protect veins from exhaustion` configuration:
|
||||
* The vein amount is protected at 1000 by default now
|
||||
* The maximum vein amount is changed to 10000, and the maximum oil speed is changed to 10.0/s
|
||||
* 1.0.25
|
||||
* Fix an issue that building entites can not be clicked through when `Do not render factory entities (except belts and sorters)` is enabled
|
||||
* 1.0.24
|
||||
* Changes to `Do not render factory entities (except belts and sorters)`
|
||||
* Add shortcut key in config panel to toggle this function
|
||||
* Can click on both belts and sorters now
|
||||
* New feature: `Drag building power poles in maximum connection range`
|
||||
* New feature: `Allow overflow for Logistic Stations and Advanced Mining Machines`
|
||||
* Allow overflow when trying to insert in-hand items
|
||||
* Allow `Enhanced control for logistic storage capacities` to exceed tech capacity limits
|
||||
* Remove logistic strorage capacity limit check on loading game
|
||||
* 1.0.23
|
||||
* New features:
|
||||
* `Do not render factory entities (except belts and sorters)`
|
||||
* This also makes players click though factory entities but belts
|
||||
* `Open Dark Fog Communicator` anywhere
|
||||
* Belts can be built off-grid now, by pressing the shortcut key for `Switch Splitter model`(`Tab` by default)
|
||||
* Add a suboption `Auto boost` to `Auto-cruise`
|
||||
* `Auto-cruise` does warp when core energy at least 80% now
|
||||
* 1.0.22
|
||||
* Fix a crash issue caused by `Quick build and dismantle stacking labs`
|
||||
* 1.0.21
|
||||
* Fix a bug that stepped rotation is not working in `Off-grid building and stepped rotation`, which is caused by latest game update
|
||||
* Fix some issues in `Auto nativation` and `Auto-cruise`, now only boosts when core energy at least 10% and warps when core energy at least 50%
|
||||
* 1.0.20
|
||||
* Fix an infinite-loop issue when `Quick build and dismantle stacking labs` and `No condition build` are both enabled
|
||||
* Fix a crash caused by `Re-initialize planet` in combat mode
|
||||
* 1.0.19
|
||||
* New functions:
|
||||
* `Quick build and dismantle stacking labs`
|
||||
* `Protect veins from exhaustion`
|
||||
* By default, the vein amount is protected at 100, and oil speed is protected at 1.0/s, you can set them yourself in config file.
|
||||
* When reach the protection value, veins/oils steeps will not be mined/extracted any longer.
|
||||
* Close this function to resume mining and pumping, usually when you have enough level on `Veins Utilization`
|
||||
* Remove default shortcut key for `Auto-cruise`, to avoid misoperation. Please set it in the system options window manually if needed.
|
||||
* 1.0.18
|
||||
* Fix crash while coursing to a dark-fog hive.
|
||||
* Auto-cruise does not bypass dark-fog hives if they are targeted.
|
||||
* 1.0.17
|
||||
* New function: `Auto navigation on sailings`, which is inspired by [CruiseAssist](https://dsp.thunderstore.io/package/tanu/CruiseAssist/) and its extension [AutoPilot](https://dsp.thunderstore.io/package/tanu/AutoPilot/)
|
||||
* It keeps Icarus on course to the target planet
|
||||
* It will try to bypass any obstacles(planets, stars or dark-fog hives) on the way
|
||||
* Furthermore, there is also a shortcut key which can be set in the system options window, which is used to toggle `Auto-cruise` that enables flying to targeted planets fully automatically.
|
||||
* Auto-cruise will start when you target a planet on star map
|
||||
* It will use warper to fly to the target planet if the planet is too far away, the range can be configured.
|
||||
* It will speed down when approaching the target planet, to avoid overshooting
|
||||
* Fix a crash caused by `Stop ejectors when available nodes are all filled up` in latest game update
|
||||
* `Off-grid building and stepped rotation`: Hide Z coordinate from display if it is zero
|
||||
* 1.0.16
|
||||
* Add CommonAPI to package manifest dependencies(missing in last version)
|
||||
* New function: `Hide tips for soil piles changes`
|
||||
* 1.0.15
|
||||
* Move shortcut key settings to system options window, which depends on [CommonAPI](https://dsp.thunderstore.io/package/CommonAPI/CommonAPI)
|
||||
* Enable `Hide UI` function(`F11` by default) while on Star Map view
|
||||
* New function: `Treat stack items as single in monitor components`
|
||||
* 1.0.14
|
||||
* Fix crash in `Re-initialize planet` again
|
||||
* `Off-grid building and stepped rotation`: Add Z coordinate to display, and adjust the precision to 4 decimal after point
|
||||
* 1.0.13
|
||||
* `Off-grid building and stepped rotation`: show building coordinates(relative to grids) on building preview and building info panel now
|
||||
* Increase maximum count of Metadata Instantiations to 20000 (from 2000)
|
||||
* Increase capacity of player order queue to 128 (from 16)
|
||||
* Fix issue caused by game updates
|
||||
* `Remove some build conditions`: fixed issue that some conditions are not eliminated
|
||||
* `Re-initialize planet`: fixed crash issue
|
||||
* 1.0.12
|
||||
* Fix a bug that ejectors aimed at even-numbered orbits stop working when `Stop ejectors when available nodes are all filled up` is enabled.
|
||||
* 1.0.11
|
||||
* Remove `Better auto-save mechanism` due to conflicts with DSPModSave and some other mods.
|
||||
* 1.0.10
|
||||
* Fix a button display bug
|
||||
* Fix a possible crash while `Enhanced control for logistic storage capacities` is enabled
|
||||
* 1.0.9
|
||||
* New function: `Better auto-save mechanism`
|
||||
* Auto saves are stored in 'Save\AutoSaves' folder, filenames are combined with cluster address and date-time
|
||||
* Note: this will sort gamesaves by modified time on save/load window, so you don't have to use [DSP_Save_Game_Sorter] anymore
|
||||
* 1.0.8
|
||||
* New function: `Enhanced control for logistic storage capacities`
|
||||
* 1.0.7
|
||||
* Fix a crash issue on choosing language other than English and Chinese
|
||||
* Games saved in Peace-Mode after Dark-Fog update can also be loaded as Combat-Mode now.
|
||||
* 1.0.6
|
||||
* Convert old saves to Combat-Mode on loading
|
||||
* 1.0.5
|
||||
* Support game version 0.10.28.20759
|
||||
* Sort blueprint structures before saving, to reduce generated blueprint data size a little.
|
||||
* 1.0.4
|
||||
* Add new function: `Off-grid building and stepped rotation`
|
||||
* Fix an issue that window position not restored and can not be resized when function is enabled but game is started with different mod profiles.
|
||||
* 1.0.3
|
||||
* Add new function: `Quick build Orbital Collectors`.
|
||||
* Add confirmation popup for `Re-intialize planet`, `Quick dismantle all buildings`, `Re-initialize Dyson Spheres` and `Quick dismantle Dyson Shells`.
|
||||
* Fix error on `Remove build count and range limit` when building a large amount of belts.
|
||||
* Fix an issue that window position not saved correctly when quit game without using in-game menu.
|
||||
* 1.0.2
|
||||
* Redesign config tabs, for clearer layout.
|
||||
* Add 2 new options:
|
||||
* Enable game window resize.
|
||||
* Remember window position and size on last exit.
|
||||
* 1.0.1
|
||||
* Fix config button text and tips while returning to title menu.
|
||||
* Fix that error occurs while returning to title menu, with `Stop ejectors when available nodes are all filled up` enabled.
|
||||
* Add a patch to fix the bug that warning popup on `Veins Utilization` upgraded to level 8000+.
|
||||
* 1.0.0
|
||||
* Initial release
|
||||
* Functions moved from [MechaDronesTweaks](https://dsp.thunderstore.io/package/soarqin/MechaDronesTweaks/) and [CheatEnabler](https://dsp.thunderstore.io/package/soarqin/CheatEnabler/)
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>中文读我</summary>
|
||||
|
||||
## 更新日志
|
||||
|
||||
* 1.5.2
|
||||
* 修复在银河系登录/上传出错时崩溃的问题
|
||||
* 1.5.1
|
||||
* 支持游戏版本 0.10.34.28392
|
||||
* 1.5.0
|
||||
* 支持游戏版本 0.10.34
|
||||
* 新功能:
|
||||
* `显示银河系发电量排行`:按钮位于银河视图左上角
|
||||
* `显示最近银河系上传结果`:按钮在UXAssist的`常规`标签页内
|
||||
* `夜间日光灯`:修复加载存档后日光角度没有更新的问题
|
||||
* `物流塔存储数量限制控制改进`:现在可用于物流控制面板
|
||||
* `保护矿脉不会耗尽`:修复了一个小问题
|
||||
* `初始化本行星`:提升稳定性并修复部分Bug
|
||||
* 1.4.5
|
||||
* 新功能:`按住Ctrl+Shift点击从整条传送带抓取物品`,包含两个子选项:`包含传送带分支` 和 `包含连接的分拣器`
|
||||
* 临时修复 [BlueprintTweaks](https://thunderstore.io/c/dyson-sphere-program/p/kremnev8/BlueprintTweaks/) 的 `拖拽拆除` 功能(等待 limoka 合并 [Pull Request](https://github.com/limoka/DSP-Mods/pull/133)):
|
||||
* 地面绘制现在已正确
|
||||
* 拆除逻辑遵循官方实现,避免潜在崩溃可能
|
||||
* 修正了 CommonAPI 的补丁,现在快捷键设置可以如预期保存了,不好意思上一版本实现有误
|
||||
* 1.4.4
|
||||
* `记住上次退出时的窗口位置和大小`:修复对游戏补丁0.10.33的兼容性
|
||||
* `物流站实时信息面板`:尝试修复一个显示问题
|
||||
* 对[CommonAPI](https://thunderstore.io/c/dyson-sphere-program/p/CommonAPI/CommonAPI/)临时打补丁,修复快捷键设置未能保存到配置文件的已知问题(其[PR](https://github.com/limoka/CommonAPI/pull/14)仍未合并)
|
||||
* 1.4.3
|
||||
* `交替建造电力感应塔和无线输电塔`:
|
||||
* 修复了在最新游戏补丁中的错误实现
|
||||
* 由于新的矩形建造机制,现在无法使用电力感应塔作为起始电塔
|
||||
* `宇宙视图矿脉数量显示`:兼容添加矿脉类型的mod
|
||||
* `物流站实时信息面板`:尝试修复可能的崩溃问题
|
||||
* 1.4.2
|
||||
* 修复了一个崩溃问题
|
||||
* 1.4.1
|
||||
* 修复了与最新游戏补丁的兼容性问题
|
||||
* 1.4.0
|
||||
* 支持游戏版本 0.10.33,移除了一些功能:
|
||||
* 移除`放大鼠标指针`:Unity 2022 读取系统设置里的鼠标指针大小,软件渲染不再影响其大小
|
||||
* 移除`设置使用的CPU线程`:因为官方已支持此功能
|
||||
* `拆除蓝图选中的建筑`:修复了从物流站中掉落的物品丢失增产点数的问题
|
||||
* `保存蓝图前对建筑进行排序`:改进了排序规则
|
||||
* `星图过滤器`:现在星系编号(按星系生成顺序)显示为前缀
|
||||
* 由于缺乏维护,整合内置了[Planet Vein Untilization](https://thunderstore.io/c/dyson-sphere-program/p/testpushpleaseignore/Planet_Vein_Utilization/),并修复了一些小问题
|
||||
* `移除部分不影响游戏逻辑的建造条件`:修复了错误的逻辑
|
||||
* `物流站实时信息面板`:修复了一些显示问题
|
||||
* 修复了配置窗口标签按钮的背景图像问题
|
||||
* 现在使用C#的`Debug`配置构建,以避免`Release`配置中的优化导致的一些问题
|
||||
* 1.3.7
|
||||
* `重新初始化行星`: 修复可能导致崩溃的问题
|
||||
* `自动配置物流站`: 增加`设置默认远程逻辑为仓储`
|
||||
* 1.3.6
|
||||
* `拆除蓝图选中的建筑`:
|
||||
* 修复了拆除虚影建筑时崩溃的问题
|
||||
* 重命名为`蓝图复制模式快捷键`,同时添加了选择所有建筑的快捷键(默认为Ctrl+A)
|
||||
* `允许物流站和大型采矿机物品溢出`:现在也适用于物流控制面板
|
||||
* `调整建筑缓冲区`:为2个新建筑添加缓冲区调整
|
||||
* `弹射太阳帆缓冲区数量`:范围5-400(步进值为5),默认值为20(与游戏相同)
|
||||
* `发射井火箭缓冲区数量`:范围1-20,默认值为20(与游戏相同)
|
||||
* 1.3.5
|
||||
* `基于mod管理器配置档案的存档文件夹`:修复游戏启动时崩溃的问题
|
||||
* 1.3.4
|
||||
* `自动配置物流站`:修复了高级采矿机和物流配送器的一些设置未被正确应用的问题
|
||||
* 1.3.3
|
||||
* `星图过滤器`:当过滤器UI显示时隐藏顶部重叠窗口
|
||||
* `自动配置物流站`:现在可以为战场分析基站设置最大充能功率
|
||||
* `重新初始化行星`:修复崩溃问题
|
||||
* `航行时自动导航`:
|
||||
* 添加快速启用/禁用`自动巡航`的按钮
|
||||
* 如果所需科技未研究则不自动使用翘曲器
|
||||
* `拆除蓝图选中建筑`:修复传送带连接建筑意外被拆除的问题
|
||||
* `基于mod管理器配置档案的存档文件夹`:修复与[SaveTheWindows](https://thunderstore.io/c/dyson-sphere-program/p/starfi5h/SaveTheWindows/)的兼容性
|
||||
* `物流存储容量控制改进`和`允许物流站和大型采矿机物品溢出`:
|
||||
* 如果物流存储容量已经超过升级后的最大容量,则在升级`物流运输机容量`时不会按比例提升
|
||||
* 粘贴蓝图时物流存储容量将降低至科技容量限制
|
||||
* `物流站实时信息面板`:支持修改物流站槽位数的mod
|
||||
* 1.3.2
|
||||
* 新功能:`在和平模式下隐藏战斗相关科技`
|
||||
* 新按钮:`使用元数据解锁所有科技`
|
||||
* 在星图过滤器中添加复选框以合并结果
|
||||
* 修复了一些星图矿脉/行星过滤条件
|
||||
* 修复了在和平模式下`初始化本行星`导致的崩溃问题
|
||||
* 修复了与`NebulaMultiplayerMod`的兼容性问题
|
||||
* 1.3.1
|
||||
* 修复了在星图上点击新增的下拉框时部分UI元素被隐藏的问题
|
||||
* 修复了未启用`显示星系名称快捷键`时星系名称过滤器不生效的问题
|
||||
* `拆除蓝图选中的建筑`:修复了物流站中的物品未被丢出的问题
|
||||
* 调整了星系名称过滤器中的行星类型列表
|
||||
* 1.3.0
|
||||
* 在星图上添加新功能:
|
||||
* 添加星系名过滤器,现在可以按矿物或行星类型过滤显示的星系名
|
||||
* 添加了一个下拉框用以切换显示所有星系的距离和/或行星数量
|
||||
* `切割传送带`:修复了输入问题
|
||||
* `启用显示所有星系名称的快捷键`:修复了在未打开星图视图时读取切换键的问题
|
||||
* `拆除蓝图选中的建筑`:修复了预建造建筑未被拆除的问题
|
||||
* `记住上次退出时的窗口位置和大小`:优化实现
|
||||
* `自动配置物流站`: 增加了一个选项`限制自动补充数量为配置的值`
|
||||
* 优化了一些UI代码
|
||||
* 1.2.20
|
||||
* 新功能:`拆除蓝图选中的建筑`
|
||||
* 在蓝图复制模式下按快捷键拆除选中的建筑
|
||||
* 默认快捷键是Ctrl+X,可以在系统选项面板中设置
|
||||
* 新功能:`自动配置物流站`
|
||||
* 自动配置的建筑包括:物流配送器、行星物流站、星际物流站、高级采矿机
|
||||
* `夜间日光灯`:再次修复了光照角度未正确更新的问题
|
||||
* 1.2.19
|
||||
* 新功能:`调整建筑输入缓冲`
|
||||
* 工厂配方计算公式,在`工厂配方缓冲时间倍率秒数x每秒需要的原料数量`和`工厂配方缓冲最小倍率x每生产一次配方需要的原料数量`中取更大的那个值
|
||||
* `工厂配方缓冲时间倍率(秒)`:范围2-10,默认为4(同游戏)
|
||||
* `工厂配方缓冲最小倍率`:范围2-10,默认为2(同游戏)
|
||||
* 研究站矩阵合成模式计算公式,默认缓存`研究站矩阵合成模式缓存数量`个,当使用自演化研究站时,如果配方的原始生产时间不大于9秒,则增加`自演化研究站矩阵额外缓冲数量`*(`研究站速度倍率`-1)
|
||||
* `研究站矩阵合成模式缓存数量`:范围2-20,默认为6(同游戏)
|
||||
* `自演化研究站矩阵额外缓冲数量`:范围1-10,默认为3(同游戏)
|
||||
* `研究站科研模式缓存数量`:范围2-20,默认为10(同游戏)
|
||||
* `射线接收器透镜缓冲数量`:范围1-20,默认为1(游戏默认为20)
|
||||
* 新功能:`启用显示所有星系名称的快捷键`
|
||||
* 新增一个快捷键,按住后始终在星图显示所有星系名称,默认为`Alt`
|
||||
* 新增一个快捷键,在星图视图切换三种星系名称显示状态:`原始显示状态`,`显示所有名称`,`隐藏所有名称`,默认为`Tab`,关闭星图时会恢复到原始状态
|
||||
* `切割传送带`:修复了实体逻辑连接未切断导致复制为蓝图时传送带未被切断的问题。
|
||||
* 1.2.18
|
||||
* `保护矿脉不会耗尽`:优化实现,当`矿物利用`升级到390级以上时消耗速度变为0时,矿脉将不再被保护。
|
||||
* `夜间日光灯`:修复了光照角度未正确更新的问题。
|
||||
* 1.2.17
|
||||
* 修复了`保护矿脉不会耗尽`导致矿脉状态显示错误和矿脉未被消耗的错误实现
|
||||
* 1.2.16
|
||||
* 新功能:`切割传送带`
|
||||
* 按快捷键切割光标位置的传送带
|
||||
* 默认快捷键是Alt+X,可以在系统选项面板中设置
|
||||
* 新功能:`基于mod管理器配置档案名`
|
||||
* 选项文件存储在`Options\<ProfileName>.xml`中
|
||||
* 修复了与游戏更新0.10.32.25779的兼容性
|
||||
* 1.2.15
|
||||
* `脱离网格建造和小角度旋转`:修复了与0.10.32.25682的兼容性 (#57)
|
||||
* `物流塔存储数量限制控制改进`:修复了可能导致崩溃的问题 (#54)
|
||||
* 1.2.14
|
||||
* 修正设置窗口右上角多出一个菜单图标的问题
|
||||
* `当可用节点全部造完时停止弹射`:修复了与`戴森球计划 v0.10.32.25496`的兼容性
|
||||
* 1.2.13
|
||||
* `用于自动购买黑雾物品的传送带信号`:修复了可能导致崩溃的问题
|
||||
* `物流控制面板改进`:现在也自动将拿着的物品设为筛选条件
|
||||
* 修复了UI面板上的对齐问题
|
||||
* 1.2.12
|
||||
* `只建造节点不建造框架`:修复了关闭此功能时框架不进行建造的问题
|
||||
* `拖动建造电线杆时自动使用最大连接距离间隔`:修复了某些位置无法放置单个电线杆的问题
|
||||
* 1.2.11
|
||||
* 修复了游戏更新导致的提示按钮鼠标悬停时不显示提示文字的问题
|
||||
* 1.2.10
|
||||
* `设置使用的CPU线程`:修复了对没有超线程的CPU的大小核检查
|
||||
* `初始化戴森球`和`快速拆除戴森壳`:修复了在戴森球面板激活时可能导致崩溃的问题,以及显示错误的问题。
|
||||
* 1.2.9
|
||||
* `保护矿脉不会耗尽`:
|
||||
* 修复了矿脉保护导致崩溃的问题(#50)
|
||||
* 修复了配置中的最小采油速度不起作用的问题(#50)
|
||||
* 修复了无限资源模式下油井保护导致无法采油的问题(#52)
|
||||
* 1.2.8
|
||||
* 新功能:`储液罐快速注入和抽取液体`
|
||||
* 你可以设置储液罐操作速度的倍率
|
||||
* 影响手动注入和抽取,以及从储液罐上层传输到下层的速度
|
||||
* 在游戏窗口标题中追加mod配置档案名的修复:
|
||||
* 修复了多实例启动时窗口标题未正确设置的问题
|
||||
* 修复了启用BepInEx调试控制台时窗口标题未正确设置的问题
|
||||
* `物流运输站实时信息面板`:修复了一个物品状态条意外显示的问题
|
||||
* 1.2.7
|
||||
* 修复了一些小问题
|
||||
* 1.2.6
|
||||
* `记住上次退出时的窗口位置和大小`
|
||||
* 修复了即使选项被禁用也恢复窗口位置的问题
|
||||
* 修复了窗口最小化时关闭游戏导致窗口位置被错误记录的问题
|
||||
* 1.2.5
|
||||
* 新功能:`设置进程优先级`
|
||||
* 新功能:`设置使用的CPU线程`
|
||||
* `拖动建造电线杆时自动使用最大连接距离间隔`:添加一个新的设置项`交替建造电力感应塔和无线输电塔`
|
||||
* 1.2.4
|
||||
* `夜间日光灯`:
|
||||
* 修复了航行时闪烁的问题
|
||||
* 现在可以配置入射光线角度了
|
||||
* `放大鼠标指针`:修复已知问题
|
||||
* `买断科技也同时买断所有前置科技`:修复了数据错误警告弹窗的问题
|
||||
* 不再对`BulletTime`的速度控制打补丁,因为`BulletTime`已更新支持可配置最大速度
|
||||
* 一些小修复和调整
|
||||
* 1.2.3
|
||||
* `物流运输站实时信息面板`:修复了物品数量超过容量限制时条长度不匹配的问题
|
||||
* `夜间日光灯`:修复了不起作用的问题
|
||||
* 1.2.2
|
||||
* `物流运输站实时信息面板`:修复了文本颜色不匹配的问题
|
||||
* `逻辑帧倍率`:将默认快捷键设置为`Ctrl`+`-/+`,以避免与其他快捷键冲突
|
||||
* 1.2.1
|
||||
* `脱离网格建造和小角度旋转`:
|
||||
* 修复了传送带脱离网格建造的默认快捷键
|
||||
* 修复了坐标显示问题
|
||||
* 1.2.0
|
||||
* 新功能:`逻辑帧倍率`
|
||||
* 这将改变游戏运行速度,最慢0.1倍,最快10倍
|
||||
* 设置了一对快捷键(`-`和`+`),可以-/+0.5倍改变逻辑帧倍率
|
||||
* 注意:
|
||||
* 高逻辑帧倍率不能保证稳定性,特别是在工厂负载较重时
|
||||
* 这不会影响一些游戏动画
|
||||
* 当在`Auxilaryfunction`mod中设置游戏速度时,此功能将被禁用
|
||||
* 当安装了`BulletTime`mod时,此功能将被隐藏,但会对`BulletTime`的速度控制打补丁,使其最大速度变为10倍
|
||||
* `脱离网格建造和小角度旋转`:由于与新游戏更新中的快捷键冲突,传送带脱离网格建造的快捷键默认更改为`Ctrl`,并且现在可以在系统选项中设置
|
||||
* `物流运输站实时信息面板`:修复了一个崩溃问题
|
||||
* `戴森球自动快速建造`:修复了可能出现的错误生产记录
|
||||
* 代码重构,以获得更好的可维护性
|
||||
* 1.1.6
|
||||
* 新功能:`放大鼠标指针`
|
||||
* 注意:这将启用软件指针模式,可能会在CPU负载较重时导致鼠标移动延迟
|
||||
* 新功能:`物流运输站实时信息面板`
|
||||
* 注意:如果你启用了`Auxilaryfunction`中的`展示物流站信息`,此功能将被隐藏
|
||||
* 修复了`戴森球自动快速建造`未生成太阳帆生产记录的问题
|
||||
* 移除了AssetBundle的使用,将所有图标移入`Assembly资源`,以获得更好的灵活性
|
||||
* 1.1.5
|
||||
* 新功能:`物流控制面板改进`
|
||||
* 打开面板时自动将鼠标指向物品设为筛选条件
|
||||
* 在控制面板物流塔列表中右键点击物品图标快速设置为筛选条件
|
||||
* 新功能:`戴森球自动快速建造速度倍率`
|
||||
* 注意:这仅适用于沙盒模式下的`戴森球自动快速建造`功能
|
||||
* 新功能:`基于mod管理器配置档案名的存档文件夹`
|
||||
* 存档文件会存储在`Save\<ProfileName>`文件夹中
|
||||
* 如果匹配默认配置档案名则使用原始存档位置
|
||||
* `快速建造和拆除堆叠研究站`:现在也支持储物仓和储液罐
|
||||
* `允许调整游戏窗口大小`:在应用游戏选项时保持窗口可调整大小
|
||||
* `记住上次退出时的窗口位置和大小`:如果分辨率相关的配置项未改变,则在应用游戏选项时不调整窗口大小
|
||||
* 自动调整面板大小适应内容,以更好地支持多语言和依赖于UX助手配置面板功能的mod
|
||||
* 1.1.4
|
||||
* 修复了`移除部分不影响游戏逻辑的建造条件`
|
||||
* 1.1.3
|
||||
* 界面文本现在完全跟随游戏语言设置改变
|
||||
* 修复了配置面板中勾选框的鼠标悬停区域
|
||||
* 修复了`加载和平模式存档时将其转换为战斗模式`不起作用的问题
|
||||
* 1.1.2
|
||||
* `用于自动购买黑雾物品的传送带信号`: 总是将传送带信号添加到面板,以修复禁用时传送带图标丢失的问题。
|
||||
* 1.1.1
|
||||
* 修复了资源包加载问题
|
||||
* 1.1.0
|
||||
* `可用节点全部造完时停止弹射`: 当所有戴森球节点都造完时,在弹射器面板上显示`没有可建造节点`
|
||||
* 如果使用mod管理器(`Thunderstore Mod Manager`或`r2modman`)启动游戏,在游戏窗口标题中追加mod配置档案名
|
||||
* 新功能:
|
||||
* `买断科技也同时买断所有前置科技`:可以批量买断科技及其所有前置科技。所有未解锁的科技/升级都会显示买断按钮。
|
||||
* `用于自动购买黑雾物品的传送带信号`,启用时:
|
||||
* 在信号面板上添加了6个传送带信号,可以用于自动购买黑雾道具。
|
||||
* 生成的物品堆叠数为4。
|
||||
* 兑换比率遵循原始游戏设计,即:
|
||||
* 1个元宇宙 = 20个黑雾矩阵
|
||||
* 1个元宇宙 = 60个能量碎片
|
||||
* 1个元宇宙 = 30个硅基神经元
|
||||
* 1个元宇宙 = 30个负熵奇点
|
||||
* 1个元宇宙 = 30个物质重组器
|
||||
* 1个元宇宙 = 10个核心素
|
||||
* 1.0.26
|
||||
* 新功能:
|
||||
* 在升级面板上恢复`分拣器货物堆叠`的升级
|
||||
* 将`分拣器货物堆叠`设为未研究状态
|
||||
* `保护矿脉不会耗尽`配置的改动:
|
||||
* 现在默认矿脉数量保护在1000
|
||||
* 最大矿脉数量改为10000,最大采油速度改为10.0/s
|
||||
* 1.0.25
|
||||
* 修复了`不渲染工厂建筑实体(除了传送带和分拣器)`启用时无法点穿工厂实体的问题
|
||||
* 1.0.24
|
||||
* `不渲染工厂建筑实体(除了传送带和分拣器)`的改动
|
||||
* 在配置面板中添加了一个快捷键来切换此功能
|
||||
* 现在也可以点击到分拣器了
|
||||
* 新功能:`拖动建造电线杆时自动使用最大连接距离间隔`
|
||||
* 新功能:`允许物流塔和大型采矿机物品溢出`
|
||||
* 当尝试塞入手中物品时允许溢出
|
||||
* 允许`物流塔存储数量限制控制改进`超过科技容量限制
|
||||
* 在加载游戏时移除物流塔容量限制检查
|
||||
* 1.0.23
|
||||
* 新功能:
|
||||
* `不渲染工厂建筑实体(除了传送带和分拣器)`
|
||||
* 这使得玩家可以点穿工厂实体直接点到传送带
|
||||
* 在任意位置`打开黑雾通讯器`
|
||||
* 传送带现在可以脱离网格建造了,通过按住`切换分流器样式`的快捷键(默认`Tab`)
|
||||
* 为`自动巡航`添加一个子选项`自动加速`
|
||||
* `自动巡航`现在在核心能量至少80%时才加速
|
||||
* 1.0.22
|
||||
* 修复了`快速建造和拆除堆叠研究站`导致的崩溃问题
|
||||
* 1.0.21
|
||||
* 修复了`脱离网格建造和小角度旋转`在最新游戏更新后无法小角度旋转的问题
|
||||
* 修复了`航行时自动导航`和`自动巡航`的一些问题。现在只有能量至少10%时才加速,能量至少50%时才启动曲速
|
||||
* 1.0.20
|
||||
* 修复了`快速建造和拆除堆叠研究站`和`无条件建造`同时启用时可能导致的逻辑死循环问题
|
||||
* 修复了在战斗模式下`初始化本行星`导致的崩溃问题
|
||||
* 1.0.19
|
||||
* 新功能:
|
||||
* `快速建造和拆除堆叠研究站`
|
||||
* `保护矿脉不会耗尽`
|
||||
* 默认矿脉数量保护于剩余100,采油速保护于速度1.0/s,你可以在配置文件中自行设置。
|
||||
* 当达到保护值时,矿脉和油井将不再被开采。
|
||||
* 关闭此功能以恢复开采,一般是当你在`矿物利用`上有足够的等级时。
|
||||
* 移除了`自动巡航`的默认快捷键,以避免误操作。如有需要请手动在系统选项窗口中设置。
|
||||
* 1.0.18
|
||||
* 修复了以黑雾巢穴为目标时导致崩溃的问题
|
||||
* 当黑雾巢穴是目标时,自动导航不会绕过它
|
||||
* 1.0.17
|
||||
* 新功能:`航行时自动导航`,想法来自[CruiseAssist](https://dsp.thunderstore.io/package/tanu/CruiseAssist/)及其扩展[AutoPilot](https://dsp.thunderstore.io/package/tanu/AutoPilot/)
|
||||
* 它会保持伊卡洛斯飞向目标星球
|
||||
* 它会尝试绕过途中的任何障碍物(行星、恒星或黑雾巢穴)
|
||||
* 此外,还有一个快捷键可以在系统选项窗口中设置,用于切换`自动巡航`,实现完全自动化的飞行至目标星球。
|
||||
* 当你选择目标星球后,自动巡航就会开始
|
||||
* 如果目标星球距离过远会自动使用曲速(超过5AU),你可以在面板上更改这个值。
|
||||
* 它会在接近目标星球时减速,以避免发生越过目标的情况
|
||||
* 修复了最新游戏更新后`当可用节点全部造完时停止弹射`引起崩溃问题
|
||||
* `脱离网格建造和小角度旋转`:如果Z坐标为零则从显示中隐藏
|
||||
* 1.0.16
|
||||
* 添加了对CommonAPI的包依赖(上个版本忘记加了)
|
||||
* 新功能:`隐藏沙土数量变动的提示`
|
||||
* 1.0.15
|
||||
* 将快捷键设置移动到系统选项窗口,依赖于[CommonAPI](https://dsp.thunderstore.io/package/CommonAPI/CommonAPI)
|
||||
* 在星图视图中启用`隐藏UI`功能(默认按键为`F11`)
|
||||
* 新功能:`在流速计中将堆叠物品视为单个物品`
|
||||
* 1.0.14
|
||||
* 再次尝试修复`初始化本行星`导致的崩溃问题
|
||||
* `脱离网格建造和小角度旋转`:现在显示建筑Z坐标,并将精度调整为小数点后4位
|
||||
* 1.0.13
|
||||
* `脱离网格建造和小角度旋转`:现在在建造预览和建筑信息面板上显示建筑坐标(相对于网格)
|
||||
* 将元数据提取的最大数量增加到20000(原来为2000)
|
||||
* 将玩家指令队列的容量增加到128(原来为16)
|
||||
* 修复了游戏更新导致的问题
|
||||
* `移除部分不影响游戏逻辑的建造条件`:修复了一些条件未被移除的问题
|
||||
* `初始化本行星`:修复了崩溃问题
|
||||
* 1.0.12
|
||||
* 修复了当`当可用节点全部造完时停止弹射`选项启用时,瞄准偶数轨道的弹射器停止工作的bug
|
||||
* 1.0.11
|
||||
* 移除`更好的自动保存机制`,因为与DSPModSave和其他一些mod冲突
|
||||
* 1.0.10
|
||||
* 修复了一个按钮显示错误
|
||||
* 修复了`物流塔存储数量限制控制改进`启用时可能导致的崩溃问题
|
||||
* 1.0.9
|
||||
* 新功能:`更好的自动保存机制`
|
||||
* 自动存档会以星区地址和日期时间组合为文件名存储在'Save\AutoSaves'文件夹中
|
||||
* 注意:此功能会在保存/读取菜单按最后修改时间对存档进行排序,因此你不再需要[DSP_Save_Game_Sorter]了
|
||||
* 1.0.8
|
||||
* 新功能:`物流塔存储数量限制控制改进`
|
||||
* 1.0.7
|
||||
* 修复了选择英文和中文以外的语言时的崩溃问题
|
||||
* 黑雾更新后使用和平模式保存的存档现在也可以转换为战斗模式了
|
||||
* 1.0.6
|
||||
* 在加载旧存档时将其转换为战斗模式
|
||||
* 1.0.5
|
||||
* 支持游戏版本0.10.28.20759
|
||||
* 保存蓝图前对建筑进行排序,以减少生成的蓝图数据大小
|
||||
* 1.0.4
|
||||
* 添加了新功能:`脱离网格建造和小角度旋转`
|
||||
* 修复了当功能启用但游戏使用不同的mod配置文件启动时窗口位置无法正确恢复和不可拖动改变大小的问题
|
||||
* 1.0.3
|
||||
* 添加了新功能:`快速建造轨道采集器`
|
||||
* 为`初始化行星`,`快速拆除所有建筑`,`初始化戴森球`和`快速拆除戴森壳`添加了确认弹窗
|
||||
* 修复了`移除建造数量和范围限制`在建造大量传送带时可能导致的错误
|
||||
* 修复了在不使用游戏内菜单退出游戏时窗口位置无法正确保存的问题
|
||||
* 1.0.2
|
||||
* 重新设计了配置面板,使布局更清晰
|
||||
* 添加了两个新选项:
|
||||
* 可调整游戏窗口大小(可最大化和拖动边框)
|
||||
* 记住上次退出时的窗口位置和大小
|
||||
* 1.0.1
|
||||
* 修复了返回标题界面后设置按钮文本和提示信息不正确的问题
|
||||
* 修复了`当可用节点全部造完时停止弹射`选项启用时返回标题界面可能导致崩溃的问题
|
||||
* 添加了一个补丁,修复了`矿物利用`升级到8000级以上时弹出警告的bug
|
||||
* 1.0.0
|
||||
* 初始版本
|
||||
* 从[MechaDronesTweaks](https://dsp.thunderstore.io/package/soarqin/MechaDronesTweaks/)和[CheatEnabler](https://dsp.thunderstore.io/package/soarqin/CheatEnabler/)移动了部分功能过来
|
||||
|
||||
</details>
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace UXAssist.Common;
|
||||
|
||||
public class GameLogic : PatchImpl<GameLogic>
|
||||
{
|
||||
public static Action OnDataLoaded;
|
||||
public static Action OnGameBegin;
|
||||
public static Action OnGameEnd;
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(VFPreload), nameof(VFPreload.InvokeOnLoadWorkEnded))]
|
||||
public static void VFPreload_InvokeOnLoadWorkEnded_Postfix()
|
||||
{
|
||||
OnDataLoaded?.Invoke();
|
||||
}
|
||||
|
||||
[HarmonyPostfix, HarmonyPriority(Priority.First)]
|
||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.Begin))]
|
||||
public static void GameMain_Begin_Postfix()
|
||||
{
|
||||
OnGameBegin?.Invoke();
|
||||
}
|
||||
|
||||
[HarmonyPostfix, HarmonyPriority(Priority.Last)]
|
||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.End))]
|
||||
public static void GameMain_End_Postfix()
|
||||
{
|
||||
OnGameEnd?.Invoke();
|
||||
}
|
||||
}
|
||||
@@ -122,14 +122,14 @@ public static class I18N
|
||||
_initialized = true;
|
||||
Apply();
|
||||
}
|
||||
|
||||
|
||||
[HarmonyPostfix, HarmonyPriority(Priority.Last), HarmonyPatch(typeof(Localization), nameof(Localization.LoadLanguage))]
|
||||
private static void Localization_LoadLanguage_Postfix(int index)
|
||||
{
|
||||
if (!_initialized) return;
|
||||
ApplyLanguage(index);
|
||||
}
|
||||
|
||||
|
||||
[HarmonyPostfix, HarmonyPriority(Priority.Last), HarmonyPatch(typeof(Localization), nameof(Localization.NotifyLanguageChange))]
|
||||
private static void Localization_NotifyLanguageChange_Postfix()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
using BepInEx.Configuration;
|
||||
using CommonAPI.Systems;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UXAssist.Common;
|
||||
|
||||
public static class KeyBindings
|
||||
{
|
||||
public static PressKeyBind RegisterKeyBinding(BuiltinKey key)
|
||||
{
|
||||
return CustomKeyBindSystem.RegisterKeyBindWithReturn<PressKeyBind>(key);
|
||||
}
|
||||
public static CombineKey FromKeyboardShortcut(KeyboardShortcut shortcut)
|
||||
{
|
||||
byte mod = 0;
|
||||
foreach (var modifier in shortcut.Modifiers)
|
||||
{
|
||||
mod |= modifier switch
|
||||
{
|
||||
KeyCode.LeftShift => 1,
|
||||
KeyCode.RightShift => 1,
|
||||
KeyCode.LeftControl => 2,
|
||||
KeyCode.RightControl => 2,
|
||||
KeyCode.LeftAlt => 4,
|
||||
KeyCode.RightAlt => 4,
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
|
||||
return new CombineKey((int)shortcut.MainKey, mod, ECombineKeyAction.OnceClick, false);
|
||||
}
|
||||
|
||||
public static bool IsKeyPressing(this PressKeyBind keyBind)
|
||||
{
|
||||
var defBind = keyBind.defaultBind;
|
||||
var overrideKey = VFInput.override_keys[defBind.id];
|
||||
return overrideKey.IsNull() ? defBind.key.GetKey() : overrideKey.GetKey();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace UXAssist.Common;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
|
||||
public class PatchGuidAttribute(string guid) : Attribute
|
||||
{
|
||||
public string Guid { get; } = guid;
|
||||
}
|
||||
|
||||
public enum PatchCallbackFlag
|
||||
{
|
||||
// By default, OnEnable() is called After patch applied, set this flag to call it before patch is applied
|
||||
CallOnEnableBeforePatch,
|
||||
// By default, OnDisable() is called Before patch removed, set this flag to call it after patch is removed
|
||||
CallOnDisableAfterUnpatch,
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
|
||||
public class PatchSetCallbackFlagAttribute(PatchCallbackFlag flag) : Attribute
|
||||
{
|
||||
public PatchCallbackFlag Flag { get; } = flag;
|
||||
}
|
||||
|
||||
public class PatchImpl<T> where T : PatchImpl<T>, new()
|
||||
{
|
||||
protected static T Instance { get; } = new();
|
||||
|
||||
protected Harmony _patch;
|
||||
|
||||
public static void Enable(bool enable)
|
||||
{
|
||||
var thisInstance = Instance;
|
||||
if (enable)
|
||||
{
|
||||
if (thisInstance._patch != null) return;
|
||||
var guid = typeof(T).GetCustomAttribute<PatchGuidAttribute>()?.Guid ?? $"PatchImpl.{typeof(T).FullName ?? typeof(T).ToString()}";
|
||||
var callOnEnableBefore = typeof(T).GetCustomAttributes<PatchSetCallbackFlagAttribute>().Any(n => n.Flag == PatchCallbackFlag.CallOnEnableBeforePatch);
|
||||
if (callOnEnableBefore) thisInstance.OnEnable();
|
||||
thisInstance._patch = Harmony.CreateAndPatchAll(typeof(T), guid);
|
||||
if (!callOnEnableBefore) thisInstance.OnEnable();
|
||||
return;
|
||||
}
|
||||
if (thisInstance._patch == null) return;
|
||||
var callOnDisableAfter = typeof(T).GetCustomAttributes<PatchSetCallbackFlagAttribute>().Any(n => n.Flag == PatchCallbackFlag.CallOnDisableAfterUnpatch);
|
||||
if (!callOnDisableAfter) thisInstance.OnDisable();
|
||||
thisInstance._patch.UnpatchSelf();
|
||||
thisInstance._patch = null;
|
||||
if (callOnDisableAfter) thisInstance.OnDisable();
|
||||
}
|
||||
|
||||
public static Harmony GetHarmony() => Instance._patch;
|
||||
|
||||
protected virtual void OnEnable() { }
|
||||
protected virtual void OnDisable() { }
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UXAssist.Common;
|
||||
|
||||
public static class Util
|
||||
{
|
||||
public static Type[] GetTypesFiltered(Assembly assembly, Func<Type, bool> predicate)
|
||||
{
|
||||
return assembly.GetTypes().Where(predicate).ToArray();
|
||||
}
|
||||
|
||||
public static Type[] GetTypesInNamespace(Assembly assembly, string nameSpace) => GetTypesFiltered(assembly, t => string.Equals(t.Namespace, nameSpace, StringComparison.Ordinal));
|
||||
|
||||
public static byte[] LoadEmbeddedResource(string path, Assembly assembly = null)
|
||||
{
|
||||
if (assembly == null)
|
||||
{
|
||||
assembly = Assembly.GetCallingAssembly();
|
||||
}
|
||||
var info = assembly.GetName();
|
||||
var name = info.Name;
|
||||
using var stream = assembly.GetManifestResourceStream($"{name}.{path.Replace('/', '.')}")!;
|
||||
var buffer = new byte[stream.Length];
|
||||
_ = stream.Read(buffer, 0, buffer.Length);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static Texture2D LoadTexture(string path)
|
||||
{
|
||||
var fileData = File.ReadAllBytes(path);
|
||||
var tex = new Texture2D(2, 2);
|
||||
tex.LoadImage(fileData);
|
||||
return tex;
|
||||
}
|
||||
|
||||
public static Sprite LoadSprite(string path)
|
||||
{
|
||||
var tex = LoadTexture(path);
|
||||
return Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
|
||||
}
|
||||
|
||||
public static Texture2D LoadEmbeddedTexture(string path, Assembly assembly = null)
|
||||
{
|
||||
var fileData = LoadEmbeddedResource(path, assembly);
|
||||
var tex = new Texture2D(2, 2);
|
||||
tex.LoadImage(fileData);
|
||||
return tex;
|
||||
}
|
||||
|
||||
public static Sprite LoadEmbeddedSprite(string path, Assembly assembly = null)
|
||||
{
|
||||
var tex = LoadEmbeddedTexture(path, assembly);
|
||||
return Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
|
||||
}
|
||||
|
||||
public static string PluginFolder(Assembly assembly = null) => Path.GetDirectoryName((assembly == null ? Assembly.GetCallingAssembly() : assembly).Location);
|
||||
}
|
||||
+129
-51
@@ -3,55 +3,91 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace UXAssist.Common;
|
||||
|
||||
[Flags]
|
||||
public enum WindowStyles: int
|
||||
{
|
||||
WS_BORDER = 0x00800000,
|
||||
WS_CAPTION = 0x00C00000,
|
||||
WS_CHILD = 0x40000000,
|
||||
WS_CHILDWINDOW = 0x40000000,
|
||||
WS_CLIPCHILDREN = 0x02000000,
|
||||
WS_CLIPSIBLINGS = 0x04000000,
|
||||
WS_DISABLED = 0x08000000,
|
||||
WS_DLGFRAME = 0x00400000,
|
||||
WS_GROUP = 0x00020000,
|
||||
WS_HSCROLL = 0x00100000,
|
||||
WS_ICONIC = 0x20000000,
|
||||
WS_MAXIMIZE = 0x01000000,
|
||||
WS_MAXIMIZEBOX = 0x00010000,
|
||||
WS_MINIMIZE = 0x20000000,
|
||||
WS_MINIMIZEBOX = 0x00020000,
|
||||
WS_OVERLAPPED = 0x00000000,
|
||||
WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
|
||||
WS_POPUP = unchecked((int)0x80000000),
|
||||
WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU,
|
||||
WS_SIZEBOX = 0x00040000,
|
||||
WS_SYSMENU = 0x00080000,
|
||||
WS_TABSTOP = 0x00010000,
|
||||
WS_THICKFRAME = 0x00040000,
|
||||
WS_TILED = 0x00000000,
|
||||
WS_TILEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
|
||||
WS_VISIBLE = 0x10000000,
|
||||
WS_VSCROLL = 0x00200000
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum WindowLongFlags: int
|
||||
{
|
||||
GWL_EXSTYLE = -20,
|
||||
GWLP_HINSTANCE = -6,
|
||||
GWLP_HWNDPARENT = -8,
|
||||
GWLP_ID = -12,
|
||||
GWL_STYLE = -16,
|
||||
GWLP_USERDATA = -21,
|
||||
GWLP_WNDPROC = -4,
|
||||
DWLP_DLGPROC = 0x4,
|
||||
DWLP_MSGRESULT = 0,
|
||||
DWLP_USER = 0x8
|
||||
}
|
||||
|
||||
public static class WinApi
|
||||
{
|
||||
#region Styles
|
||||
|
||||
public const int WS_BORDER = 0x00800000;
|
||||
public const int WS_CAPTION = 0x00C00000;
|
||||
public const int WS_CHILD = 0x40000000;
|
||||
public const int WS_CHILDWINDOW = 0x40000000;
|
||||
public const int WS_CLIPCHILDREN = 0x02000000;
|
||||
public const int WS_CLIPSIBLINGS = 0x04000000;
|
||||
public const int WS_DISABLED = 0x08000000;
|
||||
public const int WS_DLGFRAME = 0x00400000;
|
||||
public const int WS_GROUP = 0x00020000;
|
||||
public const int WS_HSCROLL = 0x00100000;
|
||||
public const int WS_ICONIC = 0x20000000;
|
||||
public const int WS_MAXIMIZE = 0x01000000;
|
||||
public const int WS_MAXIMIZEBOX = 0x00010000;
|
||||
public const int WS_MINIMIZE = 0x20000000;
|
||||
public const int WS_MINIMIZEBOX = 0x00020000;
|
||||
public const int WS_OVERLAPPED = 0x00000000;
|
||||
public const int WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
|
||||
public const int WS_POPUP = unchecked((int)0x80000000);
|
||||
public const int WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU;
|
||||
public const int WS_SIZEBOX = 0x00040000;
|
||||
public const int WS_SYSMENU = 0x00080000;
|
||||
public const int WS_TABSTOP = 0x00010000;
|
||||
public const int WS_THICKFRAME = 0x00040000;
|
||||
public const int WS_TILED = 0x00000000;
|
||||
public const int WS_TILEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
|
||||
public const int WS_VISIBLE = 0x10000000;
|
||||
public const int WS_VSCROLL = 0x00200000;
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetWindowLong and SetWindowLong Flags
|
||||
|
||||
public const int GWL_EXSTYLE = -20;
|
||||
public const int GWLP_HINSTANCE = -6;
|
||||
public const int GWLP_HWNDPARENT = -8;
|
||||
public const int GWLP_ID = -12;
|
||||
public const int GWL_STYLE = -16;
|
||||
public const int GWLP_USERDATA = -21;
|
||||
public const int GWLP_WNDPROC = -4;
|
||||
public const int DWLP_DLGPROC = 0x4;
|
||||
public const int DWLP_MSGRESULT = 0;
|
||||
public const int DWLP_USER = 0x8;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Priorities
|
||||
|
||||
public const int HIGH_PRIORITY_CLASS = 0x00000080;
|
||||
public const int ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000;
|
||||
public const int NORMAL_PRIORITY_CLASS = 0x00000020;
|
||||
public const int BELOW_NORMAL_PRIORITY_CLASS = 0x00004000;
|
||||
public const int IDLE_PRIORITY_CLASS = 0x00000040;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Messages
|
||||
|
||||
public const int WM_CREATE = 0x0001;
|
||||
public const int WM_DESTROY = 0x0002;
|
||||
public const int WM_MOVE = 0x0003;
|
||||
public const int WM_SIZE = 0x0005;
|
||||
public const int WM_ACTIVATE = 0x0006;
|
||||
public const int WM_SETFOCUS = 0x0007;
|
||||
public const int WM_KILLFOCUS = 0x0008;
|
||||
public const int WM_ENABLE = 0x000A;
|
||||
public const int WM_CLOSE = 0x0010;
|
||||
public const int WM_QUIT = 0x0012;
|
||||
public const int WM_SYSCOMMAND = 0x0112;
|
||||
public const int WM_SIZING = 0x0214;
|
||||
public const int WM_MOVING = 0x0216;
|
||||
public const long SC_MOVE = 0xF010L;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Errors
|
||||
|
||||
private const int ERROR_INSUFFICIENT_BUFFER = 122;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Structs
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Rect
|
||||
@@ -59,6 +95,15 @@ public static class WinApi
|
||||
public int Left, Top, Right, Bottom;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Functions
|
||||
|
||||
public delegate IntPtr WndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("kernel32", ExactSpelling = true)]
|
||||
public static extern int GetLastError();
|
||||
|
||||
[DllImport("user32", CharSet = CharSet.Unicode)]
|
||||
public static extern int GetWindowLong(IntPtr hwnd, int nIndex);
|
||||
|
||||
@@ -66,14 +111,47 @@ public static class WinApi
|
||||
public static extern int SetWindowLong(IntPtr hwnd, int nIndex, int dwNewLong);
|
||||
|
||||
[DllImport("user32", CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
||||
|
||||
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpClassName, string lpWindowName);
|
||||
|
||||
[DllImport("user32", ExactSpelling = true, SetLastError = true)]
|
||||
public static extern int GetWindowThreadProcessId(IntPtr hwnd, out int lpdwProcessId);
|
||||
|
||||
[DllImport("user32", ExactSpelling = true)]
|
||||
public static extern bool GetWindowRect(IntPtr hwnd, out Rect lpRect);
|
||||
|
||||
|
||||
[DllImport("user32", ExactSpelling = true)]
|
||||
public static extern bool SetWindowPos(IntPtr hwnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, int flags);
|
||||
|
||||
|
||||
[DllImport("user32", CharSet = CharSet.Unicode)]
|
||||
public static extern bool SetWindowText(IntPtr hwnd, string lpString);
|
||||
|
||||
[DllImport("user32", ExactSpelling = true)]
|
||||
public static extern bool MoveWindow(IntPtr hWnd, int x, int y, int nWidth, int nHeight, bool bRepaint);
|
||||
|
||||
[DllImport("user32", ExactSpelling = true)]
|
||||
public static extern IntPtr MonitorFromRect([In] ref Rect lpRect, uint dwFlags);
|
||||
|
||||
[DllImport("kernel32", ExactSpelling = true, SetLastError = true)]
|
||||
public static extern IntPtr GetCurrentProcess();
|
||||
|
||||
[DllImport("kernel32", ExactSpelling = true)]
|
||||
public static extern int GetCurrentProcessId();
|
||||
|
||||
[DllImport("kernel32", ExactSpelling = true)]
|
||||
public static extern IntPtr GetConsoleWindow();
|
||||
|
||||
// GetPriorityClass and SetPriorityClass
|
||||
[DllImport("kernel32", ExactSpelling = true, SetLastError = true)]
|
||||
public static extern int GetPriorityClass(IntPtr hProcess);
|
||||
|
||||
[DllImport("kernel32", ExactSpelling = true, SetLastError = true)]
|
||||
public static extern bool SetPriorityClass(IntPtr hProcess, int dwPriorityClass);
|
||||
|
||||
[DllImport("user32", CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr SetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
|
||||
|
||||
[DllImport("user32", CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr CallWindowProc(IntPtr lpPrevWndFunc, IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1,322 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace UXAssist;
|
||||
|
||||
public static class DysonSpherePatch
|
||||
{
|
||||
public static ConfigEntry<bool> StopEjectOnNodeCompleteEnabled;
|
||||
public static ConfigEntry<bool> OnlyConstructNodesEnabled;
|
||||
private static Harmony _dysonSpherePatch;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
_dysonSpherePatch ??= Harmony.CreateAndPatchAll(typeof(DysonSpherePatch));
|
||||
StopEjectOnNodeCompleteEnabled.SettingChanged += (_, _) => StopEjectOnNodeComplete.Enable(StopEjectOnNodeCompleteEnabled.Value);
|
||||
OnlyConstructNodesEnabled.SettingChanged += (_, _) => OnlyConstructNodes.Enable(OnlyConstructNodesEnabled.Value);
|
||||
StopEjectOnNodeComplete.Enable(StopEjectOnNodeCompleteEnabled.Value);
|
||||
OnlyConstructNodes.Enable(OnlyConstructNodesEnabled.Value);
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
StopEjectOnNodeComplete.Enable(false);
|
||||
OnlyConstructNodes.Enable(false);
|
||||
_dysonSpherePatch?.UnpatchSelf();
|
||||
_dysonSpherePatch = null;
|
||||
}
|
||||
|
||||
public static void InitCurrentDysonSphere(int index)
|
||||
{
|
||||
var star = GameMain.localStar;
|
||||
if (star == null) return;
|
||||
var dysonSpheres = GameMain.data?.dysonSpheres;
|
||||
if (dysonSpheres == null) return;
|
||||
if (index < 0)
|
||||
{
|
||||
if (dysonSpheres[star.index] == null) return;
|
||||
var dysonSphere = new DysonSphere();
|
||||
dysonSpheres[star.index] = dysonSphere;
|
||||
dysonSphere.Init(GameMain.data, star);
|
||||
dysonSphere.ResetNew();
|
||||
return;
|
||||
}
|
||||
|
||||
var ds = dysonSpheres[star.index];
|
||||
if (ds?.layersIdBased[index] == null) return;
|
||||
var pool = ds.rocketPool;
|
||||
for (var id = ds.rocketCursor - 1; id > 0; id--)
|
||||
{
|
||||
if (pool[id].id != id) continue;
|
||||
if (pool[id].nodeLayerId != index) continue;
|
||||
ds.RemoveDysonRocket(id);
|
||||
}
|
||||
ds.RemoveLayer(index);
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPriority(Priority.First)]
|
||||
[HarmonyPatch(typeof(DysonNode), nameof(DysonNode.ConstructCp))]
|
||||
private static IEnumerable<CodeInstruction> DysonSpherePatch_DysonNode_ConstructCp_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchBack(false,
|
||||
new CodeMatch(OpCodes.Ldc_I4_0),
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(DysonShell), nameof(DysonShell.Construct)))
|
||||
).Advance(3).InsertAndAdvance(
|
||||
// node._cpReq = node._cpReq - 1;
|
||||
new CodeInstruction(OpCodes.Ldarg_0),
|
||||
new CodeInstruction(OpCodes.Ldarg_0),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode._cpReq))),
|
||||
new CodeInstruction(OpCodes.Ldc_I4_1),
|
||||
new CodeInstruction(OpCodes.Sub),
|
||||
new CodeInstruction(OpCodes.Stfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode._cpReq)))
|
||||
);
|
||||
// Remove use of RecalcCpReq()
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(DysonNode), nameof(DysonNode.RecalcCpReq)))
|
||||
);
|
||||
var labels = matcher.Labels;
|
||||
matcher.RemoveInstructions(2).Labels.AddRange(labels);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
private static class StopEjectOnNodeComplete
|
||||
{
|
||||
private static Harmony _patch;
|
||||
private static HashSet<int>[] _nodeForAbsorb;
|
||||
private static bool _initialized;
|
||||
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
InitNodeForAbsorb();
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(StopEjectOnNodeComplete));
|
||||
}
|
||||
else
|
||||
{
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
_initialized = false;
|
||||
_nodeForAbsorb = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void InitNodeForAbsorb()
|
||||
{
|
||||
_initialized = false;
|
||||
_nodeForAbsorb = null;
|
||||
var data = GameMain.data;
|
||||
var galaxy = data?.galaxy;
|
||||
if (galaxy == null) return;
|
||||
var galaxyStarCount = galaxy.starCount;
|
||||
_nodeForAbsorb = new HashSet<int>[galaxyStarCount];
|
||||
var spheres = data.dysonSpheres;
|
||||
if (spheres == null) return;
|
||||
foreach (var sphere in spheres)
|
||||
{
|
||||
if (sphere?.layersSorted == null) continue;
|
||||
var starIndex = sphere.starData.index;
|
||||
if (starIndex >= galaxyStarCount) continue;
|
||||
foreach (var layer in sphere.layersSorted)
|
||||
{
|
||||
if (layer == null) continue;
|
||||
for (var i = layer.nodeCursor - 1; i > 0; i--)
|
||||
{
|
||||
var node = layer.nodePool[i];
|
||||
if (node == null || node.id != i || node.sp < node.spMax || node.cpReqOrder == 0) continue;
|
||||
SetNodeForAbsorb(starIndex, layer.id, node.id, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
private static void SetNodeForAbsorb(int index, int layerId, int nodeId, bool canAbsorb)
|
||||
{
|
||||
ref var comp = ref _nodeForAbsorb[index];
|
||||
comp ??= [];
|
||||
var idx = nodeId * 10 + layerId;
|
||||
if (canAbsorb)
|
||||
comp.Add(idx);
|
||||
else
|
||||
comp.Remove(idx);
|
||||
}
|
||||
|
||||
private static void UpdateNodeForAbsorbOnSpChange(DysonNode node)
|
||||
{
|
||||
if (!_initialized) return;
|
||||
if (node.sp < node.spMax || node.cpReqOrder <= 0) return;
|
||||
var shells = node.shells;
|
||||
if (shells.Count == 0) return;
|
||||
SetNodeForAbsorb(shells[0].dysonSphere.starData.index, node.layerId, node.id, true);
|
||||
}
|
||||
|
||||
private static void UpdateNodeForAbsorbOnCpChange(DysonNode node)
|
||||
{
|
||||
if (!_initialized) return;
|
||||
if (node.sp < node.spMax || node.cpReqOrder > 0) return;
|
||||
var shells = node.shells;
|
||||
if (shells.Count == 0) return;
|
||||
SetNodeForAbsorb(shells[0].dysonSphere.starData.index, node.layerId, node.id, false);
|
||||
}
|
||||
|
||||
private static bool AnyNodeForAbsorb(int starIndex)
|
||||
{
|
||||
var comp = _nodeForAbsorb[starIndex];
|
||||
return comp != null && comp.Count > 0;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.Begin))]
|
||||
private static void GameMain_Begin_Postfix()
|
||||
{
|
||||
InitNodeForAbsorb();
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.End))]
|
||||
private static void GameMain_End_Postfix()
|
||||
{
|
||||
_initialized = false;
|
||||
_nodeForAbsorb = null;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(DysonNode), nameof(DysonNode.RecalcCpReq))]
|
||||
private static void DysonNode_RecalcCpReq_Postfix(DysonNode __instance)
|
||||
{
|
||||
UpdateNodeForAbsorbOnCpChange(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(DysonSphereLayer), nameof(DysonSphereLayer.RemoveDysonNode))]
|
||||
private static void DysonSphereLayer_RemoveDysonNode_Prefix(DysonSphereLayer __instance, int nodeId)
|
||||
{
|
||||
if (_initialized)
|
||||
SetNodeForAbsorb(__instance.starData.index, __instance.id, nodeId, false);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(DysonSphere), nameof(DysonSphere.ResetNew))]
|
||||
private static void DysonSphere_ResetNew_Prefix(DysonSphere __instance)
|
||||
{
|
||||
var starIndex = __instance.starData.index;
|
||||
if (_nodeForAbsorb[starIndex] == null) return;
|
||||
_nodeForAbsorb[starIndex].Clear();
|
||||
_nodeForAbsorb[starIndex] = null;
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(EjectorComponent), nameof(EjectorComponent.InternalUpdate))]
|
||||
private static IEnumerable<CodeInstruction> EjectorComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
// if (this.orbitId == 0
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(EjectorComponent), nameof(EjectorComponent.orbitId))),
|
||||
new CodeMatch(OpCodes.Brtrue)
|
||||
).Advance(2).Insert(
|
||||
// || !StopEjectOnNodeComplete.AnyNodeForAbsorb(this.starData.index))
|
||||
new CodeInstruction(OpCodes.Ldarg_2),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(DysonSwarm), nameof(DysonSwarm.starData))),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(StarData), nameof(StarData.index))),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(StopEjectOnNodeComplete), nameof(StopEjectOnNodeComplete.AnyNodeForAbsorb))),
|
||||
new CodeInstruction(OpCodes.And)
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(DysonNode), nameof(DysonNode.ConstructSp))]
|
||||
private static IEnumerable<CodeInstruction> DysonNode_ConstructSp_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.Start().MatchForward(false,
|
||||
new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode.sp)))
|
||||
).Advance(1);
|
||||
var labels = matcher.Labels;
|
||||
matcher.Labels = [];
|
||||
matcher.Insert(
|
||||
new CodeInstruction(OpCodes.Ldarg_0).WithLabels(labels),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(StopEjectOnNodeComplete), nameof(StopEjectOnNodeComplete.UpdateNodeForAbsorbOnSpChange)))
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(DysonNode), nameof(DysonNode.ConstructCp))]
|
||||
private static IEnumerable<CodeInstruction> DysonNode_ConstructCp_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchBack(false,
|
||||
// Search for previous patch:
|
||||
// node._cpReq = node._cpReq - 1;
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode._cpReq))),
|
||||
new CodeMatch(OpCodes.Ldc_I4_1),
|
||||
new CodeMatch(OpCodes.Sub),
|
||||
new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode._cpReq)))
|
||||
).Advance(6).Insert(
|
||||
new CodeInstruction(OpCodes.Ldarg_0),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(StopEjectOnNodeComplete), nameof(StopEjectOnNodeComplete.UpdateNodeForAbsorbOnCpChange)))
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
private static class OnlyConstructNodes
|
||||
{
|
||||
private static Harmony _patch;
|
||||
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(OnlyConstructNodes));
|
||||
}
|
||||
else
|
||||
{
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
|
||||
var spheres = GameMain.data?.dysonSpheres;
|
||||
if (spheres == null) return;
|
||||
foreach (var sphere in spheres)
|
||||
{
|
||||
if (sphere == null) continue;
|
||||
sphere.CheckAutoNodes();
|
||||
if (sphere.autoNodeCount > 0) continue;
|
||||
sphere.PickAutoNode();
|
||||
sphere.PickAutoNode();
|
||||
sphere.PickAutoNode();
|
||||
sphere.PickAutoNode();
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(DysonNode), nameof(DysonNode.spReqOrder), MethodType.Getter)]
|
||||
private static IEnumerable<CodeInstruction> DysonNode_spReqOrder_Getter_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode._spReq)))
|
||||
).Advance(1).SetInstructionAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode.spMax)))
|
||||
).Insert(
|
||||
new CodeInstruction(OpCodes.Ldarg_0),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode.sp))),
|
||||
new CodeInstruction(OpCodes.Sub)
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,836 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UXAssist;
|
||||
|
||||
public static class FactoryPatch
|
||||
{
|
||||
public static ConfigEntry<bool> UnlimitInteractiveEnabled;
|
||||
public static ConfigEntry<bool> RemoveSomeConditionEnabled;
|
||||
public static ConfigEntry<bool> NightLightEnabled;
|
||||
public static ConfigEntry<bool> RemoveBuildRangeLimitEnabled;
|
||||
public static ConfigEntry<bool> LargerAreaForUpgradeAndDismantleEnabled;
|
||||
public static ConfigEntry<bool> LargerAreaForTerraformEnabled;
|
||||
public static ConfigEntry<bool> OffGridBuildingEnabled;
|
||||
public static ConfigEntry<bool> LogisticsCapacityTweaksEnabled;
|
||||
|
||||
private static Harmony _factoryPatch;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
UnlimitInteractiveEnabled.SettingChanged += (_, _) => UnlimitInteractive.Enable(UnlimitInteractiveEnabled.Value);
|
||||
RemoveSomeConditionEnabled.SettingChanged += (_, _) => RemoveSomeConditionBuild.Enable(RemoveSomeConditionEnabled.Value);
|
||||
NightLightEnabled.SettingChanged += (_, _) => NightLight.Enable(NightLightEnabled.Value);
|
||||
RemoveBuildRangeLimitEnabled.SettingChanged += (_, _) => RemoveBuildRangeLimit.Enable(RemoveBuildRangeLimitEnabled.Value);
|
||||
LargerAreaForUpgradeAndDismantleEnabled.SettingChanged += (_, _) => LargerAreaForUpgradeAndDismantle.Enable(LargerAreaForUpgradeAndDismantleEnabled.Value);
|
||||
LargerAreaForTerraformEnabled.SettingChanged += (_, _) => LargerAreaForTerraform.Enable(LargerAreaForTerraformEnabled.Value);
|
||||
OffGridBuildingEnabled.SettingChanged += (_, _) => OffGridBuilding.Enable(OffGridBuildingEnabled.Value);
|
||||
LogisticsCapacityTweaksEnabled.SettingChanged += (_, _) => LogisticsCapacityTweaks.Enable(LogisticsCapacityTweaksEnabled.Value);
|
||||
UnlimitInteractive.Enable(UnlimitInteractiveEnabled.Value);
|
||||
RemoveSomeConditionBuild.Enable(RemoveSomeConditionEnabled.Value);
|
||||
NightLight.Enable(NightLightEnabled.Value);
|
||||
RemoveBuildRangeLimit.Enable(RemoveBuildRangeLimitEnabled.Value);
|
||||
LargerAreaForUpgradeAndDismantle.Enable(LargerAreaForUpgradeAndDismantleEnabled.Value);
|
||||
LargerAreaForTerraform.Enable(LargerAreaForTerraformEnabled.Value);
|
||||
OffGridBuilding.Enable(OffGridBuildingEnabled.Value);
|
||||
LogisticsCapacityTweaks.Enable(LogisticsCapacityTweaksEnabled.Value);
|
||||
|
||||
_factoryPatch ??= Harmony.CreateAndPatchAll(typeof(FactoryPatch));
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
RemoveSomeConditionBuild.Enable(false);
|
||||
UnlimitInteractive.Enable(false);
|
||||
NightLight.Enable(false);
|
||||
RemoveBuildRangeLimit.Enable(false);
|
||||
LargerAreaForUpgradeAndDismantle.Enable(false);
|
||||
LargerAreaForTerraform.Enable(false);
|
||||
OffGridBuilding.Enable(false);
|
||||
LogisticsCapacityTweaks.Enable(false);
|
||||
|
||||
_factoryPatch?.UnpatchSelf();
|
||||
_factoryPatch = null;
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(ConnGizmoGraph), MethodType.Constructor)]
|
||||
private static IEnumerable<CodeInstruction> ConnGizmoGraph_Constructor_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Ldc_I4 && ci.OperandIs(256))
|
||||
);
|
||||
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldc_I4, 2048));
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(ConnGizmoGraph), nameof(ConnGizmoGraph.SetPointCount))]
|
||||
private static IEnumerable<CodeInstruction> ConnGizmoGraph_SetPointCount_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Ldc_I4 && ci.OperandIs(256))
|
||||
);
|
||||
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldc_I4, 2048));
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(BuildTool_Path), nameof(BuildTool_Path._OnInit))]
|
||||
private static IEnumerable<CodeInstruction> BuildTool_Path__OnInit_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Ldc_I4 && ci.OperandIs(160))
|
||||
);
|
||||
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldc_I4, 2048));
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler, HarmonyPatch(typeof(BuildTool_Reform), MethodType.Constructor)]
|
||||
private static IEnumerable<CodeInstruction> BuildTool_Reform_Constructor_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Ldc_I4_S && ci.OperandIs(100))
|
||||
);
|
||||
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldc_I4, 900));
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
public static class NightLight
|
||||
{
|
||||
private static Harmony _patch;
|
||||
private const float NightLightAngleX = -8;
|
||||
private const float NightLightAngleY = -2;
|
||||
public static bool Enabled;
|
||||
private static bool _nightlightInitialized;
|
||||
private static bool _mechaOnEarth;
|
||||
private static AnimationState _sail;
|
||||
private static Light _sunlight;
|
||||
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
Enabled = _mechaOnEarth;
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(NightLight));
|
||||
return;
|
||||
}
|
||||
|
||||
Enabled = false;
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
if (_sunlight == null) return;
|
||||
_sunlight.transform.localEulerAngles = new Vector3(0f, 180f);
|
||||
}
|
||||
|
||||
public static void LateUpdate()
|
||||
{
|
||||
if (_patch == null) return;
|
||||
|
||||
switch (_nightlightInitialized)
|
||||
{
|
||||
case false:
|
||||
Ready();
|
||||
break;
|
||||
case true:
|
||||
Go();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void Ready()
|
||||
{
|
||||
if (!GameMain.isRunning || !GameMain.mainPlayer.controller.model.gameObject.activeInHierarchy) return;
|
||||
if (_sail == null)
|
||||
{
|
||||
_sail = GameMain.mainPlayer.animator.sails[GameMain.mainPlayer.animator.sailAnimIndex];
|
||||
}
|
||||
|
||||
_nightlightInitialized = true;
|
||||
}
|
||||
|
||||
private static void Go()
|
||||
{
|
||||
if (!GameMain.isRunning)
|
||||
{
|
||||
End();
|
||||
return;
|
||||
}
|
||||
|
||||
if (_sail.enabled)
|
||||
{
|
||||
_mechaOnEarth = false;
|
||||
Enabled = false;
|
||||
if (_sunlight == null) return;
|
||||
_sunlight.transform.localEulerAngles = new Vector3(0f, 180f);
|
||||
_sunlight = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_mechaOnEarth)
|
||||
{
|
||||
if (_sunlight == null)
|
||||
{
|
||||
var simu = GameMain.universeSimulator;
|
||||
if (simu)
|
||||
_sunlight = simu.LocalStarSimulator()?.sunLight;
|
||||
if (_sunlight == null) return;
|
||||
}
|
||||
|
||||
_mechaOnEarth = true;
|
||||
Enabled = NightLightEnabled.Value;
|
||||
}
|
||||
|
||||
if (Enabled)
|
||||
{
|
||||
_sunlight.transform.rotation =
|
||||
Quaternion.LookRotation(-GameMain.mainPlayer.transform.up + GameMain.mainPlayer.transform.forward * NightLightAngleX / 10f +
|
||||
GameMain.mainPlayer.transform.right * NightLightAngleY / 10f);
|
||||
}
|
||||
}
|
||||
|
||||
private static void End()
|
||||
{
|
||||
_mechaOnEarth = false;
|
||||
Enabled = false;
|
||||
if (_sunlight != null)
|
||||
{
|
||||
_sunlight.transform.localEulerAngles = new Vector3(0f, 180f);
|
||||
_sunlight = null;
|
||||
}
|
||||
|
||||
_sail = null;
|
||||
_nightlightInitialized = false;
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(StarSimulator), "LateUpdate")]
|
||||
private static IEnumerable<CodeInstruction> StarSimulator_LateUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
// var vec = NightlightEnabled ? GameMain.mainPlayer.transform.up : __instance.transform.forward;
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
var label1 = generator.DefineLabel();
|
||||
var label2 = generator.DefineLabel();
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Call, AccessTools.PropertyGetter(typeof(Component), nameof(Component.transform)))
|
||||
).InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(NightLight), nameof(NightLight.Enabled))),
|
||||
new CodeInstruction(OpCodes.Brfalse_S, label1),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(GameMain), nameof(GameMain.mainPlayer))),
|
||||
new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Player), nameof(Player.transform))),
|
||||
new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Transform), nameof(Transform.up))),
|
||||
new CodeInstruction(OpCodes.Stloc_0),
|
||||
new CodeInstruction(OpCodes.Br_S, label2)
|
||||
);
|
||||
matcher.Labels.Add(label1);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Stloc_0)
|
||||
).Advance(1).Labels.Add(label2);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(PlanetSimulator), "LateUpdate")]
|
||||
private static IEnumerable<CodeInstruction> PlanetSimulator_LateUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
// var vec = (NightlightEnabled ? GameMain.mainPlayer.transform.up : (Quaternion.Inverse(localPlanet.runtimeRotation) * (__instance.planetData.star.uPosition - __instance.planetData.uPosition).normalized));
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
var label1 = generator.DefineLabel();
|
||||
var label2 = generator.DefineLabel();
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Stloc_1)
|
||||
).Advance(1).InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(NightLight), nameof(NightLight.Enabled))),
|
||||
new CodeInstruction(OpCodes.Brfalse_S, label1),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(GameMain), nameof(GameMain.mainPlayer))),
|
||||
new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Player), nameof(Player.transform))),
|
||||
new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Transform), nameof(Transform.up))),
|
||||
new CodeInstruction(OpCodes.Stloc_2),
|
||||
new CodeInstruction(OpCodes.Br_S, label2)
|
||||
);
|
||||
matcher.Labels.Add(label1);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldsfld, AccessTools.Field(typeof(FactoryModel), nameof(FactoryModel.whiteMode0)))
|
||||
).Labels.Add(label2);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
private static class UnlimitInteractive
|
||||
{
|
||||
private static Harmony _patch;
|
||||
|
||||
public static void Enable(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(UnlimitInteractive));
|
||||
return;
|
||||
}
|
||||
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(PlayerAction_Inspect), nameof(PlayerAction_Inspect.GetObjectSelectDistance))]
|
||||
private static IEnumerable<CodeInstruction> PlayerAction_Inspect_GetObjectSelectDistance_Transpiler(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
yield return new CodeInstruction(OpCodes.Ldc_R4, 10000f);
|
||||
yield return new CodeInstruction(OpCodes.Ret);
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveSomeConditionBuild
|
||||
{
|
||||
private static Harmony _patch;
|
||||
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(RemoveSomeConditionBuild));
|
||||
return;
|
||||
}
|
||||
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
|
||||
[HarmonyTranspiler, HarmonyPriority(Priority.First)]
|
||||
[HarmonyPatch(typeof(BuildTool_BlueprintPaste), nameof(BuildTool_BlueprintPaste.CheckBuildConditions))]
|
||||
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.CheckBuildConditions))]
|
||||
private static IEnumerable<CodeInstruction> BuildTool_Click_CheckBuildConditions_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
/* search for:
|
||||
* ldloc.s V_8 (8)
|
||||
* ldfld class PrefabDesc BuildPreview::desc
|
||||
* ldfld bool PrefabDesc::isInserter
|
||||
* brtrue 2358 (1C12) ldloc.s V_8 (8)
|
||||
* ldloca.s V_10 (10)
|
||||
* call instance float32 [UnityEngine.CoreModule]UnityEngine.Vector3::get_magnitude()
|
||||
*/
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldloc_S),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(BuildPreview), nameof(BuildPreview.desc))),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(PrefabDesc), nameof(PrefabDesc.isInserter))),
|
||||
new CodeMatch(instr => instr.opcode == OpCodes.Brtrue || instr.opcode == OpCodes.Brtrue_S),
|
||||
new CodeMatch(OpCodes.Ldloca_S),
|
||||
new CodeMatch(OpCodes.Call, AccessTools.PropertyGetter(typeof(Vector3), nameof(Vector3.magnitude)))
|
||||
);
|
||||
var jumpPos = matcher.InstructionAt(3).operand;
|
||||
var labels = matcher.Labels;
|
||||
matcher.Labels = [];
|
||||
/* Insert: br 2358 (1C12) ldloc.s V_8 (8)
|
||||
*/
|
||||
matcher.Insert(new CodeInstruction(OpCodes.Br, jumpPos).WithLabels(labels));
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler, HarmonyPriority(Priority.First)]
|
||||
[HarmonyPatch(typeof(BuildTool_Path), nameof(BuildTool_Path.CheckBuildConditions))]
|
||||
private static IEnumerable<CodeInstruction> BuildTool_Path_CheckBuildConditions_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
/* search for:
|
||||
* ldloc.s V_88 (88)
|
||||
* ldloc.s V_120 (120)
|
||||
* brtrue.s 2054 (173A) ldc.i4.s 17
|
||||
* ldc.i4.s 18
|
||||
* br.s 2055 (173C) stfld valuetype EBuildCondition BuildPreview::condition
|
||||
* ldc.i4.s 17
|
||||
* stfld valuetype EBuildCondition BuildPreview::condition
|
||||
*/
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldloc_S),
|
||||
new CodeMatch(OpCodes.Ldloc_S),
|
||||
new CodeMatch(instr => instr.opcode == OpCodes.Brtrue_S || instr.opcode == OpCodes.Brtrue),
|
||||
new CodeMatch(instr => instr.opcode == OpCodes.Ldc_I4_S && instr.OperandIs(18)),
|
||||
new CodeMatch(instr => instr.opcode == OpCodes.Br_S || instr.opcode == OpCodes.Br),
|
||||
new CodeMatch(instr => instr.opcode == OpCodes.Ldc_I4_S && instr.OperandIs(17)),
|
||||
new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(BuildPreview), nameof(BuildPreview.condition)))
|
||||
);
|
||||
if (matcher.IsValid)
|
||||
{
|
||||
// Remove 7 instructions, if the following instruction is br/br.s, remove it as well
|
||||
var labels = matcher.Labels;
|
||||
matcher.Labels = [];
|
||||
matcher.RemoveInstructions(7);
|
||||
var opcode = matcher.Opcode;
|
||||
if (opcode == OpCodes.Br || opcode == OpCodes.Br_S)
|
||||
matcher.RemoveInstruction();
|
||||
matcher.Labels.AddRange(labels);
|
||||
}
|
||||
|
||||
/* search for:
|
||||
* ldloc.s V_88 (88)
|
||||
* ldc.i4.s 15-19
|
||||
* stfld valuetype EBuildCondition BuildPreview::condition
|
||||
*/
|
||||
matcher.Start().MatchForward(false,
|
||||
new CodeMatch(instr => instr.opcode == OpCodes.Ldloc_S || instr.opcode == OpCodes.Ldloc),
|
||||
new CodeMatch(instr => (instr.opcode == OpCodes.Ldc_I4_S || instr.opcode == OpCodes.Ldc_I4) && Convert.ToInt64(instr.operand) is >= 15 and <= 19),
|
||||
new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(BuildPreview), nameof(BuildPreview.condition)))
|
||||
);
|
||||
if (matcher.IsValid)
|
||||
{
|
||||
// Remove 3 instructions, if the following instruction is br/br.s, remove it as well
|
||||
matcher.Repeat(codeMatcher =>
|
||||
{
|
||||
var labels = codeMatcher.Labels;
|
||||
codeMatcher.Labels = [];
|
||||
codeMatcher.RemoveInstructions(3);
|
||||
var opcode = codeMatcher.Opcode;
|
||||
if (opcode == OpCodes.Br || opcode == OpCodes.Br_S)
|
||||
codeMatcher.RemoveInstruction();
|
||||
codeMatcher.Labels.AddRange(labels);
|
||||
});
|
||||
}
|
||||
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveBuildRangeLimit
|
||||
{
|
||||
private static Harmony _patch;
|
||||
|
||||
public static void Enable(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(RemoveBuildRangeLimit));
|
||||
}
|
||||
else
|
||||
{
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
|
||||
var controller = GameMain.mainPlayer?.controller;
|
||||
if (controller == null) return;
|
||||
controller.actionBuild?.clickTool?._OnInit();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click._OnInit))]
|
||||
private static IEnumerable<CodeInstruction> BuildTool_Click__OnInit_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Ldc_I4_S && ci.OperandIs(15))
|
||||
);
|
||||
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldc_I4, 512));
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(BuildTool_Addon), nameof(BuildTool_Addon.CheckBuildConditions))]
|
||||
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.CheckBuildConditions))]
|
||||
[HarmonyPatch(typeof(BuildTool_Dismantle), nameof(BuildTool_Dismantle.DetermineMoreChainTargets))]
|
||||
[HarmonyPatch(typeof(BuildTool_Dismantle), nameof(BuildTool_Dismantle.DeterminePreviews))]
|
||||
[HarmonyPatch(typeof(BuildTool_Inserter), nameof(BuildTool_Inserter.CheckBuildConditions))]
|
||||
[HarmonyPatch(typeof(BuildTool_Path), nameof(BuildTool_Path.CheckBuildConditions))]
|
||||
[HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.ReformAction))]
|
||||
[HarmonyPatch(typeof(BuildTool_Upgrade), nameof(BuildTool_Upgrade.DetermineMoreChainTargets))]
|
||||
[HarmonyPatch(typeof(BuildTool_Upgrade), nameof(BuildTool_Upgrade.DeterminePreviews))]
|
||||
private static IEnumerable<CodeInstruction> BuildAreaLimitRemoval_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
/* Patch (player.mecha.buildArea * player.mecha.buildArea) to 100000000 */
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(),
|
||||
new CodeMatch(OpCodes.Call, AccessTools.PropertyGetter(typeof(BuildTool), nameof(BuildTool.player))),
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Player), nameof(Player.mecha))),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(Mecha), nameof(Mecha.buildArea))),
|
||||
new CodeMatch(),
|
||||
new CodeMatch(OpCodes.Call, AccessTools.PropertyGetter(typeof(BuildTool), nameof(BuildTool.player))),
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Player), nameof(Player.mecha))),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(Mecha), nameof(Mecha.buildArea))),
|
||||
new CodeMatch(OpCodes.Mul)
|
||||
);
|
||||
matcher.Repeat(m => m.RemoveInstructions(9).InsertAndAdvance(new CodeInstruction(OpCodes.Ldc_R4, 100000000.0f)));
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
private static class LargerAreaForUpgradeAndDismantle
|
||||
{
|
||||
private static Harmony _patch;
|
||||
|
||||
public static void Enable(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(LargerAreaForUpgradeAndDismantle));
|
||||
return;
|
||||
}
|
||||
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(BuildTool_Dismantle), nameof(BuildTool_Dismantle.DeterminePreviews))]
|
||||
[HarmonyPatch(typeof(BuildTool_Upgrade), nameof(BuildTool_Upgrade.DeterminePreviews))]
|
||||
private static IEnumerable<CodeInstruction> BuildTools_CursorSizePatch_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Ldc_I4_S && ci.OperandIs(11))
|
||||
);
|
||||
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldc_I4_S, 31));
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
private static class LargerAreaForTerraform
|
||||
{
|
||||
private static Harmony _patch;
|
||||
|
||||
public static void Enable(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(LargerAreaForTerraform));
|
||||
return;
|
||||
}
|
||||
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
|
||||
[HarmonyTranspiler, HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.ReformAction))]
|
||||
private static IEnumerable<CodeInstruction> BuildTool_Reform_ReformAction_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(BuildTool_Reform), nameof(BuildTool_Reform.brushSize))),
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Ldc_I4_S && ci.OperandIs(10))
|
||||
);
|
||||
matcher.Repeat(m => m.Advance(1).SetAndAdvance(OpCodes.Ldc_I4_S, 30));
|
||||
matcher.Start().MatchForward(false,
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Ldc_I4_S && ci.OperandIs(10)),
|
||||
new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(BuildTool_Reform), nameof(BuildTool_Reform.brushSize)))
|
||||
);
|
||||
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldc_I4_S, 30));
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
public static class OffGridBuilding
|
||||
{
|
||||
private static Harmony _patch;
|
||||
private const float SteppedRotationDegrees = 15f;
|
||||
|
||||
public static void Enable(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(OffGridBuilding));
|
||||
return;
|
||||
}
|
||||
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
|
||||
private static void MatchIgnoreGridAndCheckIfRotatable(CodeMatcher matcher, out Label? ifBlockEntryLabel, out Label? elseBlockEntryLabel)
|
||||
{
|
||||
Label? thisIfBlockEntryLabel = null;
|
||||
Label? thisElseBlockEntryLabel = null;
|
||||
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(ci => ci.Calls(AccessTools.PropertyGetter(typeof(VFInput), nameof(VFInput._ignoreGrid)))),
|
||||
new CodeMatch(ci => ci.Branches(out thisElseBlockEntryLabel)),
|
||||
new CodeMatch(ci => ci.IsLdarg()),
|
||||
new CodeMatch(OpCodes.Ldfld),
|
||||
new CodeMatch(OpCodes.Ldfld),
|
||||
new CodeMatch(ci => ci.LoadsConstant(EMinerType.Vein)),
|
||||
new CodeMatch(ci => ci.Branches(out thisIfBlockEntryLabel)),
|
||||
new CodeMatch(ci => ci.IsLdarg()),
|
||||
new CodeMatch(OpCodes.Ldfld),
|
||||
new CodeMatch(OpCodes.Ldfld),
|
||||
new CodeMatch(ci => ci.Branches(out _))
|
||||
);
|
||||
|
||||
ifBlockEntryLabel = thisIfBlockEntryLabel;
|
||||
elseBlockEntryLabel = thisElseBlockEntryLabel;
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.UpdateRaycast))]
|
||||
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.DeterminePreviews))]
|
||||
public static IEnumerable<CodeInstruction> AllowOffGridConstruction(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
|
||||
MatchIgnoreGridAndCheckIfRotatable(matcher, out var entryLabel, out _);
|
||||
|
||||
if (matcher.IsInvalid)
|
||||
return instructions;
|
||||
|
||||
matcher.Advance(2);
|
||||
matcher.Insert(new CodeInstruction(OpCodes.Br, entryLabel.Value));
|
||||
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.DeterminePreviews))]
|
||||
public static IEnumerable<CodeInstruction> PreventDraggingWhenOffGrid(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
|
||||
Label? exitLabel = null;
|
||||
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(ci => ci.Branches(out exitLabel)),
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(ci => ci.LoadsConstant(1)),
|
||||
new CodeMatch(ci => ci.StoresField(AccessTools.Field(typeof(BuildTool_Click), nameof(BuildTool_Click.isDragging))))
|
||||
);
|
||||
|
||||
if (matcher.IsInvalid)
|
||||
return instructions;
|
||||
|
||||
matcher.Advance(1);
|
||||
matcher.Insert(
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(VFInput), nameof(VFInput._ignoreGrid))),
|
||||
new CodeInstruction(OpCodes.Brtrue, exitLabel)
|
||||
);
|
||||
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
public static IEnumerable<CodeInstruction> PatchToPerformSteppedRotate(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
|
||||
MatchIgnoreGridAndCheckIfRotatable(matcher, out var ifBlockEntryLabel, out var elseBlockEntryLabel);
|
||||
|
||||
if (matcher.IsInvalid)
|
||||
return instructions;
|
||||
|
||||
while (!matcher.Labels.Contains(elseBlockEntryLabel.Value))
|
||||
matcher.Advance(1);
|
||||
|
||||
Label? ifBlockExitLabel = null;
|
||||
|
||||
matcher.MatchBack(false, new CodeMatch(ci => ci.Branches(out ifBlockExitLabel)));
|
||||
|
||||
if (matcher.IsInvalid)
|
||||
return instructions;
|
||||
|
||||
while (!matcher.Labels.Contains(ifBlockEntryLabel.Value))
|
||||
matcher.Advance(-1);
|
||||
|
||||
var instructionToClone = matcher.Instruction.Clone();
|
||||
var overwriteWith = CodeInstruction.LoadField(typeof(VFInput), nameof(VFInput.control));
|
||||
|
||||
matcher.SetAndAdvance(overwriteWith.opcode, overwriteWith.operand);
|
||||
matcher.Insert(instructionToClone);
|
||||
matcher.CreateLabel(out var existingEntryLabel);
|
||||
matcher.InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Brfalse, existingEntryLabel),
|
||||
new CodeInstruction(OpCodes.Ldarg_0),
|
||||
CodeInstruction.Call(typeof(OffGridBuilding), nameof(OffGridBuilding.RotateStepped)),
|
||||
new CodeInstruction(OpCodes.Br, ifBlockExitLabel)
|
||||
);
|
||||
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
public static void RotateStepped(BuildTool_Click instance)
|
||||
{
|
||||
if (VFInput._rotate.onDown)
|
||||
{
|
||||
instance.yaw += SteppedRotationDegrees;
|
||||
instance.yaw = Mathf.Repeat(instance.yaw, 360f);
|
||||
instance.yaw = Mathf.Round(instance.yaw / SteppedRotationDegrees) * SteppedRotationDegrees;
|
||||
}
|
||||
|
||||
if (VFInput._counterRotate.onDown)
|
||||
{
|
||||
instance.yaw -= SteppedRotationDegrees;
|
||||
instance.yaw = Mathf.Repeat(instance.yaw, 360f);
|
||||
instance.yaw = Mathf.Round(instance.yaw / SteppedRotationDegrees) * SteppedRotationDegrees;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class LogisticsCapacityTweaks
|
||||
{
|
||||
private static Harmony _patch;
|
||||
|
||||
public static void Enable(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(LogisticsCapacityTweaks));
|
||||
return;
|
||||
}
|
||||
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
|
||||
private static KeyCode _lastKey = KeyCode.None;
|
||||
private static long _nextKeyTick;
|
||||
private static bool _skipNextEvent;
|
||||
|
||||
private static bool UpdateKeyPressed(KeyCode code)
|
||||
{
|
||||
if (!Input.GetKey(code))
|
||||
return false;
|
||||
if (code != _lastKey)
|
||||
{
|
||||
_lastKey = code;
|
||||
_nextKeyTick = GameMain.instance.timei + 30;
|
||||
return true;
|
||||
}
|
||||
|
||||
var currTick = GameMain.instance.timei;
|
||||
if (_nextKeyTick > currTick) return false;
|
||||
_nextKeyTick = currTick + 4;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void OnUpdate()
|
||||
{
|
||||
if (_lastKey != KeyCode.None && Input.GetKeyUp(_lastKey))
|
||||
{
|
||||
_lastKey = KeyCode.None;
|
||||
}
|
||||
if (!VFInput.noModifier) return;
|
||||
int delta;
|
||||
if (UpdateKeyPressed(KeyCode.LeftArrow))
|
||||
{
|
||||
delta = -10;
|
||||
}
|
||||
else if (UpdateKeyPressed(KeyCode.RightArrow))
|
||||
{
|
||||
delta = 10;
|
||||
}
|
||||
else if (UpdateKeyPressed(KeyCode.DownArrow))
|
||||
{
|
||||
delta = -100;
|
||||
}
|
||||
else if (UpdateKeyPressed(KeyCode.UpArrow))
|
||||
{
|
||||
delta = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var targets = new List<RaycastResult>();
|
||||
EventSystem.current.RaycastAll(new PointerEventData(EventSystem.current) { position = Input.mousePosition }, targets);
|
||||
foreach (var target in targets)
|
||||
{
|
||||
var stationStorage = target.gameObject.GetComponentInParent<UIStationStorage>();
|
||||
if (stationStorage is null) continue;
|
||||
var station = stationStorage.station;
|
||||
ref var storage = ref station.storage[stationStorage.index];
|
||||
var oldMax = storage.max;
|
||||
var newMax = oldMax + delta;
|
||||
if (newMax < 0)
|
||||
{
|
||||
newMax = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
var modelProto = LDB.models.Select(stationStorage.stationWindow.factory.entityPool[station.entityId].modelIndex);
|
||||
var itemCountMax = 0;
|
||||
if (modelProto != null)
|
||||
{
|
||||
itemCountMax = modelProto.prefabDesc.stationMaxItemCount;
|
||||
}
|
||||
itemCountMax += station.isStellar ? GameMain.history.remoteStationExtraStorage : GameMain.history.localStationExtraStorage;
|
||||
if (newMax > itemCountMax)
|
||||
{
|
||||
newMax = itemCountMax;
|
||||
}
|
||||
}
|
||||
storage.max = newMax;
|
||||
_skipNextEvent = oldMax / 100 != newMax / 100;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(UIStationStorage), nameof(UIStationStorage.OnMaxSliderValueChange))]
|
||||
private static bool UIStationStorage_OnMaxSliderValueChange_Prefix()
|
||||
{
|
||||
if (!_skipNextEvent) return true;
|
||||
_skipNextEvent = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(PlanetTransport), nameof(PlanetTransport.OnTechFunctionUnlocked))]
|
||||
private static bool PlanetTransport_OnTechFunctionUnlocked_Prefix(PlanetTransport __instance, int _funcId, double _valuelf, int _level)
|
||||
{
|
||||
switch (_funcId)
|
||||
{
|
||||
case 30:
|
||||
{
|
||||
var stationPool = __instance.stationPool;
|
||||
var factory = __instance.factory;
|
||||
var history = GameMain.history;
|
||||
for (var i = __instance.stationCursor - 1; i > 0; i--)
|
||||
{
|
||||
if (stationPool[i] == null || stationPool[i].id != i || (stationPool[i].isStellar && !stationPool[i].isCollector && !stationPool[i].isVeinCollector)) continue;
|
||||
var modelIndex = factory.entityPool[stationPool[i].entityId].modelIndex;
|
||||
var maxCount = LDB.models.Select(modelIndex).prefabDesc.stationMaxItemCount;
|
||||
var oldMaxCount = maxCount + history.localStationExtraStorage - _valuelf;
|
||||
var intOldMaxCount = (int)Math.Round(oldMaxCount);
|
||||
var ratio = (maxCount + history.localStationExtraStorage) / oldMaxCount;
|
||||
var storage = stationPool[i].storage;
|
||||
for (var j = storage.Length - 1; j >= 0; j--)
|
||||
{
|
||||
if (storage[j].max + 10 < intOldMaxCount) continue;
|
||||
storage[j].max = Mathf.RoundToInt((float)(storage[j].max * ratio / 50.0)) * 50;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 31:
|
||||
{
|
||||
var stationPool = __instance.stationPool;
|
||||
var factory = __instance.factory;
|
||||
var history = GameMain.history;
|
||||
for (var i = __instance.stationCursor - 1; i > 0; i--)
|
||||
{
|
||||
if (stationPool[i] == null || stationPool[i].id != i || !stationPool[i].isStellar || stationPool[i].isCollector || stationPool[i].isVeinCollector) continue;
|
||||
var modelIndex = factory.entityPool[stationPool[i].entityId].modelIndex;
|
||||
var maxCount = LDB.models.Select(modelIndex).prefabDesc.stationMaxItemCount;
|
||||
var oldMaxCount = maxCount + history.remoteStationExtraStorage - _valuelf;
|
||||
var intOldMaxCount = (int)Math.Round(oldMaxCount);
|
||||
var ratio = (maxCount + history.remoteStationExtraStorage) / oldMaxCount;
|
||||
var storage = stationPool[i].storage;
|
||||
for (var j = storage.Length - 1; j >= 0; j--)
|
||||
{
|
||||
if (storage[j].max + 10 < intOldMaxCount) continue;
|
||||
storage[j].max = Mathf.RoundToInt((float)(storage[j].max * ratio / 100.0)) * 100;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
namespace UXAssist.Functions;
|
||||
|
||||
public static class DysonSphereFunctions
|
||||
{
|
||||
public static StarData CurrentStarForDysonSystem()
|
||||
{
|
||||
StarData star = null;
|
||||
var dysonEditor = UIRoot.instance?.uiGame?.dysonEditor;
|
||||
if (dysonEditor != null && dysonEditor.gameObject.activeSelf)
|
||||
{
|
||||
star = dysonEditor.selection.viewStar;
|
||||
}
|
||||
return star ?? GameMain.data?.localStar;
|
||||
}
|
||||
|
||||
public static void InitCurrentDysonLayer(StarData star, int layerId)
|
||||
{
|
||||
star ??= CurrentStarForDysonSystem();
|
||||
if (star == null) return;
|
||||
var dysonSpheres = GameMain.data?.dysonSpheres;
|
||||
if (dysonSpheres == null) return;
|
||||
var dysonEditor = UIRoot.instance?.uiGame.dysonEditor;
|
||||
if (layerId < 0)
|
||||
{
|
||||
if (dysonSpheres[star.index] == null) return;
|
||||
var dysonSphere = new DysonSphere();
|
||||
dysonSpheres[star.index] = dysonSphere;
|
||||
dysonSphere.Init(GameMain.data, star);
|
||||
dysonSphere.ResetNew();
|
||||
|
||||
if (!dysonEditor) return;
|
||||
if (dysonEditor.selection.viewStar == star)
|
||||
{
|
||||
dysonEditor.selection.viewDysonSphere = dysonSphere;
|
||||
dysonEditor.selection.NotifyDysonShpereChange();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var ds = dysonSpheres[star.index];
|
||||
if (ds?.layersIdBased[layerId] == null) return;
|
||||
var pool = ds.rocketPool;
|
||||
for (var id = ds.rocketCursor - 1; id > 0; id--)
|
||||
{
|
||||
if (pool[id].id != id) continue;
|
||||
if (pool[id].nodeLayerId != layerId) continue;
|
||||
ds.RemoveDysonRocket(id);
|
||||
break;
|
||||
}
|
||||
ds.RemoveLayer(layerId);
|
||||
if (!dysonEditor) return;
|
||||
if (!dysonEditor.IsRender(layerId, false, true))
|
||||
{
|
||||
dysonEditor.SwitchRenderState(layerId, false, true);
|
||||
}
|
||||
if (!dysonEditor.IsRender(layerId, false, false))
|
||||
{
|
||||
dysonEditor.SwitchRenderState(layerId, false, false);
|
||||
}
|
||||
dysonEditor.selection.ClearAllSelection();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace UXAssist.Functions;
|
||||
|
||||
public static class FactoryFunctions
|
||||
{
|
||||
public static void CutConveyorBelt(CargoTraffic cargoTraffic, int beltId)
|
||||
{
|
||||
ref var belt = ref cargoTraffic.beltPool[beltId];
|
||||
if (belt.id != beltId || belt.outputId <= 0) return;
|
||||
|
||||
// Clear entity connection
|
||||
var factory = cargoTraffic.factory;
|
||||
factory.ReadObjectConn(belt.entityId, 0, out var isOutput, out var otherObjId, out var otherSlot);
|
||||
if (isOutput && factory.entityPool[otherObjId].beltId == belt.outputId)
|
||||
{
|
||||
factory.ClearObjectConnDirect(belt.entityId, 0);
|
||||
factory.ClearObjectConnDirect(otherObjId, otherSlot);
|
||||
}
|
||||
// Alter belt connections
|
||||
var (i0, i1, i2) = (belt.rightInputId, belt.backInputId, belt.leftInputId);
|
||||
cargoTraffic._arrInputs(ref i0, ref i1, ref i2);
|
||||
cargoTraffic.AlterBeltConnections(beltId, 0, i0, i1, i2);
|
||||
}
|
||||
|
||||
public static bool ObjectIsBeltOrInserter(PlanetFactory factory, int objId)
|
||||
{
|
||||
if (objId == 0) return false;
|
||||
ItemProto proto = LDB.items.Select(objId > 0 ? factory.entityPool[objId].protoId : factory.prebuildPool[-objId].protoId);
|
||||
return proto != null && (proto.prefabDesc.isBelt || proto.prefabDesc.isInserter);
|
||||
}
|
||||
|
||||
public static void DismantleBlueprintSelectedBuildings()
|
||||
{
|
||||
var player = GameMain.mainPlayer;
|
||||
var build = player?.controller?.actionBuild;
|
||||
if (build == null) return;
|
||||
var blueprintCopyTool = build.blueprintCopyTool;
|
||||
if (blueprintCopyTool == null || !blueprintCopyTool.active) return;
|
||||
var factory = build.factory;
|
||||
List<int> buildPreviewsToRemove = [];
|
||||
foreach (var buildPreview in blueprintCopyTool.bpPool)
|
||||
{
|
||||
if (buildPreview?.item == null) continue;
|
||||
var objId = buildPreview.objId;
|
||||
if (objId == 0) continue;
|
||||
int index;
|
||||
if ((index = buildPreviewsToRemove.BinarySearch(objId)) < 0)
|
||||
buildPreviewsToRemove.Insert(~index, objId);
|
||||
var isBelt = buildPreview.desc.isBelt;
|
||||
var isInserter = buildPreview.desc.isInserter;
|
||||
if (isInserter) continue;
|
||||
if (isBelt)
|
||||
{
|
||||
var needCheck = false;
|
||||
for (var j = 0; j < 2; j++)
|
||||
{
|
||||
factory.ReadObjectConn(objId, j, out _, out var connObjId, out _);
|
||||
if (connObjId == 0 || ObjectIsBeltOrInserter(factory, connObjId)) continue;
|
||||
needCheck = true;
|
||||
break;
|
||||
}
|
||||
if (needCheck)
|
||||
{
|
||||
for (var k = 0; k < 16; k++)
|
||||
{
|
||||
factory.ReadObjectConn(objId, k, out _, out var connObjId, out _);
|
||||
if (connObjId != 0 && (index = buildPreviewsToRemove.BinarySearch(connObjId)) < 0 && ObjectIsBeltOrInserter(factory, connObjId))
|
||||
buildPreviewsToRemove.Insert(~index, connObjId);
|
||||
}
|
||||
}
|
||||
for (var m = 0; m < 4; m++)
|
||||
{
|
||||
factory.ReadObjectConn(objId, m, out _, out var connObjId, out _);
|
||||
if (connObjId == 0 || !factory.ObjectIsBelt(connObjId) || buildPreviewsToRemove.BinarySearch(connObjId) >= 0) continue;
|
||||
for (var j = 0; j < 2; j++)
|
||||
{
|
||||
factory.ReadObjectConn(connObjId, j, out _, out var connObjId2, out _);
|
||||
if (connObjId2 == 0 || (index = buildPreviewsToRemove.BinarySearch(connObjId2)) >= 0 || ObjectIsBeltOrInserter(factory, connObjId2)) continue;
|
||||
buildPreviewsToRemove.Insert(~index, connObjId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (buildPreview.desc.addonType == EAddonType.Belt) continue;
|
||||
for (var j = 0; j < 16; j++)
|
||||
{
|
||||
factory.ReadObjectConn(objId, j, out _, out var connObjId, out _);
|
||||
if (connObjId != 0 && (index = buildPreviewsToRemove.BinarySearch(connObjId)) < 0 && ObjectIsBeltOrInserter(factory, connObjId))
|
||||
buildPreviewsToRemove.Insert(~index, connObjId);
|
||||
}
|
||||
}
|
||||
var entityPool = factory.entityPool;
|
||||
var stationPool = factory.transport.stationPool;
|
||||
foreach (var objId in buildPreviewsToRemove)
|
||||
{
|
||||
if (objId > 0)
|
||||
{
|
||||
int stationId = entityPool[objId].stationId;
|
||||
if (stationId > 0)
|
||||
{
|
||||
StationComponent sc = stationPool[stationId];
|
||||
if (sc.id != stationId) continue;
|
||||
for (int i = 0; i < sc.storage.Length; i++)
|
||||
{
|
||||
int package = player.TryAddItemToPackage(sc.storage[i].itemId, sc.storage[i].count, sc.storage[i].inc, true, objId);
|
||||
UIItemup.Up(sc.storage[i].itemId, package);
|
||||
}
|
||||
sc.storage = new StationStore[sc.storage.Length];
|
||||
sc.needs = new int[sc.needs.Length];
|
||||
}
|
||||
}
|
||||
build.DoDismantleObject(objId);
|
||||
}
|
||||
blueprintCopyTool.ClearSelection();
|
||||
blueprintCopyTool.ClearPreSelection();
|
||||
blueprintCopyTool.ResetBlueprint();
|
||||
blueprintCopyTool.ResetBuildPreviews();
|
||||
blueprintCopyTool.RefreshBlueprintData();
|
||||
}
|
||||
|
||||
public static void SelectAllBuildingsInBlueprintCopy()
|
||||
{
|
||||
var localFactory = GameMain.localPlanet?.factory;
|
||||
if (localFactory == null) return;
|
||||
var blueprintCopyTool = GameMain.mainPlayer?.controller?.actionBuild?.blueprintCopyTool;
|
||||
if (blueprintCopyTool == null || !blueprintCopyTool.active) return;
|
||||
var entityPool = localFactory.entityPool;
|
||||
foreach (var entity in entityPool)
|
||||
{
|
||||
if (entity.id == 0) continue;
|
||||
blueprintCopyTool.preSelectObjIds.Add(entity.id);
|
||||
blueprintCopyTool.selectedObjIds.Add(entity.id);
|
||||
}
|
||||
var prebuildPool = localFactory.prebuildPool;
|
||||
foreach (var prebuild in prebuildPool)
|
||||
{
|
||||
if (prebuild.id == 0) continue;
|
||||
blueprintCopyTool.preSelectObjIds.Add(-prebuild.id);
|
||||
blueprintCopyTool.selectedObjIds.Add(-prebuild.id);
|
||||
}
|
||||
blueprintCopyTool.RefreshBlueprintData();
|
||||
blueprintCopyTool.DeterminePreviews();
|
||||
}
|
||||
|
||||
private struct BPBuildingData
|
||||
{
|
||||
public BlueprintBuilding building;
|
||||
public int itemType;
|
||||
public double offset;
|
||||
}
|
||||
|
||||
private struct BPBeltData
|
||||
{
|
||||
public BlueprintBuilding building;
|
||||
public double offset;
|
||||
}
|
||||
|
||||
private static HashSet<int> _itemIsBelt = null;
|
||||
private static Dictionary<int, int> _upgradeTypes = null;
|
||||
|
||||
public static void SortBlueprintData(BlueprintData blueprintData)
|
||||
{
|
||||
// Initialize itemIsBelt and upgradeTypes
|
||||
if (_itemIsBelt == null)
|
||||
{
|
||||
_itemIsBelt = [];
|
||||
_upgradeTypes = [];
|
||||
foreach (var proto in LDB.items.dataArray)
|
||||
{
|
||||
if (proto.prefabDesc?.isBelt ?? false)
|
||||
{
|
||||
_itemIsBelt.Add(proto.ID);
|
||||
continue;
|
||||
}
|
||||
if (proto.Upgrades != null && proto.Upgrades.Length > 0)
|
||||
{
|
||||
var minUpgrade = proto.Upgrades.Min(u => u);
|
||||
if (minUpgrade != 0 && minUpgrade != proto.ID)
|
||||
{
|
||||
_upgradeTypes.Add(proto.ID, minUpgrade);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Separate belt and non-belt buildings
|
||||
List<BPBuildingData> bpBuildings = [];
|
||||
Dictionary<BlueprintBuilding, BPBeltData> bpBelts = [];
|
||||
foreach (var building in blueprintData.buildings)
|
||||
{
|
||||
var offset = building.areaIndex * 1073741824.0 + building.localOffset_y * 262144.0 + building.localOffset_x * 1024.0 + building.localOffset_z;
|
||||
if (_itemIsBelt.Contains(building.itemId))
|
||||
{
|
||||
bpBelts.Add(building, new BPBeltData { building = building, offset = offset });
|
||||
}
|
||||
else
|
||||
{
|
||||
var itemType = _upgradeTypes.TryGetValue(building.itemId, out var upgradeType) ? upgradeType : building.itemId;
|
||||
bpBuildings.Add(new BPBuildingData { building = building, itemType = itemType, offset = offset });
|
||||
}
|
||||
}
|
||||
HashSet<BlueprintBuilding> beltsWithInput = [.. bpBelts.Select(pair => pair.Value.building.outputObj)];
|
||||
var beltHeads = bpBelts.Where(pair => !beltsWithInput.Contains(pair.Value.building)).ToDictionary(pair => pair.Key, pair => pair.Value);
|
||||
// Sort belt buildings
|
||||
List<BlueprintBuilding> sortedBpBelts = [];
|
||||
// Deal with non-cycle belt paths
|
||||
foreach (var pair in beltHeads.OrderByDescending(pair => pair.Value.offset))
|
||||
{
|
||||
var building = pair.Key;
|
||||
while (building != null)
|
||||
{
|
||||
if (!bpBelts.Remove(building)) break;
|
||||
sortedBpBelts.Add(building);
|
||||
building = building.outputObj;
|
||||
}
|
||||
}
|
||||
// Deal with cycle belt paths
|
||||
foreach (var pair in bpBelts.OrderByDescending(pair => pair.Value.offset))
|
||||
{
|
||||
var building = pair.Key;
|
||||
while (building != null)
|
||||
{
|
||||
if (!bpBelts.Remove(building)) break;
|
||||
sortedBpBelts.Add(building);
|
||||
building = building.outputObj;
|
||||
}
|
||||
}
|
||||
|
||||
// Sort non-belt buildings
|
||||
bpBuildings.Sort((a, b) =>
|
||||
{
|
||||
var sign = b.itemType.CompareTo(a.itemType);
|
||||
if (sign != 0) return sign;
|
||||
|
||||
sign = b.building.modelIndex.CompareTo(a.building.modelIndex);
|
||||
if (sign != 0) return sign;
|
||||
|
||||
sign = b.building.recipeId.CompareTo(a.building.recipeId);
|
||||
if (sign != 0) return sign;
|
||||
|
||||
sign = a.building.areaIndex.CompareTo(b.building.areaIndex);
|
||||
if (sign != 0) return sign;
|
||||
|
||||
return b.offset.CompareTo(a.offset);
|
||||
});
|
||||
|
||||
// Concatenate sorted belts and non-belt buildings
|
||||
sortedBpBelts.Reverse();
|
||||
blueprintData.buildings = [.. bpBuildings.Select(b => b.building), .. sortedBpBelts];
|
||||
var buildings = blueprintData.buildings;
|
||||
|
||||
for (var i = buildings.Length - 1; i >= 0; i--)
|
||||
{
|
||||
buildings[i].index = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,436 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using BepInEx.Configuration;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UXAssist.Functions;
|
||||
|
||||
public static class PlanetFunctions
|
||||
{
|
||||
public static ConfigEntry<int> OrbitalCollectorMaxBuildCount;
|
||||
private const int OrbitalCollectorItemId = 2105;
|
||||
public static void DismantleAll(bool toBag)
|
||||
{
|
||||
var player = GameMain.mainPlayer;
|
||||
if (player == null) return;
|
||||
var planet = GameMain.localPlanet;
|
||||
var factory = planet?.factory;
|
||||
if (factory == null) return;
|
||||
foreach (var etd in factory.entityPool)
|
||||
{
|
||||
var stationId = etd.stationId;
|
||||
if (stationId > 0)
|
||||
{
|
||||
var sc = GameMain.localPlanet.factory.transport.stationPool[stationId];
|
||||
if (toBag)
|
||||
{
|
||||
for (var i = sc.storage.Length - 1; i >= 0; i--)
|
||||
{
|
||||
var added = player.TryAddItemToPackage(sc.storage[i].itemId, sc.storage[i].count, 0, true, etd.id);
|
||||
UIItemup.Up(sc.storage[i].itemId, added);
|
||||
sc.storage[i].count = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var i = sc.storage.Length - 1; i >= 0; i--)
|
||||
{
|
||||
sc.storage[i].count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (toBag)
|
||||
{
|
||||
int protoId = 0;
|
||||
factory.DismantleFinally(player, etd.id, ref protoId);
|
||||
}
|
||||
else
|
||||
{
|
||||
var objId = etd.id;
|
||||
factory.BeforeDismantleObject(objId);
|
||||
factory.RemoveEntityWithComponents(objId, false);
|
||||
factory.OnDismantleObject(objId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void RecreatePlanet(bool revertReform)
|
||||
{
|
||||
var player = GameMain.mainPlayer;
|
||||
if (player == null) return;
|
||||
var planet = GameMain.localPlanet;
|
||||
var factory = planet?.factory;
|
||||
if (factory == null) return;
|
||||
var uiGame = UIRoot.instance.uiGame;
|
||||
if (uiGame)
|
||||
{
|
||||
uiGame.ShutAllFunctionWindow();
|
||||
uiGame.ShutAllFullScreens();
|
||||
}
|
||||
player.controller.actionBuild.Close();
|
||||
|
||||
var groundCombatModule = player.mecha.groundCombatModule;
|
||||
for (var i = 0; i < groundCombatModule.moduleFleets.Length; i++)
|
||||
{
|
||||
var entry = groundCombatModule.moduleFleets[i];
|
||||
if (entry.fleetId <= 0 || !entry.fleetEnabled) continue;
|
||||
entry.fleetEnabled = false;
|
||||
groundCombatModule.RemoveFleetDirectly(i);
|
||||
}
|
||||
var constructionSystem = factory.constructionSystem;
|
||||
var constructionModule = player.mecha.constructionModule;
|
||||
for (var i = 0; i < constructionSystem.drones.cursor; i++)
|
||||
{
|
||||
ref var drone = ref constructionSystem.drones.buffer[i];
|
||||
if (drone.id <= 0) continue;
|
||||
var owner = drone.owner;
|
||||
constructionSystem.ResetDroneTargets(ref drone);
|
||||
if (owner == 0)
|
||||
{
|
||||
factory.RemoveCraftWithComponents(drone.craftId);
|
||||
constructionModule.droneIdleCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
drone.movement = factory.gameData.history.constructionDroneMovement;
|
||||
factory.craftPool[drone.craftId].pos = constructionSystem.constructionModules[owner].baseEjectPos;
|
||||
constructionSystem.constructionModules[owner].droneIdleCount++;
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < constructionSystem.constructStats.cursor; i++)
|
||||
{
|
||||
ref var constructStat = ref constructionSystem.constructStats.buffer[i];
|
||||
if (constructStat.id <= 0) continue;
|
||||
constructionSystem.RemoveConstructStat(constructStat.id);
|
||||
}
|
||||
constructionModule.autoReconstructTargetTotalCount = 0;
|
||||
constructionModule.buildTargetTotalCount = 0;
|
||||
constructionModule.repairTargetTotalCount = 0;
|
||||
constructionModule.autoReconstructTargets = null;
|
||||
constructionModule.buildTargets = null;
|
||||
constructionModule.repairTargets = null;
|
||||
constructionModule.tmpTargets = null;
|
||||
constructionModule.tmpTargetsHash = null;
|
||||
constructionModule.checkItemCursor = 0;
|
||||
|
||||
//planet.data = new PlanetRawData(planet.precision);
|
||||
//planet.data.CalcVerts();
|
||||
var stationPool = factory.transport?.stationPool;
|
||||
if (stationPool != null)
|
||||
{
|
||||
foreach (var sc in stationPool)
|
||||
{
|
||||
if (sc is not { id: > 0 }) continue;
|
||||
for (var i = sc.storage.Length - 1; i >= 0; i--)
|
||||
{
|
||||
sc.storage[i].count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var physics = planet.physics;
|
||||
var gpuiManager = GameMain.gpuiManager;
|
||||
var blockContainer = factory.blockContainer;
|
||||
var audio = planet.audio;
|
||||
for (var id = factory.entityCursor - 1; id > 0; id--)
|
||||
{
|
||||
ref var ed = ref factory.entityPool[id];
|
||||
if (ed.id != id) continue;
|
||||
|
||||
factory.BeforeDismantleObject(id);
|
||||
|
||||
if (ed.colliderId != 0)
|
||||
{
|
||||
physics.RemoveLinkedColliderData(ed.colliderId);
|
||||
physics.NotifyObjectRemove(EObjectType.Entity, ed.id);
|
||||
}
|
||||
|
||||
if (ed.modelId != 0)
|
||||
{
|
||||
gpuiManager.RemoveModel(ed.modelIndex, ed.modelId);
|
||||
}
|
||||
|
||||
if (ed.mmblockId != 0)
|
||||
{
|
||||
blockContainer.RemoveMiniBlock(ed.mmblockId);
|
||||
}
|
||||
|
||||
if (ed.audioId != 0)
|
||||
{
|
||||
audio.RemoveAudioData(ed.audioId);
|
||||
}
|
||||
|
||||
factory.OnDismantleObject(id);
|
||||
}
|
||||
|
||||
for (var id = factory.prebuildCursor - 1; id > 0; id--)
|
||||
{
|
||||
ref var pb = ref factory.prebuildPool[id];
|
||||
if (pb.id != id) continue;
|
||||
if (pb.colliderId != 0)
|
||||
{
|
||||
physics.RemoveLinkedColliderData(pb.colliderId);
|
||||
}
|
||||
if (pb.modelId != 0)
|
||||
{
|
||||
gpuiManager.RemovePrebuildModel(pb.modelIndex, pb.modelId);
|
||||
}
|
||||
}
|
||||
|
||||
var hives = GameMain.spaceSector?.dfHives;
|
||||
if (hives != null)
|
||||
{
|
||||
var hive = hives[planet.star.index];
|
||||
var relays = hive?.relays?.buffer;
|
||||
if (relays != null)
|
||||
{
|
||||
var astroId = planet.astroId;
|
||||
for (var i = relays.Length - 1; i >= 0; i--)
|
||||
{
|
||||
var relay = relays[i];
|
||||
if (relay == null || relay.id != i) continue;
|
||||
if (relay.targetAstroId != astroId && relay.searchAstroId != astroId) continue;
|
||||
relay.targetAstroId = 0;
|
||||
relay.searchAstroId = 0;
|
||||
if (relay.baseId > 0)
|
||||
hive.relayNeutralizedCounter++;
|
||||
relay.LeaveBase();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (factory.enemyPool != null)
|
||||
{
|
||||
for (var i = factory.enemyCursor - 1; i > 0; i--)
|
||||
{
|
||||
ref var enemyData = ref factory.enemyPool[i];
|
||||
if (enemyData.id != i) continue;
|
||||
var combatStatId = enemyData.combatStatId;
|
||||
factory.skillSystem.OnRemovingSkillTarget(combatStatId, factory.skillSystem.combatStats.buffer[combatStatId].originAstroId, ETargetType.CombatStat);
|
||||
factory.skillSystem.combatStats.Remove(combatStatId);
|
||||
factory.KillEnemyFinally(i, ref CombatStat.empty);
|
||||
}
|
||||
factory.enemySystem.Free();
|
||||
UIRoot.instance.uiGame.dfAssaultTip.ClearAllSpots();
|
||||
}
|
||||
|
||||
var planetId = planet.id;
|
||||
var gameScenario = GameMain.gameScenario;
|
||||
if (gameScenario != null)
|
||||
{
|
||||
var genPool = factory.powerSystem?.genPool;
|
||||
if (genPool != null)
|
||||
{
|
||||
foreach (var pgc in genPool)
|
||||
{
|
||||
if (pgc.id <= 0) continue;
|
||||
int protoId = factory.entityPool[pgc.entityId].protoId;
|
||||
gameScenario.achievementLogic.NotifyBeforeDismantleEntity(planetId, protoId, pgc.entityId);
|
||||
gameScenario.NotifyOnDismantleEntity(planetId, protoId, pgc.entityId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (revertReform)
|
||||
{
|
||||
factory.PlanetReformRevert();
|
||||
}
|
||||
|
||||
GameMain.data.LeavePlanet();
|
||||
var index = factory.index;
|
||||
var warningSystem = GameMain.data.warningSystem;
|
||||
var warningPool = warningSystem.warningPool;
|
||||
for (var i = warningSystem.warningCursor - 1; i >= 0; i--)
|
||||
{
|
||||
ref var warning = ref warningPool[i];
|
||||
if (warning.id != i) continue;
|
||||
switch (warning.factoryId)
|
||||
{
|
||||
case -4:
|
||||
if (warning.astroId == planetId)
|
||||
warningSystem.RemoveWarningData(i);
|
||||
break;
|
||||
case >= 0:
|
||||
if (warning.factoryId == index)
|
||||
warningSystem.RemoveWarningData(i);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
var isCombatMode = factory.gameData.gameDesc.isCombatMode;
|
||||
factory.entityCursor = 1;
|
||||
factory.entityRecycleCursor = 0;
|
||||
factory.entityCapacity = 0;
|
||||
factory.SetEntityCapacity(1024);
|
||||
factory.craftCursor = 1;
|
||||
factory.craftRecycleCursor = 0;
|
||||
factory.craftCapacity = 0;
|
||||
factory.SetCraftCapacity(128);
|
||||
factory.prebuildCursor = 1;
|
||||
factory.prebuildRecycleCursor = 0;
|
||||
factory.prebuildCapacity = 0;
|
||||
factory.SetPrebuildCapacity(256);
|
||||
factory.enemyCursor = 1;
|
||||
factory.enemyRecycleCursor = 0;
|
||||
factory.enemyCapacity = 0;
|
||||
factory.SetEnemyCapacity(isCombatMode ? 1024 : 32);
|
||||
factory.hashSystemDynamic = new HashSystem();
|
||||
factory.hashSystemStatic = new HashSystem();
|
||||
factory.cargoContainer = new CargoContainer();
|
||||
factory.cargoTraffic = new CargoTraffic(planet);
|
||||
factory.blockContainer = new MiniBlockContainer();
|
||||
factory.factoryStorage = new FactoryStorage(planet);
|
||||
factory.powerSystem = new PowerSystem(planet);
|
||||
factory.constructionSystem = new ConstructionSystem(planet);
|
||||
if (factory.veinPool != null)
|
||||
{
|
||||
for (var i = 0; i < factory.veinPool.Length; i++)
|
||||
{
|
||||
ref var vein = ref factory.veinPool[i];
|
||||
if (vein.id != i) continue;
|
||||
vein.minerCount = 0;
|
||||
vein.minerId0 = 0;
|
||||
vein.minerId1 = 0;
|
||||
vein.minerId2 = 0;
|
||||
vein.minerId3 = 0;
|
||||
}
|
||||
}
|
||||
factory.InitVeinHashAddress();
|
||||
factory.RecalculateAllVeinGroups();
|
||||
factory.InitVegeHashAddress();
|
||||
factory.ruinCursor = 1;
|
||||
factory.ruinRecycleCursor = 0;
|
||||
factory.ruinCapacity = 0;
|
||||
factory.SetRuinCapacity(isCombatMode ? 1024 : 32);
|
||||
factory.factorySystem = new FactorySystem(planet);
|
||||
factory.enemySystem = new EnemyDFGroundSystem(planet);
|
||||
factory.combatGroundSystem = new CombatGroundSystem(planet);
|
||||
factory.defenseSystem = new DefenseSystem(planet);
|
||||
factory.planetATField = new PlanetATField(planet);
|
||||
factory.transport = new PlanetTransport(GameMain.data, planet);
|
||||
factory.transport.Init();
|
||||
var mem = new MemoryStream();
|
||||
var writer = new BinaryWriter(mem);
|
||||
factory.platformSystem.Export(writer);
|
||||
factory.platformSystem = new PlatformSystem(planet, true);
|
||||
mem.Position = 0;
|
||||
var reader = new BinaryReader(mem);
|
||||
factory.platformSystem.Import(reader);
|
||||
mem.Close();
|
||||
mem.Dispose();
|
||||
factory.digitalSystem = new DigitalSystem(planet);
|
||||
|
||||
//GameMain.data.statistics.production.CreateFactoryStat(index);
|
||||
GameMain.data.ArrivePlanet(planet);
|
||||
}
|
||||
|
||||
public static void BuildOrbitalCollectors()
|
||||
{
|
||||
var player = GameMain.mainPlayer;
|
||||
if (player == null) return;
|
||||
var planet = GameMain.localPlanet;
|
||||
if (planet is not { type: EPlanetType.Gas }) return;
|
||||
var countToBuild = OrbitalCollectorMaxBuildCount.Value;
|
||||
if (countToBuild == 0) countToBuild = -1;
|
||||
|
||||
var factory = planet.factory;
|
||||
var stationPool = factory.transport.stationPool;
|
||||
var stationCursor = factory.transport.stationCursor;
|
||||
var entityPool = factory.entityPool;
|
||||
var pos = new Vector3(0f, 0f, planet.realRadius * 1.025f + 0.2f);
|
||||
var found = false;
|
||||
for (var i = 1; i < stationCursor; i++)
|
||||
{
|
||||
if (stationPool[i] == null || stationPool[i].id != i) continue;
|
||||
ref var entity = ref entityPool[stationPool[i].entityId];
|
||||
pos = entity.pos;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
var prebuildCursor = factory.prebuildCursor;
|
||||
var prebuildPool = factory.prebuildPool;
|
||||
if (!found)
|
||||
{
|
||||
for (var i = 1; i < prebuildCursor; i++)
|
||||
{
|
||||
if (prebuildPool[i].id != i) continue;
|
||||
pos = prebuildPool[i].pos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var testPos = pos;
|
||||
var cellCount = PlanetGrid.DetermineLongitudeSegmentCount(0, factory.planet.aux.mainGrid.segment) * 5;
|
||||
var cellRad = Math.PI / cellCount;
|
||||
var distRadCount = 1;
|
||||
for (var i = 1; i <= cellCount; i++)
|
||||
{
|
||||
testPos = Maths.RotateLF(0.0, 1.0, 0.0, cellRad, testPos);
|
||||
if ((testPos - pos).sqrMagnitude < 14297f) continue;
|
||||
distRadCount = i;
|
||||
break;
|
||||
}
|
||||
for (var i = 0; i < cellCount && countToBuild != 0;)
|
||||
{
|
||||
/* Check for collision */
|
||||
var collide = false;
|
||||
for (var j = 1; j < stationCursor; j++)
|
||||
{
|
||||
if (stationPool[j] == null || stationPool[j].id != j) continue;
|
||||
if ((entityPool[stationPool[j].entityId].pos - pos).sqrMagnitude >= 14297f) continue;
|
||||
collide = true;
|
||||
break;
|
||||
}
|
||||
for (var j = 1; j < prebuildCursor; j++)
|
||||
{
|
||||
if (prebuildPool[j].id != j) continue;
|
||||
if ((prebuildPool[j].pos - pos).sqrMagnitude >= 14297f) continue;
|
||||
collide = true;
|
||||
break;
|
||||
}
|
||||
if (collide)
|
||||
{
|
||||
/* rotate for a small cell on sphere */
|
||||
pos = Maths.RotateLF(0.0, 1.0, 0.0, cellRad, pos);
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (player.inhandItemId == OrbitalCollectorItemId && player.inhandItemCount > 0)
|
||||
{
|
||||
player.UseHandItems(1, out var _);
|
||||
}
|
||||
else
|
||||
{
|
||||
var count = 1;
|
||||
var itemId = OrbitalCollectorItemId;
|
||||
player.package.TakeTailItems(ref itemId, ref count, out var _);
|
||||
if (count == 0) break;
|
||||
}
|
||||
|
||||
var rot = Maths.SphericalRotation(pos, 0f);
|
||||
var prebuild = new PrebuildData
|
||||
{
|
||||
protoId = 2105,
|
||||
modelIndex = 117,
|
||||
pos = pos,
|
||||
pos2 = pos,
|
||||
rot = rot,
|
||||
rot2 = rot,
|
||||
pickOffset = 0,
|
||||
insertOffset = 0,
|
||||
recipeId = 0,
|
||||
filterId = 0,
|
||||
paramCount = 0
|
||||
};
|
||||
factory.AddPrebuildDataWithComponents(prebuild);
|
||||
prebuildCursor = factory.prebuildCursor;
|
||||
if (countToBuild > 0) countToBuild--;
|
||||
/* rotate for minimal distance for next OC on sphere */
|
||||
pos = Maths.RotateLF(0.0, 1.0, 0.0, cellRad * distRadCount, pos);
|
||||
i += distRadCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,313 @@
|
||||
namespace UXAssist.Functions;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Common;
|
||||
using UnityEngine;
|
||||
|
||||
public static class TechFunctions
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
I18N.Add("Do you want to use metadata to buyout the following tech?", "Do you want to use metadata to buyout the following tech?", "要使用元数据买断以下科技吗?");
|
||||
I18N.Add("The following is the required metadata for buyout:", "The following is the required metadata for buyout:", "以下是买断所需元数据:");
|
||||
I18N.Add("Batch buyout tech", "Batch buyout tech", "批量买断科技");
|
||||
}
|
||||
|
||||
public static void GenerateTechListWithPrerequisites(GameHistoryData history, int techId, List<int> techIdList)
|
||||
{
|
||||
var techProto = LDB.techs.Select(techId);
|
||||
if (techProto == null || !techProto.Published) return;
|
||||
var flag = true;
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
foreach (var preTechId in (i == 1 ? techProto.PreTechsImplicit : techProto.PreTechs))
|
||||
{
|
||||
if (!history.techStates.ContainsKey(preTechId) || history.techStates[preTechId].unlocked) continue;
|
||||
if (history.techStates[preTechId].maxLevel > history.techStates[preTechId].curLevel)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
GenerateTechListWithPrerequisites(history, preTechId, techIdList);
|
||||
}
|
||||
}
|
||||
if (history.techStates.ContainsKey(techId) && !history.techStates[techId].unlocked && flag)
|
||||
{
|
||||
techIdList.Add(techId);
|
||||
}
|
||||
}
|
||||
|
||||
private static void CheckTechUnlockProperties(GameHistoryData history, TechProto techProto, SortedList<int, int> properties, List<Tuple<TechProto, int, int>> techList, int maxLevel = 10000, bool withPrerequisites = true)
|
||||
{
|
||||
var techStates = history.techStates;
|
||||
var techID = techProto.ID;
|
||||
if (techStates == null || !techStates.TryGetValue(techID, out var value)) return;
|
||||
if (value.unlocked) return;
|
||||
|
||||
var maxLvl = Math.Min(maxLevel < 0 ? value.curLevel - maxLevel - 1 : maxLevel, value.maxLevel);
|
||||
if (withPrerequisites)
|
||||
{
|
||||
foreach (var preid in techProto.PreTechs)
|
||||
{
|
||||
var preProto = LDB.techs.Select(preid);
|
||||
if (preProto != null)
|
||||
CheckTechUnlockProperties(history, preProto, properties, techList, techProto.PreTechsMax ? 10000 : preProto.Level, true);
|
||||
}
|
||||
foreach (var preid in techProto.PreTechsImplicit)
|
||||
{
|
||||
var preProto = LDB.techs.Select(preid);
|
||||
if (preProto != null)
|
||||
CheckTechUnlockProperties(history, preProto, properties, techList, techProto.PreTechsMax ? 10000 : preProto.Level, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (value.curLevel < techProto.Level) value.curLevel = techProto.Level;
|
||||
techList.Add(new Tuple<TechProto, int, int>(techProto, value.curLevel, techProto.Level));
|
||||
while (value.curLevel <= maxLvl)
|
||||
{
|
||||
if (techProto.PropertyOverrideItemArray != null)
|
||||
{
|
||||
var propertyOverrideItemArray = techProto.PropertyOverrideItemArray;
|
||||
for (var i = 0; i < propertyOverrideItemArray.Length; i++)
|
||||
{
|
||||
var id = propertyOverrideItemArray[i].id;
|
||||
var count = (float)propertyOverrideItemArray[i].count;
|
||||
var ratio = Mathf.Clamp01((float)((double)value.hashUploaded / value.hashNeeded));
|
||||
var consume = Mathf.CeilToInt(count * (1f - ratio));
|
||||
if (properties.TryGetValue(id, out var existingCount))
|
||||
properties[id] = existingCount + consume;
|
||||
else
|
||||
properties.Add(id, consume);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var i = 0; i < techProto.itemArray.Length; i++)
|
||||
{
|
||||
var id = techProto.itemArray[i].ID;
|
||||
var consume = (int)(techProto.ItemPoints[i] * (value.hashNeeded - value.hashUploaded) / 3600L);
|
||||
if (properties.TryGetValue(id, out var existingCount))
|
||||
properties[id] = existingCount + consume;
|
||||
else
|
||||
properties.Add(id, consume);
|
||||
}
|
||||
}
|
||||
value.curLevel++;
|
||||
value.hashUploaded = 0;
|
||||
value.hashNeeded = techProto.GetHashNeeded(value.curLevel);
|
||||
}
|
||||
}
|
||||
|
||||
private static int UnlockTechImpl(GameHistoryData history, TechProto techProto, int maxLevel = 10000, bool withPrerequisites = true)
|
||||
{
|
||||
var techStates = history.techStates;
|
||||
var techID = techProto.ID;
|
||||
if (techStates == null || !techStates.TryGetValue(techID, out var value))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (value.unlocked)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
var maxLvl = Math.Min(maxLevel < 0 ? value.curLevel - maxLevel - 1 : maxLevel, value.maxLevel);
|
||||
|
||||
if (withPrerequisites)
|
||||
{
|
||||
foreach (var preid in techProto.PreTechs)
|
||||
{
|
||||
var preProto = LDB.techs.Select(preid);
|
||||
if (preProto != null)
|
||||
UnlockTechImpl(history, preProto, techProto.PreTechsMax ? 10000 : preProto.Level, true);
|
||||
}
|
||||
foreach (var preid in techProto.PreTechsImplicit)
|
||||
{
|
||||
var preProto = LDB.techs.Select(preid);
|
||||
if (preProto != null)
|
||||
UnlockTechImpl(history, preProto, techProto.PreTechsMax ? 10000 : preProto.Level, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (value.curLevel < techProto.Level) value.curLevel = techProto.Level;
|
||||
while (value.curLevel <= maxLvl)
|
||||
{
|
||||
if (value.curLevel == 0)
|
||||
{
|
||||
foreach (var recipe in techProto.UnlockRecipes)
|
||||
{
|
||||
history.UnlockRecipe(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
for (var j = 0; j < techProto.UnlockFunctions.Length; j++)
|
||||
{
|
||||
history.UnlockTechFunction(techProto.UnlockFunctions[j], techProto.UnlockValues[j], value.curLevel);
|
||||
}
|
||||
|
||||
for (var k = 0; k < techProto.AddItems.Length; k++)
|
||||
{
|
||||
history.GainTechAwards(techProto.AddItems[k], techProto.AddItemCounts[k]);
|
||||
}
|
||||
|
||||
value.curLevel++;
|
||||
}
|
||||
|
||||
value.unlocked = maxLvl >= value.maxLevel;
|
||||
value.curLevel = value.unlocked ? maxLvl : maxLvl + 1;
|
||||
value.hashNeeded = techProto.GetHashNeeded(value.curLevel);
|
||||
value.hashUploaded = value.unlocked ? value.hashNeeded : 0;
|
||||
techStates[techID] = value;
|
||||
return maxLvl;
|
||||
}
|
||||
|
||||
private static bool UnlockTechImmediately(TechProto techProto, int maxLevel = 10000, bool withPrerequisites = true)
|
||||
{
|
||||
if (techProto == null) return false;
|
||||
var history = GameMain.history;
|
||||
var ulvl = UnlockTechImpl(history, techProto, maxLevel, withPrerequisites);
|
||||
if (ulvl < 0) return false;
|
||||
history.RegFeatureKey(1000100);
|
||||
history.NotifyTechUnlock(techProto.ID, ulvl);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void UnlockAllProtoWithMetadataAndPrompt()
|
||||
{
|
||||
var history = GameMain.history;
|
||||
List<TechProto> techProtos = [];
|
||||
foreach (var techProto in LDB.techs.dataArray)
|
||||
{
|
||||
if (techProto.Published && !techProto.IsObsolete && !techProto.IsHiddenTech && !history.TechUnlocked(techProto.ID) && (techProto.MaxLevel <= techProto.Level || techProto.MaxLevel <= 16) && (techProto.ID is (< 3301 or > 3309) and (< 3601 or > 3609) and (< 3901 or > 3909)) && techProto.ID != 1508)
|
||||
{
|
||||
techProtos.Add(techProto);
|
||||
}
|
||||
}
|
||||
UnlockProtoWithMetadataAndPrompt([.. techProtos], 16, false);
|
||||
}
|
||||
|
||||
public static void UnlockProtoWithMetadataAndPrompt(TechProto[] techProtos, int toLevel, bool withPrerequisites = true)
|
||||
{
|
||||
var techList = new List<Tuple<TechProto, int, int>>();
|
||||
var properties = new SortedList<int, int>();
|
||||
var history = GameMain.history;
|
||||
foreach (var techProto in techProtos)
|
||||
{
|
||||
CheckTechUnlockProperties(history, techProto, properties, techList, toLevel, withPrerequisites);
|
||||
}
|
||||
var propertySystem = DSPGame.propertySystem;
|
||||
var clusterSeedKey = history.gameData.GetClusterSeedKey();
|
||||
var enough = true;
|
||||
foreach (var consumption in properties)
|
||||
{
|
||||
if (propertySystem.GetItemAvaliableProperty(clusterSeedKey, consumption.Key) >= consumption.Value) continue;
|
||||
enough = false;
|
||||
break;
|
||||
}
|
||||
if (!enough)
|
||||
{
|
||||
UIMessageBox.Show("元数据".Translate(), "元数据不足".Translate(), "确定".Translate(), UIMessageBox.ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!history.hasUsedPropertyBanAchievement)
|
||||
{
|
||||
UIMessageBox.Show("初次使用元数据标题".Translate(), "初次使用元数据描述".Translate(), "取消".Translate(), "确定".Translate(), UIMessageBox.QUESTION, null, DoUnlockCalculatedTechs);
|
||||
return;
|
||||
}
|
||||
|
||||
DoUnlockCalculatedTechs();
|
||||
return;
|
||||
|
||||
void DoUnlockCalculatedTechs()
|
||||
{
|
||||
if (techList.Count <= 1)
|
||||
{
|
||||
UnlockWithPropertiesImmediately();
|
||||
return;
|
||||
}
|
||||
var msg = "Do you want to use metadata to buyout the following tech?".Translate();
|
||||
|
||||
if (techList.Count <= 10)
|
||||
{
|
||||
foreach (var tuple in techList)
|
||||
{
|
||||
AddToMsg(ref msg, tuple);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var i = 0; i < 5; i++)
|
||||
{
|
||||
AddToMsg(ref msg, techList[i]);
|
||||
}
|
||||
msg += "\n ...";
|
||||
for (var i = techList.Count - 5; i < techList.Count; i++)
|
||||
{
|
||||
AddToMsg(ref msg, techList[i]);
|
||||
}
|
||||
}
|
||||
|
||||
msg += "\n\n";
|
||||
msg += "The following is the required metadata for buyout:".Translate();
|
||||
foreach (var consumption in properties)
|
||||
{
|
||||
if (consumption.Value <= 0) continue;
|
||||
msg += $"\n {LDB.items.Select(consumption.Key).propertyName}x{consumption.Value}";
|
||||
}
|
||||
UIMessageBox.Show("Batch buyout tech".Translate(), msg, "取消".Translate(), "确定".Translate(), UIMessageBox.QUESTION, null, UnlockWithPropertiesImmediately);
|
||||
return;
|
||||
|
||||
void AddToMsg(ref string str, Tuple<TechProto, int, int> tuple)
|
||||
{
|
||||
if (tuple.Item2 == tuple.Item3)
|
||||
{
|
||||
if (tuple.Item2 <= 0)
|
||||
str += $"\n {tuple.Item1.name}";
|
||||
else
|
||||
str += $"\n {tuple.Item1.name}{"杠等级".Translate()}{tuple.Item2}";
|
||||
}
|
||||
else
|
||||
str += $"\n {tuple.Item1.name}{"杠等级".Translate()}{tuple.Item2}->{tuple.Item3}";
|
||||
}
|
||||
}
|
||||
|
||||
void UnlockWithPropertiesImmediately()
|
||||
{
|
||||
var mainPlayer = GameMain.mainPlayer;
|
||||
foreach (var consumption in properties)
|
||||
{
|
||||
if (consumption.Value <= 0) continue;
|
||||
propertySystem.AddItemConsumption(clusterSeedKey, consumption.Key, consumption.Value);
|
||||
history.AddPropertyItemConsumption(consumption.Key, consumption.Value, true);
|
||||
mainPlayer.mecha.AddProductionStat(consumption.Key, consumption.Value, mainPlayer.nearestFactory);
|
||||
mainPlayer.mecha.AddConsumptionStat(consumption.Key, consumption.Value, mainPlayer.nearestFactory);
|
||||
}
|
||||
foreach (var techProto in techProtos)
|
||||
{
|
||||
UnlockTechImmediately(techProto, toLevel, withPrerequisites);
|
||||
}
|
||||
history.VerifyTechQueue();
|
||||
if (history.currentTech != history.techQueue[0])
|
||||
{
|
||||
history.currentTech = history.techQueue[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveCargoStackingTechs()
|
||||
{
|
||||
var history = GameMain.data?.history;
|
||||
if (history == null) return;
|
||||
history.inserterStackCountObsolete = 1;
|
||||
for (var id = 3301; id <= 3305; id++)
|
||||
{
|
||||
history.techStates.TryGetValue(id, out var state);
|
||||
if (!state.unlocked) continue;
|
||||
state.unlocked = false;
|
||||
state.hashUploaded = 0;
|
||||
history.techStates[id] = state;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,138 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using BepInEx.Configuration;
|
||||
using UXAssist.Common;
|
||||
|
||||
namespace UXAssist.Functions;
|
||||
|
||||
public static class WindowFunctions
|
||||
{
|
||||
private static bool _initialized;
|
||||
public static string ProfileName { get; private set; }
|
||||
|
||||
private const string GameWindowClass = "UnityWndClass";
|
||||
private static string _gameWindowTitle = "Dyson Sphere Program";
|
||||
|
||||
private static IntPtr _oldWndProc = IntPtr.Zero;
|
||||
private static IntPtr _gameWindowHandle = IntPtr.Zero;
|
||||
|
||||
public static ConfigEntry<int> ProcessPriority;
|
||||
|
||||
private static readonly int[] ProrityFlags =
|
||||
[
|
||||
WinApi.HIGH_PRIORITY_CLASS,
|
||||
WinApi.ABOVE_NORMAL_PRIORITY_CLASS,
|
||||
WinApi.NORMAL_PRIORITY_CLASS,
|
||||
WinApi.BELOW_NORMAL_PRIORITY_CLASS,
|
||||
WinApi.IDLE_PRIORITY_CLASS
|
||||
];
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
if (_initialized) return;
|
||||
_initialized = true;
|
||||
SetWindowTitle();
|
||||
}
|
||||
|
||||
public static void Start()
|
||||
{
|
||||
var wndProc = new WinApi.WndProc(GameWndProc);
|
||||
var gameWnd = FindGameWindow();
|
||||
if (gameWnd != IntPtr.Zero)
|
||||
{
|
||||
_oldWndProc = WinApi.SetWindowLongPtr(gameWnd, WinApi.GWLP_WNDPROC, Marshal.GetFunctionPointerForDelegate(wndProc));
|
||||
}
|
||||
|
||||
ProcessPriority.SettingChanged += (_, _) => WinApi.SetPriorityClass(WinApi.GetCurrentProcess(), ProrityFlags[ProcessPriority.Value]);
|
||||
WinApi.SetPriorityClass(WinApi.GetCurrentProcess(), ProrityFlags[ProcessPriority.Value]);
|
||||
}
|
||||
|
||||
private static IntPtr GameWndProc(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam)
|
||||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
case WinApi.WM_ACTIVATE:
|
||||
WinApi.SetPriorityClass(WinApi.GetCurrentProcess(), ProrityFlags[ProcessPriority.Value]);
|
||||
break;
|
||||
case WinApi.WM_DESTROY:
|
||||
if (_oldWndProc != IntPtr.Zero && _gameWindowHandle != IntPtr.Zero)
|
||||
{
|
||||
WinApi.SetWindowLongPtr(_gameWindowHandle, WinApi.GWLP_WNDPROC, _oldWndProc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return WinApi.CallWindowProc(_oldWndProc, hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
private static string GetPriorityName(int priority)
|
||||
{
|
||||
return priority switch
|
||||
{
|
||||
WinApi.HIGH_PRIORITY_CLASS => "High".Translate(),
|
||||
WinApi.ABOVE_NORMAL_PRIORITY_CLASS => "Above Normal".Translate(),
|
||||
WinApi.NORMAL_PRIORITY_CLASS => "Normal".Translate(),
|
||||
WinApi.BELOW_NORMAL_PRIORITY_CLASS => "Below Normal".Translate(),
|
||||
WinApi.IDLE_PRIORITY_CLASS => "Idle".Translate(),
|
||||
_ => "Unknown".Translate()
|
||||
};
|
||||
}
|
||||
|
||||
public static void SetWindowTitle()
|
||||
{
|
||||
// Get profile name from command line arguments, and set window title accordingly
|
||||
var args = Environment.GetCommandLineArgs();
|
||||
for (var i = args.Length - 2; i >= 0; i--)
|
||||
{
|
||||
if (args[i] == "--gale-profile")
|
||||
{
|
||||
// We use gale profile name directly
|
||||
ProfileName = args[i + 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Doorstop 3.x and 4.x use different arguments to pass the target assembly path
|
||||
if (args[i] != "--doorstop-target" && args[i] != "--doorstop-target-assembly") continue;
|
||||
var arg = args[i + 1];
|
||||
const string doorstopPathSuffix = @"\BepInEx\core\BepInEx.Preloader.dll";
|
||||
if (!arg.EndsWith(doorstopPathSuffix, StringComparison.OrdinalIgnoreCase))
|
||||
break;
|
||||
arg = arg.Substring(0, arg.Length - doorstopPathSuffix.Length);
|
||||
const string profileSuffix = @"\profiles\";
|
||||
var index = arg.LastIndexOf(profileSuffix, StringComparison.OrdinalIgnoreCase);
|
||||
if (index < 0)
|
||||
break;
|
||||
arg = arg.Substring(index + profileSuffix.Length);
|
||||
ProfileName = arg;
|
||||
}
|
||||
var wnd = FindGameWindow();
|
||||
if (wnd == IntPtr.Zero) return;
|
||||
_gameWindowTitle = $"Dyson Sphere Program - {ProfileName}";
|
||||
WinApi.SetWindowText(wnd, _gameWindowTitle);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static IntPtr FindGameWindow()
|
||||
{
|
||||
if (_gameWindowHandle != IntPtr.Zero)
|
||||
return _gameWindowHandle;
|
||||
var wnd = IntPtr.Zero;
|
||||
var consoleWnd = WinApi.GetConsoleWindow();
|
||||
var currentProcessId = WinApi.GetCurrentProcessId();
|
||||
while (true)
|
||||
{
|
||||
wnd = WinApi.FindWindowEx(IntPtr.Zero, wnd, GameWindowClass, _gameWindowTitle);
|
||||
if (wnd == IntPtr.Zero)
|
||||
return IntPtr.Zero;
|
||||
if (wnd == consoleWnd)
|
||||
continue;
|
||||
WinApi.GetWindowThreadProcessId(wnd, out var pid);
|
||||
if (pid == currentProcessId)
|
||||
break;
|
||||
}
|
||||
|
||||
_gameWindowHandle = wnd;
|
||||
return _gameWindowHandle;
|
||||
}
|
||||
}
|
||||
@@ -1,380 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
using UXAssist.Common;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace UXAssist;
|
||||
|
||||
public static class GamePatch
|
||||
{
|
||||
private const string GameWindowClass = "UnityWndClass";
|
||||
private const string GameWindowTitle = "Dyson Sphere Program";
|
||||
|
||||
public static ConfigEntry<bool> EnableWindowResizeEnabled;
|
||||
public static ConfigEntry<bool> LoadLastWindowRectEnabled;
|
||||
// public static ConfigEntry<bool> AutoSaveOptEnabled;
|
||||
public static ConfigEntry<bool> ConvertSavesFromPeaceEnabled;
|
||||
public static ConfigEntry<Vector4> LastWindowRect;
|
||||
private static Harmony _gamePatch;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
EnableWindowResizeEnabled.SettingChanged += (_, _) => EnableWindowResize.Enable(EnableWindowResizeEnabled.Value);
|
||||
LoadLastWindowRectEnabled.SettingChanged += (_, _) => LoadLastWindowRect.Enable(LoadLastWindowRectEnabled.Value);
|
||||
// AutoSaveOptEnabled.SettingChanged += (_, _) => AutoSaveOpt.Enable(AutoSaveOptEnabled.Value);
|
||||
ConvertSavesFromPeaceEnabled.SettingChanged += (_, _) => ConvertSavesFromPeace.Enable(ConvertSavesFromPeaceEnabled.Value);
|
||||
EnableWindowResize.Enable(EnableWindowResizeEnabled.Value);
|
||||
LoadLastWindowRect.Enable(LoadLastWindowRectEnabled.Value);
|
||||
// AutoSaveOpt.Enable(AutoSaveOptEnabled.Value);
|
||||
ConvertSavesFromPeace.Enable(ConvertSavesFromPeaceEnabled.Value);
|
||||
_gamePatch ??= Harmony.CreateAndPatchAll(typeof(GamePatch));
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
LoadLastWindowRect.Enable(false);
|
||||
EnableWindowResize.Enable(false);
|
||||
// AutoSaveOpt.Enable(false);
|
||||
ConvertSavesFromPeace.Enable(false);
|
||||
_gamePatch?.UnpatchSelf();
|
||||
_gamePatch = null;
|
||||
}
|
||||
|
||||
[HarmonyPrefix, HarmonyPatch(typeof(GameMain), nameof(GameMain.HandleApplicationQuit))]
|
||||
private static void GameMain_HandleApplicationQuit_Prefix()
|
||||
{
|
||||
var wnd = WinApi.FindWindow(GameWindowClass, GameWindowTitle);
|
||||
if (wnd == IntPtr.Zero) return;
|
||||
WinApi.GetWindowRect(wnd, out var rect);
|
||||
LastWindowRect.Value = new Vector4(rect.Left, rect.Top, Screen.width, Screen.height);
|
||||
}
|
||||
|
||||
private static class EnableWindowResize
|
||||
{
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
var wnd = WinApi.FindWindow(GameWindowClass, GameWindowTitle);
|
||||
if (wnd == IntPtr.Zero) return;
|
||||
if (on)
|
||||
WinApi.SetWindowLong(wnd, (int)WindowLongFlags.GWL_STYLE,
|
||||
WinApi.GetWindowLong(wnd, (int)WindowLongFlags.GWL_STYLE) | (int)WindowStyles.WS_THICKFRAME | (int)WindowStyles.WS_MAXIMIZEBOX);
|
||||
else
|
||||
WinApi.SetWindowLong(wnd, (int)WindowLongFlags.GWL_STYLE,
|
||||
WinApi.GetWindowLong(wnd, (int)WindowLongFlags.GWL_STYLE) & ~((int)WindowStyles.WS_THICKFRAME | (int)WindowStyles.WS_MAXIMIZEBOX));
|
||||
}
|
||||
}
|
||||
|
||||
private static class LoadLastWindowRect
|
||||
{
|
||||
private static Harmony _patch;
|
||||
private static bool _loaded;
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(LoadLastWindowRect));
|
||||
if (Screen.fullScreenMode is not (FullScreenMode.ExclusiveFullScreen or FullScreenMode.FullScreenWindow or FullScreenMode.MaximizedWindow))
|
||||
{
|
||||
var rect = LastWindowRect.Value;
|
||||
var x = Mathf.RoundToInt(rect.x);
|
||||
var y = Mathf.RoundToInt(rect.y);
|
||||
var w = Mathf.RoundToInt(rect.z);
|
||||
var h = Mathf.RoundToInt(rect.w);
|
||||
var needFix = false;
|
||||
if (w < 100)
|
||||
{
|
||||
w = 1280;
|
||||
needFix = true;
|
||||
}
|
||||
if (h < 100)
|
||||
{
|
||||
h = 720;
|
||||
needFix = true;
|
||||
}
|
||||
var sw = Screen.currentResolution.width;
|
||||
var sh = Screen.currentResolution.height;
|
||||
if (x + w > sw)
|
||||
{
|
||||
x = sw - w;
|
||||
needFix = true;
|
||||
}
|
||||
if (y + h > sh)
|
||||
{
|
||||
y = sh - h;
|
||||
needFix = true;
|
||||
}
|
||||
if (x < 0)
|
||||
{
|
||||
x = 0;
|
||||
needFix = true;
|
||||
}
|
||||
if (y < 0)
|
||||
{
|
||||
y = 0;
|
||||
needFix = true;
|
||||
}
|
||||
if (needFix)
|
||||
{
|
||||
LastWindowRect.Value = new Vector4(x, y, w, h);
|
||||
}
|
||||
}
|
||||
MoveWindowPosition();
|
||||
return;
|
||||
}
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
|
||||
private static void MoveWindowPosition()
|
||||
{
|
||||
if (Screen.fullScreenMode is FullScreenMode.ExclusiveFullScreen or FullScreenMode.FullScreenWindow or FullScreenMode.MaximizedWindow || GameMain.isRunning) return;
|
||||
var wnd = WinApi.FindWindow(GameWindowClass, GameWindowTitle);
|
||||
if (wnd == IntPtr.Zero) return;
|
||||
var rect = LastWindowRect.Value;
|
||||
if (rect.z == 0f && rect.w == 0f) return;
|
||||
var x = Mathf.RoundToInt(rect.x);
|
||||
var y = Mathf.RoundToInt(rect.y);
|
||||
WinApi.SetWindowPos(wnd, IntPtr.Zero, x, y, 0, 0, 0x0235);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(Screen), nameof(Screen.SetResolution), typeof(int), typeof(int), typeof(FullScreenMode), typeof(int))]
|
||||
private static void Screen_SetResolution_Prefix(ref int width, ref int height, FullScreenMode fullscreenMode)
|
||||
{
|
||||
if (fullscreenMode is FullScreenMode.ExclusiveFullScreen or FullScreenMode.FullScreenWindow or FullScreenMode.MaximizedWindow || GameMain.isRunning) return;
|
||||
var rect = LastWindowRect.Value;
|
||||
if (rect.z == 0f && rect.w == 0f) return;
|
||||
var w = Mathf.RoundToInt(rect.z);
|
||||
var h = Mathf.RoundToInt(rect.w);
|
||||
width = w;
|
||||
height = h;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(Screen), nameof(Screen.SetResolution), typeof(int), typeof(int), typeof(FullScreenMode), typeof(int))]
|
||||
private static void Screen_SetResolution_Postfix(FullScreenMode fullscreenMode)
|
||||
{
|
||||
MoveWindowPosition();
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")]
|
||||
private static void VFPreload_InvokeOnLoadWorkEnded_Postfix()
|
||||
{
|
||||
if (_loaded || Screen.fullScreenMode is FullScreenMode.ExclusiveFullScreen or FullScreenMode.FullScreenWindow or FullScreenMode.MaximizedWindow) return;
|
||||
_loaded = true;
|
||||
var wnd = WinApi.FindWindow(GameWindowClass, GameWindowTitle);
|
||||
if (wnd == IntPtr.Zero) return;
|
||||
var rect = LastWindowRect.Value;
|
||||
if (rect.z == 0f && rect.w == 0f) return;
|
||||
var x = Mathf.RoundToInt(rect.x);
|
||||
var y = Mathf.RoundToInt(rect.y);
|
||||
var w = Mathf.RoundToInt(rect.z);
|
||||
var h = Mathf.RoundToInt(rect.w);
|
||||
Screen.SetResolution(w, h, false);
|
||||
WinApi.SetWindowPos(wnd, IntPtr.Zero, x, y, 0, 0, 0x0235);
|
||||
if (EnableWindowResizeEnabled.Value)
|
||||
WinApi.SetWindowLong(wnd, (int)WindowLongFlags.GWL_STYLE,
|
||||
WinApi.GetWindowLong(wnd, (int)WindowLongFlags.GWL_STYLE) | (int)WindowStyles.WS_THICKFRAME | (int)WindowStyles.WS_MAXIMIZEBOX);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
private static class AutoSaveOpt
|
||||
{
|
||||
private static Harmony _patch;
|
||||
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
Directory.CreateDirectory(GameConfig.gameSaveFolder + "AutoSaves/");
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(AutoSaveOpt));
|
||||
return;
|
||||
}
|
||||
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.AutoSave))]
|
||||
private static bool GameSave_AutoSave_Prefix(ref bool __result)
|
||||
{
|
||||
if (!GameSave.SaveCurrentGame(GameSave.AutoSaveTmp))
|
||||
{
|
||||
GlobalObject.SaveOpCounter();
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
var tmpFilename = GameConfig.gameSaveFolder + GameSave.AutoSaveTmp + GameSave.saveExt;
|
||||
var targetFilename = $"{GameConfig.gameSaveFolder}AutoSaves/[{GameMain.data.gameDesc.clusterString}] {DateTime.Now:yyyy-MM-dd_hh-mm-ss}{GameSave.saveExt}";
|
||||
File.Move(tmpFilename, targetFilename);
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(UILoadGameWindow), nameof(UILoadGameWindow.RefreshList))]
|
||||
public static void UILoadGameWindow_RefreshList_Postfix(UILoadGameWindow __instance)
|
||||
{
|
||||
var baseDir = GameConfig.gameSaveFolder + "AutoSaves/";
|
||||
var files = Directory.GetFiles(baseDir, "*" + GameSave.saveExt, SearchOption.TopDirectoryOnly);
|
||||
var entries = __instance.entries;
|
||||
var entries2 = new List<UIGameSaveEntry>();
|
||||
var entryPrefab = __instance.entryPrefab;
|
||||
var entryPrefabParent = entryPrefab.transform.parent;
|
||||
foreach (var f in files)
|
||||
{
|
||||
var fileInfo = new FileInfo(f);
|
||||
var entry = Object.Instantiate(entryPrefab, entryPrefabParent);
|
||||
entry.fileInfo = fileInfo;
|
||||
entries2.Add(entry);
|
||||
}
|
||||
entries2.Sort((x, y) => -x.fileDate.CompareTo(y.fileDate));
|
||||
if (entries2.Count > 10)
|
||||
entries2.RemoveRange(10, entries2.Count - 10);
|
||||
var autoSaveText = ">> " + "自动存档条目".Translate();
|
||||
foreach (var entry in entries2)
|
||||
{
|
||||
entry.indexText.text = "";
|
||||
var saveName = entry.saveName;
|
||||
entry._saveName = $"AutoSaves/{saveName}";
|
||||
var quoteIndex = saveName.IndexOf('[');
|
||||
if (quoteIndex >= 0)
|
||||
{
|
||||
var quoteIndex2 = saveName.IndexOf(']', quoteIndex + 1);
|
||||
if (quoteIndex2 > 0) saveName = saveName.Substring(quoteIndex, quoteIndex2 + 1 - quoteIndex);
|
||||
}
|
||||
entry.nameText.text = $"{autoSaveText} {saveName}";
|
||||
entry.nameText.fontStyle = FontStyle.Italic;
|
||||
entry.nameText.color = new Color(1f, 1f, 1f, 0.7f);
|
||||
entry.timeText.text = $"{entry.fileDate:yyyy-MM-dd HH:mm:ss}";
|
||||
GameSave.ReadModes(entry.fileInfo.FullName, out var isSandbox, out var isPeace);
|
||||
if (entry.sandboxIcon != null)
|
||||
{
|
||||
entry.sandboxIcon.gameObject.SetActive(isSandbox);
|
||||
}
|
||||
if (entry.combatIcon != null)
|
||||
{
|
||||
entry.combatIcon.gameObject.SetActive(!isPeace);
|
||||
}
|
||||
entry.selected = false;
|
||||
entry.gameObject.SetActive(true);
|
||||
}
|
||||
entries.AddRange(entries2);
|
||||
entries.Sort((x, y) => -x.fileDate.CompareTo(y.fileDate));
|
||||
var displayIndex = 1;
|
||||
for (var i = 0; i < entries.Count; i++)
|
||||
{
|
||||
var entry = entries[i];
|
||||
entry.index = i + 1;
|
||||
entry.rectTrans.anchoredPosition = new Vector2(entry.rectTrans.anchoredPosition.x, -40 * i);
|
||||
if (string.IsNullOrEmpty(entry.indexText.text)) continue;
|
||||
entry.indexText.text = displayIndex.ToString();
|
||||
displayIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(UISaveGameWindow), nameof(UISaveGameWindow.RefreshList))]
|
||||
public static void UISaveGameWindow_RefreshList_Postfix(UISaveGameWindow __instance)
|
||||
{
|
||||
var entries = __instance.entries;
|
||||
entries.Sort((x, y) => -x.fileDate.CompareTo(y.fileDate));
|
||||
for (var i = 0; i < entries.Count; i++)
|
||||
{
|
||||
var entry = entries[i];
|
||||
entry.index = i + 1;
|
||||
entry.rectTrans.anchoredPosition = new Vector2(entry.rectTrans.anchoredPosition.x, -40 * i);
|
||||
entry.indexText.text = (i + 1).ToString();
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(UILoadGameWindow), nameof(UILoadGameWindow.DoLoadSelectedGame))]
|
||||
[HarmonyPatch(typeof(UILoadGameWindow), nameof(UILoadGameWindow.OnSelectedChange))]
|
||||
private static IEnumerable<CodeInstruction> UILoadGameWindow_ReplaceSaveName_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.Start().MatchForward(false,
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(UIGameSaveEntry), nameof(UIGameSaveEntry.saveName)))
|
||||
);
|
||||
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldfld, AccessTools.Field(typeof(UIGameSaveEntry), nameof(UIGameSaveEntry._saveName))));
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.LoadCurrentGame))]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.LoadGameDesc))]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.ReadHeader))]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.ReadHeaderAndDescAndProperty))]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.SaveExist))]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.SavePath))]
|
||||
private static IEnumerable<CodeInstruction> GameSave_RemoveValidateOnLoad_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.Start().MatchForward(false,
|
||||
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(CommonUtils), nameof(CommonUtils.ValidFileName)))
|
||||
);
|
||||
matcher.RemoveInstruction();
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
private static class ConvertSavesFromPeace
|
||||
{
|
||||
private static Harmony _patch;
|
||||
private static bool _needConvert;
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(ConvertSavesFromPeace));
|
||||
return;
|
||||
}
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GameDesc), nameof(GameDesc.Import))]
|
||||
private static void GameDesc_Import_Postfix(GameDesc __instance)
|
||||
{
|
||||
if (DSPGame.IsMenuDemo || !__instance.isPeaceMode) return;
|
||||
__instance.combatSettings = UIRoot.instance.galaxySelect.uiCombat.combatSettings;
|
||||
__instance.isPeaceMode = false;
|
||||
_needConvert = true;
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(GameData), nameof(GameData.Import))]
|
||||
private static IEnumerable<CodeInstruction> GameData_Import_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.Start().MatchForward(false,
|
||||
new CodeMatch(instr => (instr.opcode == OpCodes.Ldc_I4 || instr.opcode == OpCodes.Ldc_I4_S) && instr.OperandIs(0x1B)),
|
||||
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(PerformanceMonitor), nameof(PerformanceMonitor.EndData)))
|
||||
);
|
||||
matcher.Advance(2).Opcode = OpCodes.Brfalse;
|
||||
matcher.Insert(
|
||||
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(ConvertSavesFromPeace), nameof(ConvertSavesFromPeace._needConvert)))
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GameData), nameof(GameData.Import))]
|
||||
private static void GameData_Import_Postfix()
|
||||
{
|
||||
_needConvert = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using BepInEx.Bootstrap;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
using UXAssist.Patches;
|
||||
|
||||
namespace UXAssist.ModsCompat;
|
||||
|
||||
public static class AuxilaryfunctionWrapper
|
||||
{
|
||||
private const string AuxilaryfunctionGuid = "cn.blacksnipe.dsp.Auxilaryfunction";
|
||||
public static ConfigEntry<bool> ShowStationInfo;
|
||||
|
||||
public static void Start(Harmony harmony)
|
||||
{
|
||||
if (!Chainloader.PluginInfos.TryGetValue(AuxilaryfunctionGuid, out var pluginInfo)) return;
|
||||
var assembly = pluginInfo.Instance.GetType().Assembly;
|
||||
try
|
||||
{
|
||||
var classType = assembly.GetType("Auxilaryfunction.Auxilaryfunction");
|
||||
ShowStationInfo = (ConfigEntry<bool>)AccessTools.Field(classType, "ShowStationInfo").GetValue(pluginInfo.Instance);
|
||||
}
|
||||
catch
|
||||
{
|
||||
UXAssist.Logger.LogWarning("Failed to get ShowStationInfo from Auxilaryfunction");
|
||||
}
|
||||
try
|
||||
{
|
||||
var classType = assembly.GetType("Auxilaryfunction.Patch.SpeedUpPatch");
|
||||
harmony.Patch(AccessTools.PropertySetter(classType, "Enable"),
|
||||
new HarmonyMethod(AccessTools.Method(typeof(AuxilaryfunctionWrapper), nameof(PatchSpeedUpPatchEnable))));
|
||||
}
|
||||
catch
|
||||
{
|
||||
UXAssist.Logger.LogWarning("Failed to patch SpeedUpPatch.set_Enable() from Auxilaryfunction");
|
||||
}
|
||||
}
|
||||
|
||||
public static void PatchSpeedUpPatchEnable(bool value)
|
||||
{
|
||||
if (!value)
|
||||
{
|
||||
GamePatch.EnableGameUpsFactor = true;
|
||||
return;
|
||||
}
|
||||
if (Math.Abs(GamePatch.GameUpsFactor.Value - 1.0) < 0.001) return;
|
||||
GamePatch.EnableGameUpsFactor = false;
|
||||
UXAssist.Logger.LogInfo("Game UPS changing is disabled when using Auxilaryfunction's speed up feature");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
using HarmonyLib;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using UnityEngine;
|
||||
using UXAssist.Functions;
|
||||
|
||||
namespace UXAssist.ModsCompat;
|
||||
|
||||
class BlueprintTweaks
|
||||
{
|
||||
public const string BlueprintTweaksGuid = "org.kremnev8.plugin.BlueprintTweaks";
|
||||
private static FieldInfo selectObjIdsField;
|
||||
private static Type classTypeBlueprintTweaksPlugin;
|
||||
private static Type classTypeUIBuildingGridPatch2;
|
||||
|
||||
public static bool Run(Harmony harmony)
|
||||
{
|
||||
if (!BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue(BlueprintTweaksGuid, out var pluginInfo)) return false;
|
||||
var assembly = pluginInfo.Instance.GetType().Assembly;
|
||||
var classTypeDragRemoveBuildTool = assembly.GetType("BlueprintTweaks.DragRemoveBuildTool");
|
||||
if (classTypeDragRemoveBuildTool == null) return false;
|
||||
if (AccessTools.Method(classTypeDragRemoveBuildTool, "DetermineMorePreviews") != null) return true;
|
||||
classTypeBlueprintTweaksPlugin = assembly.GetType("BlueprintTweaks.BlueprintTweaksPlugin");
|
||||
classTypeUIBuildingGridPatch2 = assembly.GetType("BlueprintTweaks.UIBuildingGridPatch2");
|
||||
var UIBuildingGrid_Update = AccessTools.Method(typeof(UIBuildingGrid), nameof(UIBuildingGrid.Update));
|
||||
harmony.Patch(AccessTools.Method(classTypeUIBuildingGridPatch2, "UpdateGrid"), null, null, new HarmonyMethod(AccessTools.Method(typeof(BlueprintTweaks), nameof(PatchUpdateGrid))));
|
||||
selectObjIdsField = AccessTools.Field(classTypeDragRemoveBuildTool, "selectObjIds");
|
||||
harmony.Patch(AccessTools.Method(classTypeDragRemoveBuildTool, "DeterminePreviews"),
|
||||
new HarmonyMethod(AccessTools.Method(typeof(BlueprintTweaks), nameof(PatchDeterminePreviews))));
|
||||
return true;
|
||||
}
|
||||
|
||||
private static readonly int zMin = Shader.PropertyToID("_ZMin");
|
||||
private static readonly int reformMode = Shader.PropertyToID("_ReformMode");
|
||||
|
||||
private static IEnumerable<CodeInstruction> PatchUpdateGrid(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldsfld, AccessTools.Field(classTypeBlueprintTweaksPlugin, "tool")),
|
||||
new CodeMatch(OpCodes.Ldfld),
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Brfalse || ci.opcode == OpCodes.Brfalse_S)
|
||||
);
|
||||
var label1 = generator.DefineLabel();
|
||||
matcher.Advance(2).Operand = label1;
|
||||
matcher.Advance(1);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(UIBuildingGrid), nameof(UIBuildingGrid.blueprintMaterial))),
|
||||
new CodeMatch(OpCodes.Ldsfld, AccessTools.Field(classTypeUIBuildingGridPatch2, "tintColor")),
|
||||
new CodeMatch(OpCodes.Call),
|
||||
new CodeMatch(OpCodes.Callvirt)
|
||||
).RemoveInstructions(5);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(UIBuildingGrid), nameof(UIBuildingGrid.blueprintMaterial))),
|
||||
new CodeMatch(OpCodes.Ldsfld, AccessTools.Field(classTypeUIBuildingGridPatch2, "cursorGratBox")),
|
||||
new CodeMatch(OpCodes.Ldsfld),
|
||||
new CodeMatch(OpCodes.Ldfld),
|
||||
new CodeMatch(OpCodes.Call),
|
||||
new CodeMatch(OpCodes.Callvirt)
|
||||
).Advance(1).Operand = AccessTools.Field(typeof(UIBuildingGrid), nameof(UIBuildingGrid.material));
|
||||
matcher.Advance(6);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(UIBuildingGrid), nameof(UIBuildingGrid.blueprintMaterial))),
|
||||
new CodeMatch(OpCodes.Ldsfld, AccessTools.Field(classTypeUIBuildingGridPatch2, "selectColor")),
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld),
|
||||
new CodeMatch(OpCodes.Call),
|
||||
new CodeMatch(OpCodes.Callvirt)
|
||||
).Advance(1).Operand = AccessTools.Field(typeof(UIBuildingGrid), nameof(UIBuildingGrid.material));
|
||||
matcher.Advance(1).Operand = AccessTools.Field(classTypeUIBuildingGridPatch2, "tintColor");
|
||||
matcher.Advance(5);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(UIBuildingGrid), nameof(UIBuildingGrid.blueprintMaterial))),
|
||||
new CodeMatch(OpCodes.Ldsfld, AccessTools.Field(classTypeUIBuildingGridPatch2, "showDivideLine")),
|
||||
new CodeMatch(OpCodes.Ldc_R4, 0f),
|
||||
new CodeMatch(OpCodes.Callvirt)
|
||||
).RemoveInstructions(5);
|
||||
matcher.InsertAndAdvance(new CodeInstruction(OpCodes.Ldarg_0),
|
||||
Transpilers.EmitDelegate((UIBuildingGrid grid) =>
|
||||
{
|
||||
grid.material.SetFloat(reformMode, 0f);
|
||||
grid.material.SetFloat(zMin, -0.5f);
|
||||
})
|
||||
);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(UIBuildingGrid), nameof(UIBuildingGrid.blueprintGridRnd))),
|
||||
new CodeMatch(OpCodes.Ldc_I4_1),
|
||||
new CodeMatch(OpCodes.Callvirt),
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Br || ci.opcode == OpCodes.Br_S)
|
||||
).RemoveInstructions(4).Set(OpCodes.Ret, null).Labels.Add(label1);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
private static void PatchDeterminePreviews(object __instance)
|
||||
{
|
||||
var selectObjIds = (HashSet<int>)selectObjIdsField.GetValue(__instance);
|
||||
var buildTool = (BuildTool)__instance;
|
||||
var factory = buildTool.factory;
|
||||
HashSet<int> extraObjIds = [];
|
||||
foreach (var objId in selectObjIds)
|
||||
{
|
||||
var desc = buildTool.GetPrefabDesc(objId);
|
||||
var isBelt = desc.isBelt;
|
||||
var isInserter = desc.isInserter;
|
||||
if (isInserter) continue;
|
||||
if (isBelt)
|
||||
{
|
||||
var needCheck = false;
|
||||
for (var j = 0; j < 2; j++)
|
||||
{
|
||||
factory.ReadObjectConn(objId, j, out _, out var connObjId, out _);
|
||||
if (connObjId == 0 || FactoryFunctions.ObjectIsBeltOrInserter(factory, connObjId)) continue;
|
||||
needCheck = true;
|
||||
break;
|
||||
}
|
||||
if (needCheck)
|
||||
{
|
||||
for (var k = 0; k < 16; k++)
|
||||
{
|
||||
factory.ReadObjectConn(objId, k, out _, out var connObjId, out _);
|
||||
if (connObjId != 0 && !selectObjIds.Contains(connObjId) && !extraObjIds.Contains(connObjId) && FactoryFunctions.ObjectIsBeltOrInserter(factory, connObjId))
|
||||
extraObjIds.Add(connObjId);
|
||||
}
|
||||
}
|
||||
for (var m = 0; m < 4; m++)
|
||||
{
|
||||
factory.ReadObjectConn(objId, m, out _, out var connObjId, out _);
|
||||
if (connObjId == 0 || !factory.ObjectIsBelt(connObjId) || selectObjIds.Contains(connObjId) || extraObjIds.Contains(connObjId)) continue;
|
||||
for (var j = 0; j < 2; j++)
|
||||
{
|
||||
factory.ReadObjectConn(connObjId, j, out _, out var connObjId2, out _);
|
||||
if (connObjId2 == 0 || selectObjIds.Contains(connObjId2) || extraObjIds.Contains(connObjId2) || FactoryFunctions.ObjectIsBeltOrInserter(factory, connObjId2)) continue;
|
||||
extraObjIds.Add(connObjId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (desc.addonType == EAddonType.Belt) continue;
|
||||
for (var j = 0; j < 16; j++)
|
||||
{
|
||||
factory.ReadObjectConn(objId, j, out _, out var connObjId, out _);
|
||||
if (connObjId != 0 && !selectObjIds.Contains(connObjId) && !extraObjIds.Contains(connObjId) && FactoryFunctions.ObjectIsBeltOrInserter(factory, connObjId))
|
||||
extraObjIds.Add(connObjId);
|
||||
}
|
||||
}
|
||||
selectObjIds.UnionWith(extraObjIds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using BepInEx.Bootstrap;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace UXAssist.ModsCompat;
|
||||
|
||||
public static class BulletTimeWrapper
|
||||
{
|
||||
private const string BulletTimeGuid = "com.starfi5h.plugin.BulletTime";
|
||||
public static bool HasBulletTime;
|
||||
|
||||
public static void Start(Harmony _)
|
||||
{
|
||||
HasBulletTime = Chainloader.PluginInfos.TryGetValue(BulletTimeGuid, out var _);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using BepInEx.Bootstrap;
|
||||
using CommonAPI;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace UXAssist.ModsCompat;
|
||||
|
||||
public static class CommonAPIWrapper
|
||||
{
|
||||
public static void Run(Harmony harmony)
|
||||
{
|
||||
if (!Chainloader.PluginInfos.TryGetValue(CommonAPIPlugin.GUID, out var commonAPIPlugin) ||
|
||||
commonAPIPlugin.Metadata.Version > new System.Version(1, 6, 7, 0)) return;
|
||||
harmony.Patch(AccessTools.Method(typeof(GameOption), nameof(GameOption.InitKeys)), new HarmonyMethod(AccessTools.Method(typeof(CommonAPIWrapper), nameof(PatchInitKeys)), Priority.First));
|
||||
}
|
||||
|
||||
public static bool PatchInitKeys(GameOption __instance)
|
||||
{
|
||||
return __instance.overrideKeys == null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using HarmonyLib;
|
||||
|
||||
namespace UXAssist.ModsCompat;
|
||||
|
||||
class PlanetVeinUtilization
|
||||
{
|
||||
public const string PlanetVeinUtilizationGuid = "testpostpleaseignore.dsp.planet_vein_utilization";
|
||||
|
||||
public static bool Run(Harmony harmony)
|
||||
{
|
||||
if (!BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue(PlanetVeinUtilizationGuid, out var pluginInfo)) return false;
|
||||
var assembly = pluginInfo.Instance.GetType().Assembly;
|
||||
var classType = assembly.GetType("PlanetVeinUtilization.PlanetVeinUtilization");
|
||||
harmony.Patch(AccessTools.Method(classType, "Awake"),
|
||||
new HarmonyMethod(typeof(PlanetVeinUtilization).GetMethod("PatchPlanetVeinUtilizationAwake")));
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool PatchPlanetVeinUtilizationAwake()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,541 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
using UnityEngine.UI;
|
||||
using UXAssist.Common;
|
||||
using GameLogicProc = UXAssist.Common.GameLogic;
|
||||
|
||||
namespace UXAssist.Patches;
|
||||
|
||||
public class DysonSpherePatch : PatchImpl<DysonSpherePatch>
|
||||
{
|
||||
public static ConfigEntry<bool> StopEjectOnNodeCompleteEnabled;
|
||||
public static ConfigEntry<bool> OnlyConstructNodesEnabled;
|
||||
public static ConfigEntry<int> AutoConstructMultiplier;
|
||||
|
||||
private static FieldInfo _totalNodeSpInfo, _totalFrameSpInfo, _totalCpInfo;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
I18N.Add("[UXAssist] No node to fill", "[UXAssist] No node to fill", "[UXAssist] 无可建造节点");
|
||||
Enable(true);
|
||||
StopEjectOnNodeCompleteEnabled.SettingChanged += (_, _) => StopEjectOnNodeComplete.Enable(StopEjectOnNodeCompleteEnabled.Value);
|
||||
OnlyConstructNodesEnabled.SettingChanged += (_, _) => OnlyConstructNodes.Enable(OnlyConstructNodesEnabled.Value);
|
||||
_totalNodeSpInfo = AccessTools.Field(typeof(DysonSphereLayer), "totalNodeSP");
|
||||
_totalFrameSpInfo = AccessTools.Field(typeof(DysonSphereLayer), "totalFrameSP");
|
||||
_totalCpInfo = AccessTools.Field(typeof(DysonSphereLayer), "totalCP");
|
||||
}
|
||||
|
||||
public static void Start()
|
||||
{
|
||||
StopEjectOnNodeComplete.Enable(StopEjectOnNodeCompleteEnabled.Value);
|
||||
OnlyConstructNodes.Enable(OnlyConstructNodesEnabled.Value);
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
StopEjectOnNodeComplete.Enable(false);
|
||||
OnlyConstructNodes.Enable(false);
|
||||
Enable(false);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(DysonSwarm), nameof(DysonSwarm.AutoConstruct))]
|
||||
private static bool DysonSwarm_AutoConstruct_Prefix(DysonSwarm __instance)
|
||||
{
|
||||
return __instance.dysonSphere.autoNodeCount == 0;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(DysonSphere), nameof(DysonSphere.AutoConstruct))]
|
||||
private static bool DysonSphere_AutoConstruct_Prefix(DysonSphere __instance)
|
||||
{
|
||||
var totalCount = AutoConstructMultiplier.Value * 6;
|
||||
foreach (var dysonSphereLayer in __instance.layersIdBased)
|
||||
{
|
||||
if (dysonSphereLayer == null) continue;
|
||||
for (var j = dysonSphereLayer.nodePool.Length - 1; j >= 0; j--)
|
||||
{
|
||||
var dysonNode = dysonSphereLayer.nodePool[j];
|
||||
if (dysonNode == null || dysonNode.id != j) continue;
|
||||
var count = dysonNode._spReq - dysonNode.spOrdered;
|
||||
int todoCount;
|
||||
int[] productRegister;
|
||||
if (count > 0)
|
||||
{
|
||||
if (count > totalCount)
|
||||
{
|
||||
count = totalCount;
|
||||
}
|
||||
|
||||
todoCount = count;
|
||||
if (dysonNode.sp < dysonNode.spMax)
|
||||
{
|
||||
int diff;
|
||||
if (dysonNode.sp + count > dysonNode.spMax)
|
||||
{
|
||||
diff = dysonNode.spMax - dysonNode.sp;
|
||||
count -= diff;
|
||||
dysonNode._spReq -= diff;
|
||||
|
||||
dysonNode.sp = dysonNode.spMax;
|
||||
}
|
||||
else
|
||||
{
|
||||
diff = count;
|
||||
dysonNode._spReq -= diff;
|
||||
|
||||
dysonNode.sp += diff;
|
||||
count = 0;
|
||||
}
|
||||
|
||||
// Make compatible with DSPOptimizations
|
||||
if (_totalNodeSpInfo != null)
|
||||
_totalNodeSpInfo.SetValue(dysonSphereLayer, (long)_totalNodeSpInfo.GetValue(dysonSphereLayer) + diff - 1);
|
||||
__instance.UpdateProgress(dysonNode);
|
||||
}
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
var frameCount = dysonNode.frames.Count;
|
||||
var frameIndex = dysonNode.frameTurn % frameCount;
|
||||
for (var i = frameCount; i > 0 && count > 0; i--)
|
||||
{
|
||||
var dysonFrame = dysonNode.frames[frameIndex];
|
||||
var spMax = dysonFrame.spMax >> 1;
|
||||
if (dysonFrame.nodeA == dysonNode && dysonFrame.spA < spMax)
|
||||
{
|
||||
int diff;
|
||||
if (dysonFrame.spA + count > spMax)
|
||||
{
|
||||
diff = spMax - dysonFrame.spA;
|
||||
count -= diff;
|
||||
dysonNode._spReq -= diff;
|
||||
|
||||
dysonFrame.spA = spMax;
|
||||
}
|
||||
else
|
||||
{
|
||||
diff = count;
|
||||
dysonNode._spReq -= diff;
|
||||
|
||||
dysonFrame.spA += diff;
|
||||
count = 0;
|
||||
}
|
||||
|
||||
// Make compatible with DSPOptimizations
|
||||
if (_totalFrameSpInfo != null)
|
||||
_totalFrameSpInfo.SetValue(dysonSphereLayer, (long)_totalFrameSpInfo.GetValue(dysonSphereLayer) + diff - 1);
|
||||
__instance.UpdateProgress(dysonFrame);
|
||||
}
|
||||
|
||||
if (count > 0 && dysonFrame.nodeB == dysonNode && dysonFrame.spB < spMax)
|
||||
{
|
||||
int diff;
|
||||
if (dysonFrame.spB + count > spMax)
|
||||
{
|
||||
diff = spMax - dysonFrame.spB;
|
||||
count -= diff;
|
||||
dysonNode._spReq -= diff;
|
||||
|
||||
dysonFrame.spB = spMax;
|
||||
}
|
||||
else
|
||||
{
|
||||
diff = count;
|
||||
dysonNode._spReq -= diff;
|
||||
|
||||
dysonFrame.spB += diff;
|
||||
count = 0;
|
||||
}
|
||||
|
||||
// Make compatible with DSPOptimizations
|
||||
if (_totalFrameSpInfo != null)
|
||||
_totalFrameSpInfo.SetValue(dysonSphereLayer, (long)_totalFrameSpInfo.GetValue(dysonSphereLayer) + diff - 1);
|
||||
__instance.UpdateProgress(dysonFrame);
|
||||
}
|
||||
|
||||
frameIndex = (frameIndex + 1) % frameCount;
|
||||
}
|
||||
|
||||
dysonNode.frameTurn = frameIndex;
|
||||
}
|
||||
|
||||
if (dysonNode.spOrdered >= dysonNode._spReq)
|
||||
{
|
||||
__instance.RemoveAutoNode(dysonNode);
|
||||
__instance.PickAutoNode();
|
||||
}
|
||||
|
||||
productRegister = __instance.productRegister;
|
||||
if (productRegister != null)
|
||||
{
|
||||
lock (productRegister)
|
||||
{
|
||||
productRegister[ProductionStatistics.DYSON_STRUCTURE_ID] += todoCount - count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
count = dysonNode._cpReq - dysonNode.cpOrdered;
|
||||
if (count > 0)
|
||||
{
|
||||
if (count > totalCount) count = totalCount;
|
||||
todoCount = count;
|
||||
var shellCount = dysonNode.shells.Count;
|
||||
var shellIndex = dysonNode.shellTurn % shellCount;
|
||||
for (var i = shellCount; i > 0 && count > 0; i--)
|
||||
{
|
||||
var dysonShell = dysonNode.shells[shellIndex];
|
||||
var nodeIndex = dysonShell.nodeIndexMap[dysonNode.id];
|
||||
var diff = (dysonShell.vertsqOffset[nodeIndex + 1] - dysonShell.vertsqOffset[nodeIndex]) * dysonShell.cpPerVertex - dysonShell.nodecps[nodeIndex];
|
||||
if (diff > count)
|
||||
diff = count;
|
||||
count -= diff;
|
||||
dysonNode._cpReq -= diff;
|
||||
dysonShell.nodecps[nodeIndex] += diff;
|
||||
dysonShell.nodecps[dysonShell.nodecps.Length - 1] += diff;
|
||||
// Make compatible with DSPOptimizations
|
||||
if (_totalCpInfo != null)
|
||||
{
|
||||
_totalCpInfo.SetValue(dysonSphereLayer, (long)_totalCpInfo.GetValue(dysonSphereLayer) + diff);
|
||||
dysonShell.SetMaterialDynamicVars();
|
||||
}
|
||||
shellIndex = (shellIndex + 1) % shellCount;
|
||||
}
|
||||
|
||||
dysonNode.shellTurn = shellIndex;
|
||||
|
||||
var solarSailCount = todoCount - count;
|
||||
productRegister = __instance.productRegister;
|
||||
if (productRegister != null)
|
||||
{
|
||||
lock (productRegister)
|
||||
{
|
||||
productRegister[ProductionStatistics.SOLAR_SAIL_ID] += solarSailCount;
|
||||
productRegister[ProductionStatistics.DYSON_CELL_ID] += solarSailCount;
|
||||
}
|
||||
}
|
||||
var consumeRegister = __instance.consumeRegister;
|
||||
if (consumeRegister != null)
|
||||
{
|
||||
lock (consumeRegister)
|
||||
{
|
||||
consumeRegister[ProductionStatistics.SOLAR_SAIL_ID] += solarSailCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPriority(Priority.First)]
|
||||
[HarmonyPatch(typeof(DysonNode), nameof(DysonNode.ConstructCp))]
|
||||
private static IEnumerable<CodeInstruction> DysonSpherePatch_DysonNode_ConstructCp_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchBack(false,
|
||||
new CodeMatch(OpCodes.Ldc_I4_0),
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(DysonShell), nameof(DysonShell.Construct)))
|
||||
).Advance(3).InsertAndAdvance(
|
||||
// node._cpReq = node._cpReq - 1;
|
||||
new CodeInstruction(OpCodes.Ldarg_0),
|
||||
new CodeInstruction(OpCodes.Ldarg_0),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode._cpReq))),
|
||||
new CodeInstruction(OpCodes.Ldc_I4_1),
|
||||
new CodeInstruction(OpCodes.Sub),
|
||||
new CodeInstruction(OpCodes.Stfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode._cpReq)))
|
||||
);
|
||||
// Remove use of RecalcCpReq()
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(DysonNode), nameof(DysonNode.RecalcCpReq)))
|
||||
);
|
||||
var labels = matcher.Labels;
|
||||
matcher.RemoveInstructions(2).Labels.AddRange(labels);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
private class StopEjectOnNodeComplete : PatchImpl<StopEjectOnNodeComplete>
|
||||
{
|
||||
private static HashSet<int>[] _nodeForAbsorb;
|
||||
private static bool _initialized;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
InitNodeForAbsorb();
|
||||
GameLogicProc.OnGameBegin += OnGameBegin;
|
||||
GameLogicProc.OnGameEnd += OnGameEnd;
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
GameLogicProc.OnGameEnd -= OnGameEnd;
|
||||
GameLogicProc.OnGameBegin -= OnGameBegin;
|
||||
_initialized = false;
|
||||
_nodeForAbsorb = null;
|
||||
}
|
||||
|
||||
private static void InitNodeForAbsorb()
|
||||
{
|
||||
_initialized = false;
|
||||
_nodeForAbsorb = null;
|
||||
var data = GameMain.data;
|
||||
var galaxy = data?.galaxy;
|
||||
if (galaxy == null) return;
|
||||
var galaxyStarCount = galaxy.starCount;
|
||||
_nodeForAbsorb = new HashSet<int>[galaxyStarCount];
|
||||
var spheres = data.dysonSpheres;
|
||||
if (spheres == null) return;
|
||||
foreach (var sphere in spheres)
|
||||
{
|
||||
if (sphere?.layersSorted == null) continue;
|
||||
var starIndex = sphere.starData.index;
|
||||
if (starIndex >= galaxyStarCount) continue;
|
||||
foreach (var layer in sphere.layersSorted)
|
||||
{
|
||||
if (layer == null) continue;
|
||||
for (var i = layer.nodeCursor - 1; i > 0; i--)
|
||||
{
|
||||
var node = layer.nodePool[i];
|
||||
if (node == null || node.id != i || node.sp < node.spMax || node.cpReqOrder == 0) continue;
|
||||
SetNodeForAbsorb(starIndex, layer.id, node.id, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
private static void SetNodeForAbsorb(int index, int layerId, int nodeId, bool canAbsorb)
|
||||
{
|
||||
ref var comp = ref _nodeForAbsorb[index];
|
||||
comp ??= [];
|
||||
var idx = nodeId * 10 + layerId;
|
||||
if (canAbsorb)
|
||||
comp.Add(idx);
|
||||
else
|
||||
comp.Remove(idx);
|
||||
}
|
||||
|
||||
private static void UpdateNodeForAbsorbOnSpChange(DysonNode node)
|
||||
{
|
||||
if (!_initialized) return;
|
||||
if (node.sp < node.spMax || node.cpReqOrder <= 0) return;
|
||||
var shells = node.shells;
|
||||
if (shells.Count == 0) return;
|
||||
SetNodeForAbsorb(shells[0].dysonSphere.starData.index, node.layerId, node.id, true);
|
||||
}
|
||||
|
||||
private static void UpdateNodeForAbsorbOnCpChange(DysonNode node)
|
||||
{
|
||||
if (!_initialized) return;
|
||||
if (node.sp < node.spMax || node.cpReqOrder > 0) return;
|
||||
var shells = node.shells;
|
||||
if (shells.Count == 0) return;
|
||||
SetNodeForAbsorb(shells[0].dysonSphere.starData.index, node.layerId, node.id, false);
|
||||
}
|
||||
|
||||
private static bool AnyNodeForAbsorb(int starIndex)
|
||||
{
|
||||
var comp = _nodeForAbsorb[starIndex];
|
||||
return comp is { Count: > 0 };
|
||||
}
|
||||
|
||||
private static void OnGameBegin()
|
||||
{
|
||||
InitNodeForAbsorb();
|
||||
}
|
||||
|
||||
private static void OnGameEnd()
|
||||
{
|
||||
_initialized = false;
|
||||
_nodeForAbsorb = null;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(DysonNode), nameof(DysonNode.RecalcCpReq))]
|
||||
private static void DysonNode_RecalcCpReq_Postfix(DysonNode __instance)
|
||||
{
|
||||
UpdateNodeForAbsorbOnCpChange(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(DysonSphereLayer), nameof(DysonSphereLayer.RemoveDysonNode))]
|
||||
private static void DysonSphereLayer_RemoveDysonNode_Prefix(DysonSphereLayer __instance, int nodeId)
|
||||
{
|
||||
if (_initialized)
|
||||
SetNodeForAbsorb(__instance.starData.index, __instance.id, nodeId, false);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(DysonSphere), nameof(DysonSphere.ResetNew))]
|
||||
private static void DysonSphere_ResetNew_Prefix(DysonSphere __instance)
|
||||
{
|
||||
if (_nodeForAbsorb == null) return;
|
||||
var starIndex = __instance.starData.index;
|
||||
if (starIndex >= _nodeForAbsorb.Length || _nodeForAbsorb[starIndex] == null) return;
|
||||
_nodeForAbsorb[starIndex].Clear();
|
||||
_nodeForAbsorb[starIndex] = null;
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(EjectorComponent), nameof(EjectorComponent.InternalUpdate))]
|
||||
private static IEnumerable<CodeInstruction> EjectorComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
// if (this.runtimeOrbitId == 0
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(EjectorComponent), nameof(EjectorComponent.runtimeOrbitId))),
|
||||
new CodeMatch(OpCodes.Brtrue)
|
||||
).Advance(2).InsertAndAdvance(
|
||||
// || !StopEjectOnNodeComplete.AnyNodeForAbsorb(this.starData.index))
|
||||
new CodeInstruction(OpCodes.Ldc_I4_0),
|
||||
new CodeInstruction(OpCodes.Cgt),
|
||||
new CodeInstruction(OpCodes.Ldarg_3),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(DysonSwarm), nameof(DysonSwarm.starData))),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(StarData), nameof(StarData.index))),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(StopEjectOnNodeComplete), nameof(AnyNodeForAbsorb))),
|
||||
new CodeInstruction(OpCodes.And)
|
||||
);
|
||||
|
||||
// Do not search for next orbit if runtimeOrbitId is not 0 (which means nodes are completed)
|
||||
Label? jmpTarget = null;
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(EjectorComponent), nameof(EjectorComponent.autoOrbit))),
|
||||
new CodeMatch(ci => ci.Branches(out jmpTarget))
|
||||
);
|
||||
if (jmpTarget == null) return matcher.InstructionEnumeration();
|
||||
var labels = matcher.Labels;
|
||||
matcher.Labels = null;
|
||||
matcher.Insert(
|
||||
new CodeInstruction(OpCodes.Ldarg_0).WithLabels(labels),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(EjectorComponent), nameof(EjectorComponent.runtimeOrbitId))),
|
||||
new CodeInstruction(OpCodes.Brtrue, jmpTarget.Value)
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(DysonNode), nameof(DysonNode.ConstructSp))]
|
||||
private static IEnumerable<CodeInstruction> DysonNode_ConstructSp_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.Start().MatchForward(false,
|
||||
new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode.sp)))
|
||||
).Advance(1);
|
||||
var labels = matcher.Labels;
|
||||
matcher.Labels = [];
|
||||
matcher.Insert(
|
||||
new CodeInstruction(OpCodes.Ldarg_0).WithLabels(labels),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(StopEjectOnNodeComplete), nameof(UpdateNodeForAbsorbOnSpChange)))
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(DysonNode), nameof(DysonNode.ConstructCp))]
|
||||
private static IEnumerable<CodeInstruction> DysonNode_ConstructCp_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchBack(false,
|
||||
// Search for previous patch:
|
||||
// node._cpReq = node._cpReq - 1;
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode._cpReq))),
|
||||
new CodeMatch(OpCodes.Ldc_I4_1),
|
||||
new CodeMatch(OpCodes.Sub),
|
||||
new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode._cpReq)))
|
||||
).Advance(6).Insert(
|
||||
new CodeInstruction(OpCodes.Ldarg_0),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(StopEjectOnNodeComplete), nameof(UpdateNodeForAbsorbOnCpChange)))
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(UIEjectorWindow), nameof(UIEjectorWindow._OnUpdate))]
|
||||
static IEnumerable<CodeInstruction> UIEjectorWindow__OnUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
var label1 = generator.DefineLabel();
|
||||
var label2 = generator.DefineLabel();
|
||||
matcher.MatchForward(false,
|
||||
// this.stateText.text = "轨道未设置".Translate();
|
||||
new CodeMatch(OpCodes.Ldstr, "待机"),
|
||||
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(Localization), nameof(Localization.Translate))),
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(Text), nameof(Text.text)))
|
||||
).InsertAndAdvance(
|
||||
// if (StopEjectOnNodeComplete.AnyNodeForAbsorb(this.starData.index))
|
||||
new CodeInstruction(OpCodes.Ldarg_0),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(UIEjectorWindow), nameof(UIEjectorWindow.factorySystem))),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(FactorySystem), nameof(FactorySystem.planet))),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(PlanetData), nameof(PlanetData.star))),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(StarData), nameof(StarData.index))),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(StopEjectOnNodeComplete), nameof(AnyNodeForAbsorb))),
|
||||
new CodeInstruction(OpCodes.Brfalse, label1)
|
||||
).Advance(1).InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Br, label2),
|
||||
new CodeInstruction(OpCodes.Ldstr, "[UXAssist] No node to fill").WithLabels(label1),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Localization), nameof(Localization.Translate)))
|
||||
).Labels.Add(label2);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
[PatchSetCallbackFlag(PatchCallbackFlag.CallOnDisableAfterUnpatch)]
|
||||
private class OnlyConstructNodes : PatchImpl<OnlyConstructNodes>
|
||||
{
|
||||
protected override void OnEnable()
|
||||
{
|
||||
RecheckDysonSphereAutoNodes();
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
RecheckDysonSphereAutoNodes();
|
||||
}
|
||||
|
||||
private static void RecheckDysonSphereAutoNodes()
|
||||
{
|
||||
var spheres = GameMain.data?.dysonSpheres;
|
||||
if (spheres == null) return;
|
||||
foreach (var sphere in spheres)
|
||||
{
|
||||
if (sphere == null) continue;
|
||||
sphere.CheckAutoNodes();
|
||||
if (sphere.autoNodeCount > 0) continue;
|
||||
sphere.PickAutoNode();
|
||||
sphere.PickAutoNode();
|
||||
sphere.PickAutoNode();
|
||||
sphere.PickAutoNode();
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(DysonNode), nameof(DysonNode.spReqOrder), MethodType.Getter)]
|
||||
private static IEnumerable<CodeInstruction> DysonNode_spReqOrder_Getter_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode._spReq)))
|
||||
).Advance(1).SetInstructionAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode.spMax)))
|
||||
).Insert(
|
||||
new CodeInstruction(OpCodes.Ldarg_0),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode.sp))),
|
||||
new CodeInstruction(OpCodes.Sub)
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,573 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection.Emit;
|
||||
using System.Xml;
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using CommonAPI.Systems;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
using UXAssist.Common;
|
||||
using UXAssist.Functions;
|
||||
|
||||
namespace UXAssist.Patches;
|
||||
|
||||
public class GamePatch : PatchImpl<GamePatch>
|
||||
{
|
||||
public static ConfigEntry<bool> EnableWindowResizeEnabled;
|
||||
public static ConfigEntry<bool> LoadLastWindowRectEnabled;
|
||||
|
||||
// public static ConfigEntry<bool> AutoSaveOptEnabled;
|
||||
public static ConfigEntry<bool> ConvertSavesFromPeaceEnabled;
|
||||
public static ConfigEntry<Vector4> LastWindowRect;
|
||||
public static ConfigEntry<bool> ProfileBasedSaveFolderEnabled;
|
||||
public static ConfigEntry<bool> ProfileBasedOptionEnabled;
|
||||
public static ConfigEntry<string> DefaultProfileName;
|
||||
public static ConfigEntry<double> GameUpsFactor;
|
||||
|
||||
private static PressKeyBind _speedDownKey;
|
||||
private static PressKeyBind _speedUpKey;
|
||||
private static bool _enableGameUpsFactor = true;
|
||||
|
||||
public static bool EnableGameUpsFactor
|
||||
{
|
||||
get => _enableGameUpsFactor;
|
||||
set
|
||||
{
|
||||
_enableGameUpsFactor = value;
|
||||
if (value)
|
||||
{
|
||||
var oldFixUps = FPSController.instance.fixUPS;
|
||||
if (oldFixUps <= 1.0)
|
||||
{
|
||||
GameUpsFactor.Value = 1.0;
|
||||
return;
|
||||
}
|
||||
|
||||
GameUpsFactor.Value = Maths.Clamp(FPSController.instance.fixUPS / GameMain.tickPerSec, 0.1, 10.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameUpsFactor.Value = 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
_speedDownKey = KeyBindings.RegisterKeyBinding(new BuiltinKey
|
||||
{
|
||||
key = new CombineKey((int)KeyCode.Minus, CombineKey.CTRL_COMB, ECombineKeyAction.OnceClick, false),
|
||||
conflictGroup = KeyBindConflict.MOVEMENT | KeyBindConflict.FLYING | KeyBindConflict.SAILING | KeyBindConflict.BUILD_MODE_1 | KeyBindConflict.KEYBOARD_KEYBIND,
|
||||
name = "UPSSpeedDown",
|
||||
canOverride = true
|
||||
}
|
||||
);
|
||||
I18N.Add("KEYUPSSpeedDown", "[UXA] Decrease logical frame rate", "[UXA] 降低逻辑帧率");
|
||||
_speedUpKey = KeyBindings.RegisterKeyBinding(new BuiltinKey
|
||||
{
|
||||
key = new CombineKey((int)KeyCode.Equals, CombineKey.CTRL_COMB, ECombineKeyAction.OnceClick, false),
|
||||
conflictGroup = KeyBindConflict.MOVEMENT | KeyBindConflict.UI | KeyBindConflict.FLYING | KeyBindConflict.SAILING | KeyBindConflict.BUILD_MODE_1 | KeyBindConflict.KEYBOARD_KEYBIND,
|
||||
name = "UPSSpeedUp",
|
||||
canOverride = true
|
||||
}
|
||||
);
|
||||
I18N.Add("KEYUPSSpeedUp", "[UXA] Increase logical frame rate", "[UXA] 提升逻辑帧率");
|
||||
I18N.Add("Logical frame rate: {0}x", "[UXA] Logical frame rate: {0}x", "[UXA] 逻辑帧速率: {0}x");
|
||||
|
||||
EnableWindowResizeEnabled.SettingChanged += (_, _) => EnableWindowResize.Enable(EnableWindowResizeEnabled.Value);
|
||||
LoadLastWindowRectEnabled.SettingChanged += (_, _) =>
|
||||
{
|
||||
if (LoadLastWindowRectEnabled.Value)
|
||||
{
|
||||
FixLastWindowRect();
|
||||
}
|
||||
};
|
||||
// AutoSaveOptEnabled.SettingChanged += (_, _) => AutoSaveOpt.Enable(AutoSaveOptEnabled.Value);
|
||||
ConvertSavesFromPeaceEnabled.SettingChanged += (_, _) => ConvertSavesFromPeace.Enable(ConvertSavesFromPeaceEnabled.Value);
|
||||
ProfileBasedSaveFolderEnabled.SettingChanged += (_, _) => RefreshSavePath();
|
||||
ProfileBasedOptionEnabled.SettingChanged += (_, _) => ProfileBasedOption.Enable(ProfileBasedOptionEnabled.Value);
|
||||
DefaultProfileName.SettingChanged += (_, _) => RefreshSavePath();
|
||||
GameUpsFactor.SettingChanged += (_, _) =>
|
||||
{
|
||||
if (!EnableGameUpsFactor || GameUpsFactor.Value == 0.0) return;
|
||||
if (Math.Abs(GameUpsFactor.Value - 1.0) < 0.001)
|
||||
{
|
||||
FPSController.SetFixUPS(0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
FPSController.SetFixUPS(GameMain.tickPerSec * GameUpsFactor.Value);
|
||||
};
|
||||
ProfileBasedOption.Enable(ProfileBasedOptionEnabled.Value);
|
||||
}
|
||||
|
||||
public static void Start()
|
||||
{
|
||||
if (LoadLastWindowRectEnabled.Value)
|
||||
{
|
||||
FixLastWindowRect();
|
||||
var wnd = WindowFunctions.FindGameWindow();
|
||||
if (wnd != IntPtr.Zero)
|
||||
{
|
||||
ThreadingHelper.Instance.StartCoroutine(SetWindowPositionCoroutine(wnd, (int)LastWindowRect.Value.x, (int)LastWindowRect.Value.y));
|
||||
}
|
||||
}
|
||||
EnableWindowResize.Enable(EnableWindowResizeEnabled.Value);
|
||||
// AutoSaveOpt.Enable(AutoSaveOptEnabled.Value);
|
||||
ConvertSavesFromPeace.Enable(ConvertSavesFromPeaceEnabled.Value);
|
||||
Enable(true);
|
||||
|
||||
RefreshSavePath();
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
Enable(false);
|
||||
EnableWindowResize.Enable(false);
|
||||
// AutoSaveOpt.Enable(false);
|
||||
ConvertSavesFromPeace.Enable(false);
|
||||
}
|
||||
|
||||
public static void OnInputUpdate()
|
||||
{
|
||||
if (!_enableGameUpsFactor) return;
|
||||
if (_speedDownKey.keyValue)
|
||||
{
|
||||
GameUpsFactor.Value = Maths.Clamp(Math.Round((GameUpsFactor.Value - 0.5) * 2.0) / 2.0, 0.1, 10.0);
|
||||
UIRoot.instance.uiGame.generalTips.InvokeRealtimeTipAhead(string.Format("Logical frame rate: {0}x".Translate(), GameUpsFactor.Value));
|
||||
}
|
||||
|
||||
if (_speedUpKey.keyValue)
|
||||
{
|
||||
GameUpsFactor.Value = Maths.Clamp(Math.Round((GameUpsFactor.Value + 0.5) * 2.0) / 2.0, 0.1, 10.0);
|
||||
UIRoot.instance.uiGame.generalTips.InvokeRealtimeTipAhead(string.Format("Logical frame rate: {0}x".Translate(), GameUpsFactor.Value));
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPriority(Priority.First)]
|
||||
[HarmonyPatch(typeof(GameConfig), nameof(GameConfig.gameSaveFolder), MethodType.Getter)]
|
||||
public static void GameConfig_gameSaveFolder_Postfix(ref string __result)
|
||||
{
|
||||
if (!ProfileBasedSaveFolderEnabled.Value || string.IsNullOrEmpty(WindowFunctions.ProfileName)) return;
|
||||
__result = $"{__result}{WindowFunctions.ProfileName}/";
|
||||
}
|
||||
|
||||
private static void RefreshSavePath()
|
||||
{
|
||||
var gameSaveFolder = GameConfig.gameSaveFolder;
|
||||
if (!Directory.Exists(gameSaveFolder))
|
||||
Directory.CreateDirectory(gameSaveFolder);
|
||||
if (UIRoot.instance?.loadGameWindow?.active == true) UIRoot.instance.loadGameWindow.RefreshList();
|
||||
if (UIRoot.instance?.saveGameWindow?.active == true) UIRoot.instance.saveGameWindow.RefreshList();
|
||||
}
|
||||
|
||||
[HarmonyPrefix, HarmonyPatch(typeof(GameMain), nameof(GameMain.HandleApplicationQuit))]
|
||||
private static void GameMain_HandleApplicationQuit_Prefix()
|
||||
{
|
||||
if (!LoadLastWindowRectEnabled.Value) return;
|
||||
var wnd = WindowFunctions.FindGameWindow();
|
||||
if (wnd == IntPtr.Zero) return;
|
||||
WinApi.GetWindowRect(wnd, out var rect);
|
||||
LastWindowRect.Value = new Vector4(rect.Left, rect.Top, Screen.width, Screen.height);
|
||||
}
|
||||
private static void FixLastWindowRect()
|
||||
{
|
||||
if (Screen.fullScreenMode is not (FullScreenMode.ExclusiveFullScreen or FullScreenMode.FullScreenWindow or FullScreenMode.MaximizedWindow))
|
||||
{
|
||||
var rect = LastWindowRect.Value;
|
||||
var x = Mathf.RoundToInt(rect.x);
|
||||
var y = Mathf.RoundToInt(rect.y);
|
||||
var w = Mathf.RoundToInt(rect.z);
|
||||
var h = Mathf.RoundToInt(rect.w);
|
||||
var needFix = false;
|
||||
if (w < 100)
|
||||
{
|
||||
w = 1280;
|
||||
needFix = true;
|
||||
}
|
||||
|
||||
if (h < 100)
|
||||
{
|
||||
h = 720;
|
||||
needFix = true;
|
||||
}
|
||||
|
||||
var rc = new WinApi.Rect { Left = x, Top = y, Right = x + w, Bottom = y + h };
|
||||
if (WinApi.MonitorFromRect(ref rc, 0) == IntPtr.Zero)
|
||||
{
|
||||
x = 0;
|
||||
y = 0;
|
||||
w = 1280;
|
||||
h = 720;
|
||||
needFix = true;
|
||||
}
|
||||
if (needFix)
|
||||
{
|
||||
LastWindowRect.Value = new Vector4(x, y, w, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerator SetWindowPositionCoroutine(IntPtr wnd, int x, int y)
|
||||
{
|
||||
yield return new WaitForEndOfFrame();
|
||||
yield return new WaitForEndOfFrame();
|
||||
WinApi.SetWindowPos(wnd, IntPtr.Zero, x, y, 0, 0, 0x0235);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(Screen), nameof(Screen.SetResolution), typeof(int), typeof(int), typeof(FullScreenMode), typeof(RefreshRate))]
|
||||
private static void Screen_SetResolution_Prefix(ref int width, ref int height, FullScreenMode fullscreenMode, ref Vector2Int __state)
|
||||
{
|
||||
if (fullscreenMode is FullScreenMode.ExclusiveFullScreen or FullScreenMode.FullScreenWindow or FullScreenMode.MaximizedWindow) return;
|
||||
if (GameMain.isRunning)
|
||||
{
|
||||
var wnd = WindowFunctions.FindGameWindow();
|
||||
if (wnd == IntPtr.Zero) return;
|
||||
WinApi.GetWindowRect(wnd, out var rc);
|
||||
__state = new Vector2Int(rc.Left, rc.Top);
|
||||
return;
|
||||
}
|
||||
else if (!LoadLastWindowRectEnabled.Value) return;
|
||||
int x = 0, y = 0, w = 0, h = 0;
|
||||
var rect = LastWindowRect.Value;
|
||||
if (rect is not { z: 0f, w: 0f })
|
||||
{
|
||||
x = Mathf.RoundToInt(rect.x);
|
||||
y = Mathf.RoundToInt(rect.y);
|
||||
w = Mathf.RoundToInt(rect.z);
|
||||
h = Mathf.RoundToInt(rect.w);
|
||||
}
|
||||
width = w;
|
||||
height = h;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(Screen), nameof(Screen.SetResolution), typeof(int), typeof(int), typeof(FullScreenMode), typeof(RefreshRate))]
|
||||
private static void Screen_SetResolution_Postfix(FullScreenMode fullscreenMode, Vector2Int __state)
|
||||
{
|
||||
if (fullscreenMode is FullScreenMode.ExclusiveFullScreen or FullScreenMode.FullScreenWindow or FullScreenMode.MaximizedWindow) return;
|
||||
var gameRunning = GameMain.isRunning;
|
||||
if (!LoadLastWindowRectEnabled.Value && !gameRunning) return;
|
||||
var wnd = WindowFunctions.FindGameWindow();
|
||||
if (wnd == IntPtr.Zero) return;
|
||||
int x, y;
|
||||
if (gameRunning)
|
||||
{
|
||||
x = __state.x;
|
||||
y = __state.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
var rect = LastWindowRect.Value;
|
||||
if (rect is { z: 0f, w: 0f }) return;
|
||||
x = Mathf.RoundToInt(rect.x);
|
||||
y = Mathf.RoundToInt(rect.y);
|
||||
}
|
||||
ThreadingHelper.Instance.StartCoroutine(SetWindowPositionCoroutine(wnd, x, y));
|
||||
}
|
||||
|
||||
private class EnableWindowResize : PatchImpl<EnableWindowResize>
|
||||
{
|
||||
private static bool _enabled;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
var wnd = WindowFunctions.FindGameWindow();
|
||||
if (wnd == IntPtr.Zero)
|
||||
{
|
||||
Enable(false);
|
||||
return;
|
||||
}
|
||||
|
||||
_enabled = true;
|
||||
WinApi.SetWindowLong(wnd, WinApi.GWL_STYLE,
|
||||
WinApi.GetWindowLong(wnd, WinApi.GWL_STYLE) | WinApi.WS_THICKFRAME | WinApi.WS_MAXIMIZEBOX);
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
var wnd = WindowFunctions.FindGameWindow();
|
||||
if (wnd == IntPtr.Zero)
|
||||
return;
|
||||
|
||||
_enabled = false;
|
||||
WinApi.SetWindowLong(wnd, WinApi.GWL_STYLE,
|
||||
WinApi.GetWindowLong(wnd, WinApi.GWL_STYLE) & ~(WinApi.WS_THICKFRAME | WinApi.WS_MAXIMIZEBOX));
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(UIOptionWindow), nameof(UIOptionWindow.ApplyOptions))]
|
||||
private static void UIOptionWindow_ApplyOptions_Postfix()
|
||||
{
|
||||
var wnd = WindowFunctions.FindGameWindow();
|
||||
if (wnd == IntPtr.Zero) return;
|
||||
if (_enabled)
|
||||
WinApi.SetWindowLong(wnd, WinApi.GWL_STYLE,
|
||||
WinApi.GetWindowLong(wnd, WinApi.GWL_STYLE) | WinApi.WS_THICKFRAME | WinApi.WS_MAXIMIZEBOX);
|
||||
else
|
||||
WinApi.SetWindowLong(wnd, WinApi.GWL_STYLE,
|
||||
WinApi.GetWindowLong(wnd, WinApi.GWL_STYLE) & ~(WinApi.WS_THICKFRAME | WinApi.WS_MAXIMIZEBOX));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
private class AutoSaveOpt: PatchImpl<AutoSaveOpt>
|
||||
{
|
||||
protected override void OnEnable()
|
||||
{
|
||||
Directory.CreateDirectory(GameConfig.gameSaveFolder + "AutoSaves/");
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.AutoSave))]
|
||||
private static bool GameSave_AutoSave_Prefix(ref bool __result)
|
||||
{
|
||||
if (!GameSave.SaveCurrentGame(GameSave.AutoSaveTmp))
|
||||
{
|
||||
GlobalObject.SaveOpCounter();
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
var tmpFilename = GameConfig.gameSaveFolder + GameSave.AutoSaveTmp + GameSave.saveExt;
|
||||
var targetFilename = $"{GameConfig.gameSaveFolder}AutoSaves/[{GameMain.data.gameDesc.clusterString}] {DateTime.Now:yyyy-MM-dd_hh-mm-ss}{GameSave.saveExt}";
|
||||
File.Move(tmpFilename, targetFilename);
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(UILoadGameWindow), nameof(UILoadGameWindow.RefreshList))]
|
||||
public static void UILoadGameWindow_RefreshList_Postfix(UILoadGameWindow __instance)
|
||||
{
|
||||
var baseDir = GameConfig.gameSaveFolder + "AutoSaves/";
|
||||
var files = Directory.GetFiles(baseDir, "*" + GameSave.saveExt, SearchOption.TopDirectoryOnly);
|
||||
var entries = __instance.entries;
|
||||
var entries2 = new List<UIGameSaveEntry>();
|
||||
var entryPrefab = __instance.entryPrefab;
|
||||
var entryPrefabParent = entryPrefab.transform.parent;
|
||||
foreach (var f in files)
|
||||
{
|
||||
var fileInfo = new FileInfo(f);
|
||||
var entry = Object.Instantiate(entryPrefab, entryPrefabParent);
|
||||
entry.fileInfo = fileInfo;
|
||||
entries2.Add(entry);
|
||||
}
|
||||
entries2.Sort((x, y) => -x.fileDate.CompareTo(y.fileDate));
|
||||
if (entries2.Count > 10)
|
||||
entries2.RemoveRange(10, entries2.Count - 10);
|
||||
var autoSaveText = ">> " + "自动存档条目".Translate();
|
||||
foreach (var entry in entries2)
|
||||
{
|
||||
entry.indexText.text = "";
|
||||
var saveName = entry.saveName;
|
||||
entry._saveName = $"AutoSaves/{saveName}";
|
||||
var quoteIndex = saveName.IndexOf('[');
|
||||
if (quoteIndex >= 0)
|
||||
{
|
||||
var quoteIndex2 = saveName.IndexOf(']', quoteIndex + 1);
|
||||
if (quoteIndex2 > 0) saveName = saveName.Substring(quoteIndex, quoteIndex2 + 1 - quoteIndex);
|
||||
}
|
||||
entry.nameText.text = $"{autoSaveText} {saveName}";
|
||||
entry.nameText.fontStyle = FontStyle.Italic;
|
||||
entry.nameText.color = new Color(1f, 1f, 1f, 0.7f);
|
||||
entry.timeText.text = $"{entry.fileDate:yyyy-MM-dd HH:mm:ss}";
|
||||
GameSave.ReadModes(entry.fileInfo.FullName, out var isSandbox, out var isPeace);
|
||||
if (entry.sandboxIcon != null)
|
||||
{
|
||||
entry.sandboxIcon.gameObject.SetActive(isSandbox);
|
||||
}
|
||||
if (entry.combatIcon != null)
|
||||
{
|
||||
entry.combatIcon.gameObject.SetActive(!isPeace);
|
||||
}
|
||||
entry.selected = false;
|
||||
entry.gameObject.SetActive(true);
|
||||
}
|
||||
entries.AddRange(entries2);
|
||||
entries.Sort((x, y) => -x.fileDate.CompareTo(y.fileDate));
|
||||
var displayIndex = 1;
|
||||
for (var i = 0; i < entries.Count; i++)
|
||||
{
|
||||
var entry = entries[i];
|
||||
entry.index = i + 1;
|
||||
entry.rectTrans.anchoredPosition = new Vector2(entry.rectTrans.anchoredPosition.x, -40 * i);
|
||||
if (string.IsNullOrEmpty(entry.indexText.text)) continue;
|
||||
entry.indexText.text = displayIndex.ToString();
|
||||
displayIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(UISaveGameWindow), nameof(UISaveGameWindow.RefreshList))]
|
||||
public static void UISaveGameWindow_RefreshList_Postfix(UISaveGameWindow __instance)
|
||||
{
|
||||
var entries = __instance.entries;
|
||||
entries.Sort((x, y) => -x.fileDate.CompareTo(y.fileDate));
|
||||
for (var i = 0; i < entries.Count; i++)
|
||||
{
|
||||
var entry = entries[i];
|
||||
entry.index = i + 1;
|
||||
entry.rectTrans.anchoredPosition = new Vector2(entry.rectTrans.anchoredPosition.x, -40 * i);
|
||||
entry.indexText.text = (i + 1).ToString();
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(UILoadGameWindow), nameof(UILoadGameWindow.DoLoadSelectedGame))]
|
||||
[HarmonyPatch(typeof(UILoadGameWindow), nameof(UILoadGameWindow.OnSelectedChange))]
|
||||
private static IEnumerable<CodeInstruction> UILoadGameWindow_ReplaceSaveName_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.Start().MatchForward(false,
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(UIGameSaveEntry), nameof(UIGameSaveEntry.saveName)))
|
||||
);
|
||||
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldfld, AccessTools.Field(typeof(UIGameSaveEntry), nameof(UIGameSaveEntry._saveName))));
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.LoadCurrentGame))]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.LoadGameDesc))]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.ReadHeader))]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.ReadHeaderAndDescAndProperty))]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.SaveExist))]
|
||||
[HarmonyPatch(typeof(GameSave), nameof(GameSave.SavePath))]
|
||||
private static IEnumerable<CodeInstruction> GameSave_RemoveValidateOnLoad_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.Start().MatchForward(false,
|
||||
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(CommonUtils), nameof(CommonUtils.ValidFileName)))
|
||||
);
|
||||
matcher.RemoveInstruction();
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
private class ConvertSavesFromPeace : PatchImpl<ConvertSavesFromPeace>
|
||||
{
|
||||
private static bool _needConvert;
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GameDesc), nameof(GameDesc.Import))]
|
||||
private static void GameDesc_Import_Postfix(GameDesc __instance)
|
||||
{
|
||||
if (DSPGame.IsMenuDemo || !__instance.isPeaceMode) return;
|
||||
__instance.combatSettings = UIRoot.instance.galaxySelect.uiCombat.combatSettings;
|
||||
__instance.isPeaceMode = false;
|
||||
_needConvert = true;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GameHistoryData), nameof(GameHistoryData.Import))]
|
||||
private static void GameHistoryData_Import_Postfix(GameHistoryData __instance)
|
||||
{
|
||||
if (_needConvert)
|
||||
{
|
||||
__instance.combatSettings = UIRoot.instance.galaxySelect.uiCombat.combatSettings;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(GameData), nameof(GameData.Import))]
|
||||
private static IEnumerable<CodeInstruction> GameData_Import_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.Start().MatchForward(false,
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(Player), nameof(Player.mecha))),
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(Mecha), nameof(Mecha.CheckCombatModuleDataIsValidPatch)))
|
||||
);
|
||||
matcher.Advance(2).Opcode = OpCodes.Brfalse;
|
||||
matcher.Insert(
|
||||
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(ConvertSavesFromPeace), nameof(_needConvert)))
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GameData), nameof(GameData.Import))]
|
||||
private static void GameData_Import_Postfix()
|
||||
{
|
||||
_needConvert = false;
|
||||
}
|
||||
}
|
||||
|
||||
private class ProfileBasedOption : PatchImpl<ProfileBasedOption>
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(GameOption), nameof(GameOption.LoadGlobal))]
|
||||
private static bool GameOption_LoadGlobal_Prefix(ref GameOption __instance)
|
||||
{
|
||||
var profileName = WindowFunctions.ProfileName;
|
||||
if (profileName == null)
|
||||
{
|
||||
// We should initialize WindowFunctions before using WindowFunctions.ProfileName
|
||||
WindowFunctions.Init();
|
||||
profileName = WindowFunctions.ProfileName;
|
||||
if (profileName == null) return true;
|
||||
}
|
||||
if (string.Compare(DefaultProfileName.Value, profileName, StringComparison.OrdinalIgnoreCase) == 0) return true;
|
||||
var optionPath = $"{GameConfig.gameDocumentFolder}Option/{profileName}.xml";
|
||||
if (File.Exists(optionPath))
|
||||
{
|
||||
try
|
||||
{
|
||||
__instance.ImportXML(optionPath);
|
||||
return false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
var gameXMLOptionPath = GameConfig.gameXMLOptionPath;
|
||||
if (File.Exists(gameXMLOptionPath))
|
||||
{
|
||||
try
|
||||
{
|
||||
__instance.ImportXML(gameXMLOptionPath);
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogException(ex);
|
||||
}
|
||||
}
|
||||
GameOption.newlyCreated = true;
|
||||
__instance.SetDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(GameOption), nameof(GameOption.SaveGlobal))]
|
||||
private static bool GameOption_SaveGlobal_Prefix(ref GameOption __instance)
|
||||
{
|
||||
var profileName = WindowFunctions.ProfileName;
|
||||
if (profileName == null) return true;
|
||||
if (string.Compare(DefaultProfileName.Value, profileName, StringComparison.OrdinalIgnoreCase) == 0) return true;
|
||||
var path = $"{GameConfig.gameDocumentFolder}Option";
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
try
|
||||
{
|
||||
using FileStream fileStream = new($"{path}/{profileName}.xml", FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
using XmlTextWriter xmlTextWriter = new(fileStream, Console.OutputEncoding);
|
||||
xmlTextWriter.Formatting = Formatting.Indented;
|
||||
__instance.ExportXML(xmlTextWriter);
|
||||
xmlTextWriter.Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user