Skip to content

Commit 2e3c8ff

Browse files
committed
fix the problem with existing saves.
1 parent 25d9c6e commit 2e3c8ff

File tree

3 files changed

+86
-16
lines changed

3 files changed

+86
-16
lines changed

InstantDelivery/InstantDelivery/Plugin.cs

Lines changed: 75 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ public class InstantDelivery : BaseUnityPlugin
1111
public const string __NAME__ = "InstantDelivery";
1212
public const string __GUID__ = "lxb007981.dsp." + __NAME__;
1313

14-
private ConfigEntry<bool> configMethod;
1514
Harmony harmony;
1615

1716
public void Awake()
@@ -23,8 +22,7 @@ public void Awake()
2322
"General",
2423
"EnableVessels",
2524
true,
26-
"Whether to enable sending out vessels as in the original game. Note setting this option to false will freeze vessels that have taken off.").Value;
27-
25+
"Decide whether to allow sending out vessels as in the original game. Keep this setting enabled (true) to ensure compatibility with an existing game save.").Value;
2826
harmony.PatchAll(typeof(InstantDelivery));
2927
}
3028

@@ -37,10 +35,67 @@ public void OnDestroy()
3735
{
3836
harmony.UnpatchSelf();
3937
}
40-
[HarmonyPrefix, HarmonyPatch(typeof(StationComponent), "InternalTickRemote")]
41-
public static void InternalTickRemote_Prefix(ref StationComponent __instance, PlanetFactory factory, int timeGene, float shipSailSpeed, float shipWarpSpeed, int shipCarries, StationComponent[] gStationPool, AstroData[] astroPoses, ref VectorLF3 relativePos, ref Quaternion relativeRot, bool starmap, int[] consumeRegister, ref bool __runOriginal)
38+
39+
private static void SpeedUpShip(ref StationComponent __instance)
40+
{
41+
int j = 0;
42+
while (j < __instance.workShipCount)
43+
{
44+
ref ShipData ptr2 = ref __instance.workShipDatas[j];
45+
if (ptr2.stage < -1)
46+
{
47+
if (ptr2.direction > 0)
48+
{
49+
ptr2.t = 1.2f;
50+
}
51+
else
52+
{
53+
ptr2.t = -0.1f;
54+
}
55+
}
56+
else if (ptr2.stage == -1)
57+
{
58+
if (ptr2.direction > 0)
59+
{
60+
ptr2.t = 1.1f;
61+
}
62+
else
63+
{
64+
ptr2.t = -0.2f;
65+
}
66+
}
67+
else if (ptr2.stage == 0)
68+
{
69+
ptr2.t = 1f;
70+
ptr2.stage = ptr2.direction;
71+
}
72+
else if (ptr2.stage == 1)
73+
{
74+
if (ptr2.direction > 0)
75+
{
76+
ptr2.t = -1f;
77+
}
78+
else
79+
{
80+
ptr2.t = 1.1f;
81+
}
82+
}
83+
else if (ptr2.direction > 0)
84+
{
85+
ptr2.t = -0.2f;
86+
87+
}
88+
else
89+
{
90+
ptr2.t = 1.2f;
91+
}
92+
93+
j++;
94+
}
95+
}
96+
97+
private static void TeleportShip(ref StationComponent __instance, PlanetFactory factory, int timeGene, float shipSailSpeed, float shipWarpSpeed, int shipCarries, StationComponent[] gStationPool, AstroData[] astroPoses, ref VectorLF3 relativePos, ref Quaternion relativeRot, bool starmap, int[] consumeRegister)
4298
{
43-
__runOriginal = Configs.configEnableVessels;
4499
__instance.warperFree = DSPGame.IsMenuDemo;
45100
if (__instance.warperCount < __instance.warperMaxCount)
46101
{
@@ -348,5 +403,19 @@ public static void InternalTickRemote_Prefix(ref StationComponent __instance, Pl
348403
}
349404
}
350405
}
406+
407+
[HarmonyPrefix, HarmonyPatch(typeof(StationComponent), "InternalTickRemote")]
408+
public static bool InternalTickRemote_Prefix(ref StationComponent __instance, PlanetFactory factory, int timeGene, float shipSailSpeed, float shipWarpSpeed, int shipCarries, StationComponent[] gStationPool, AstroData[] astroPoses, ref VectorLF3 relativePos, ref Quaternion relativeRot, bool starmap, int[] consumeRegister)
409+
{
410+
if (Configs.configEnableVessels)
411+
{
412+
SpeedUpShip(ref __instance);
413+
}
414+
else
415+
{
416+
TeleportShip(ref __instance, factory, timeGene, shipSailSpeed, shipWarpSpeed, shipCarries, gStationPool, astroPoses, ref relativePos, ref relativeRot, starmap, consumeRegister);
417+
}
418+
return true;
419+
}
351420
}
352421
}

InstantDelivery/README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Mod for Dyson Sphere Program. BepInEx required.
44

5-
Instantly delivery items from `Remote Supply` interstellar stations to `Remote Demand` interstellar stations.
5+
Instantly deliver items from `Remote Supply` interstellar stations to `Remote Demand` interstellar stations.
66

77
Basically the stations work as usual (find matching pairs, find an available vessel, decide the amount to be sent), however now the cargo is delivered instantly. You can think of it as equipping vessel with infinite speed. Note it still consumes power and warpers, and requires at least one vessel to deliver, so it won't deliver cargos unless the related research has been unlocked, and the power/warper/vessel condition is satisfied. The station is also constrolled by options like Min Load of Vessels, and Transport Range of Vessels. Just as in the unmodded game.
88

@@ -16,21 +16,18 @@ Put `InstantDelivery.dll` into `...\Dyson Sphere Program\BepInEx\plugins`.
1616

1717
## Configurations
1818

19-
There is an option `EnableVessels` to control whether the game continues to send out vessels besides the functionality provided by `InstantDelivery`, and the option also controls whether the game continues to calculate paths for those vessels that have already departed.
19+
There is an option `EnableVessels` to decide whether to allow sending out vessels as in the original game. Keep this option enabled (true) to ensure compatibility with an existing game save (when vessels are already in operation). You can set the option to `false` when starting a new run, to achieve a slight performance boost
2020

2121
You can find this option after running the game once with the mod installed, and check `...\Dyson Sphere Program\BepInEx\config\lxb007981.dsp.InstantDelivery.cfg`.
2222

23-
If you are using this mod in a new run with no exsiting vessels, you can set the option to `false`. Otherwise if the mod is used on an exsiting save, it might be better to leave the option `true` (with a little bit performance decrease). Since setting it to `false` will freeze all vessels that have departed, and they will never reach their destinations. Or you could manually take out all the vessels from all of the stations and then set the option to `false`.
24-
25-
2623
------------------------------------------------------------------------
2724
# 立刻送达
2825

2926
需要BepInEx.
3027

3128
瞬间将货物从`星际供应`物流站传送到`星际需求`站。
3229

33-
Mod不会改变星际物流站的工作方式。星际物流站仍需要至少一艘运输船,并会消耗电力和翘曲器,而且受到运输船起送量、最远运送距离等选项控制。你可以将此Mod理解为将运输船的速度变为无限大
30+
Mod不会改变星际物流站的工作方式。星际物流站仍需要至少一艘运输船,并会消耗电力和翘曲器,而且受到运输船起送量、最远运送距离等选项控制。可以将此Mod理解为将运输船的速度变为无限大
3431

3532
- **与上版本不同!** 需要至少一艘运输船
3633
- 支持轨道采集器
@@ -42,17 +39,21 @@ Mod不会改变星际物流站的工作方式。星际物流站仍需要至少
4239

4340
## 配置
4441

45-
`EnableVessels`选项用于控制物流站是否仍如未安装Mod时一样发送运输船。将此选项置为`false`会同时冻结已经出发的运输船(因为有关发送运输船、校正轨道的代码不再被运行)
42+
`EnableVessels`选项用于控制物流站是否仍如未安装Mod时一样发送运输船。需要启用此设置才能兼容(已经有运输船在运行的)旧存档
4643

4744
在安装Mod并运行一次游戏后,在`...\Dyson Sphere Program\BepInEx\config\lxb007981.dsp.InstantDelivery.cfg`找到配置文件。
4845

4946
如果此Mod被用在新存档(没有运输船),可以将选项置否(获得一点性能提升)。
5047

51-
如果此Mod被用在已有运输船运行的旧存档,建议不改动默认选项(true)。
52-
你也可以手动取走所有物流站里的运输船后再改动选项。
48+
如果此Mod被用在已有运输船运行的旧存档,则不应改动默认选项(true)。
5349

5450
## Release Notes
5551

52+
### v1.1.0
53+
54+
- Now compatiable with existing game saves with working vessels. Requires the `EnableVessels` option to be set to `true`.
55+
- 现在可以兼容旧存档。需要打开`EnableVessels`选项。
56+
5657
### v1.0.0
5758

5859
- update to game lib ver 0.10.30.22292-r.0

InstantDelivery/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "InstantDelivery",
33
"description": "Instantly delivery items from Remote Supply interstellar stations to Remote Demand interstellar stations./ 将货物从星际供应站瞬间传送到星际需求站",
4-
"version_number": "0.1.0",
4+
"version_number": "1.1.0",
55
"dependencies": [],
66
"website_url": "https://github.com/lxb007981/DSP_Mod/tree/master/InstantDelivery"
77
}

0 commit comments

Comments
 (0)