diff --git a/OCBatchBuild/OCBatchBuild.csproj b/OCBatchBuild/OCBatchBuild.csproj
index be9956b..96b7e89 100644
--- a/OCBatchBuild/OCBatchBuild.csproj
+++ b/OCBatchBuild/OCBatchBuild.csproj
@@ -5,7 +5,7 @@
OCBatchBuild
org.soardev.ocbatchbuild
DSP MOD - OCBatchBuild
- 1.1.0
+ 1.2.0
true
latest
diff --git a/OCBatchBuild/OrbitalCollectorBatchBuild.cs b/OCBatchBuild/OrbitalCollectorBatchBuild.cs
index 03684c4..ba6df66 100644
--- a/OCBatchBuild/OrbitalCollectorBatchBuild.cs
+++ b/OCBatchBuild/OrbitalCollectorBatchBuild.cs
@@ -20,10 +20,7 @@ public class OrbitalCollectorBatchBuild : BaseUnityPlugin
private void Awake()
{
_cfgEnabled = Config.Bind("General", "Enabled", _cfgEnabled, "enable/disable this plugin").Value;
- _maxBuildCount = Config.Bind("General", "MaxBuildCount", _maxBuildCount,
- new ConfigDescription("Maximum Orbital Collectors to build once, set to 0 to build as many as possible",
- new AcceptableValueRange(0, 40), new {}))
- .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));
}
@@ -48,14 +45,28 @@ public class OrbitalCollectorBatchBuild : BaseUnityPlugin
var pos2 = buildPreview.lpos2;
var itemId = buildPreview.item.ID;
var countToBuild = _maxBuildCount - 1;
+ if (countToBuild == 0) return;
var prebuilds = new List {-buildPreview.objId};
var player = __instance.player;
- for (var i = 0; i < 39 && countToBuild != 0; i++)
+ 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++)
{
- /* rotate for 1/40 on sphere */
- pos = Maths.RotateLF(0.0, 1.0, 0.0, Math.PI / 40.0, pos);
- pos2 = Maths.RotateLF(0.0, 1.0, 0.0, Math.PI / 40.0, pos2);
+ 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++)
@@ -65,7 +76,14 @@ public class OrbitalCollectorBatchBuild : BaseUnityPlugin
collide = true;
break;
}
- if (collide) continue;
+ 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)
{
@@ -98,6 +116,10 @@ public class OrbitalCollectorBatchBuild : BaseUnityPlugin
}
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;
diff --git a/OCBatchBuild/README.md b/OCBatchBuild/README.md
index 2d8e89e..f04d278 100644
--- a/OCBatchBuild/README.md
+++ b/OCBatchBuild/README.md
@@ -4,6 +4,10 @@
#### 轨道采集器快速批量建造
## 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
diff --git a/OCBatchBuild/package/manifest.json b/OCBatchBuild/package/manifest.json
index 9265396..ec35549 100644
--- a/OCBatchBuild/package/manifest.json
+++ b/OCBatchBuild/package/manifest.json
@@ -1,6 +1,6 @@
{
"name": "OrbitalCollectorBatchBuild",
- "version_number": "1.1.0",
+ "version_number": "1.2.0",
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/OCBatchBuild",
"description": "Batch build Orbital Collectors / 轨道采集器快速批量建造",
"dependencies": [