Skip to content

Commit 9a20f76

Browse files
authored
1.8 / 1.9
1.8 / 1.9
2 parents 9592591 + 21f4e18 commit 9a20f76

File tree

12 files changed

+92
-85
lines changed

12 files changed

+92
-85
lines changed

Changelog.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
**v1.7.3**
2+
3+
- Updated to KSP 1.8.1 and Kopernicus 1.8.1-1
4+
- Fixed PeriodFixer
5+
6+
17
**v1.7.2**
28

39
- Recompiled against KSP 1.7.1 and Kopernicus 1.7.1-4
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Sigma88LoadingScreens
2+
{
3+
folder = Sigma/Binary/LoadingScreens/PluginData/
4+
tipsFile = Sigma/Binary/LoadingScreens/LoadingTips.txt
5+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Re-centering Barycenters...
-1 KB
Binary file not shown.

License.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,3 @@ All Rights Reserved
66

77
For more info visit the GitHub Repository:
88
https://github.com/Sigma88/Sigma-Binary
9-
10-
11-
12-
Includes the Sigma88LoadingScreens plugin.
13-
License: All Rights Reserved
14-
Source: https://github.com/Sigma88/Sigma-LoadingScreens

README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,40 @@
11
# Sigma Binary
22

3+
34
**This KSP mod will help you create binary systems.**
45

56

6-
Latest Release: https://github.com/Sigma88/Sigma-Binary/releases/latest
7+
- [Releases](https://github.com/Sigma88/Sigma-Binary/releases)
8+
- [ChangeLog](https://raw.githubusercontent.com/Sigma88/Sigma-Binary/master/Changelog.txt)
9+
10+
11+
### Required Mods
12+
13+
- [Kopernicus](https://github.com/Kopernicus/Kopernicus)
14+
15+
16+
### How to support me
17+
18+
If you enjoy my mods, please consider supporting me with a small donation.
19+
20+
[![DonatePounds](https://i.imgur.com/xBBQy19.png "Donate Pounds")](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=65VBNHB39BTKG&item_name=Sigma-Binary&currency_code=GBP)[![DonateEuros](https://i.imgur.com/kKYb2lE.png "Donate Euros")](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=65VBNHB39BTKG&item_name=Sigma-Binary&currency_code=EUR)[![DonateDollars](https://i.imgur.com/TT1Vymu.png "Donate Dollars")](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=65VBNHB39BTKG&item_name=Sigma-Binary&currency_code=USD)
21+
22+
23+
### How To Report A Bug
24+
25+
To report a bug or to ask for support, open an issue on [GitHub](https://github.com/Sigma88/Sigma-Binary/issues).
26+
27+
28+
### How To Install
29+
30+
To install the mod, follow these instructions:
31+
32+
```
33+
>> Install Manually
34+
  - Remove any other version of the mod.
35+
  - Unzip the archive directly into the folder 'KSP\GameData'
36+
- Install any required mods
737
8-
Dev version: https://github.com/Sigma88/Sigma-Binary/tree/Development
38+
>> Uninstall manually
39+
  - Delete the folder 'KSP\GameData\Sigma\Binary'
40+
```
-1 KB
Binary file not shown.

[Source]/SigmaBinary/Extensions.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
namespace SigmaBinaryPlugin
1+
using System;
2+
using Kopernicus;
3+
using Kopernicus.Configuration;
4+
5+
6+
namespace SigmaBinaryPlugin
27
{
38
internal static class Extensions
49
{
@@ -12,5 +17,25 @@ internal static double GetMass(this CelestialBody cb)
1217

1318
return 0;
1419
}
20+
21+
internal static double GetOrbitalPeriod(this Body body, CelestialBody referenceBody)
22+
{
23+
if (body?.GeneratedBody?.orbitDriver?.orbit?.semiMajorAxis != null && referenceBody != null)
24+
{
25+
body.GeneratedBody.celestialBody.Set("customOrbitalPeriod", 2 * Math.PI * Math.Sqrt(Math.Pow(body.GeneratedBody.orbitDriver.orbit.semiMajorAxis, 3) / 6.67408E-11 / referenceBody.GetMass()));
26+
}
27+
28+
return body.GetOrbitalPeriod();
29+
}
30+
31+
internal static double GetOrbitalPeriod(this Body body)
32+
{
33+
if (body?.GeneratedBody?.celestialBody?.Has("customOrbitalPeriod") == true)
34+
{
35+
return body.GeneratedBody.celestialBody.Get<double>("customOrbitalPeriod");
36+
}
37+
38+
return 0;
39+
}
1540
}
1641
}

[Source]/SigmaBinary/PeriodFixer.cs

Lines changed: 0 additions & 43 deletions
This file was deleted.

[Source]/SigmaBinary/SigmaBinary.cs

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -155,20 +155,12 @@ void ProcessBinaries(Loader ldr, ConfigNode cfgn)
155155
cbBarycenter.GeeASL = (cbPrimary.GetMass() + cbSecondary.GetMass()) / 1e5 * 6.674e-11d / Math.Pow(cbBarycenter.Radius, 2) / 9.80665d;
156156
cbBarycenter.rotationPeriod = 0;
157157
Debug.Log("SigmaBinary.SetBarycenter", "Printing orbital parameters of primary " + sbPrimary.GeneratedBody.name + " for reference.");
158-
Debug.Log("SigmaBinary.SetBarycenter", "referenceBody = " + sbPrimary.Orbit.ReferenceBody + ", semiMajorAxis = " + sbPrimary.GeneratedBody.orbitDriver.orbit.semiMajorAxis);
158+
Debug.Log("SigmaBinary.SetBarycenter", "referenceBody = " + sbPrimary.Orbit.ReferenceBody + ", semiMajorAxis = " + sbPrimary.GeneratedBody.orbitDriver.orbit.semiMajorAxis + ", period = " + sbPrimary.GetOrbitalPeriod(cbReference));
159159
Debug.Log("SigmaBinary.SetBarycenter", "Calculated new orbital parameters for barycenter " + sbBarycenter.GeneratedBody.name);
160160
Debug.Log("SigmaBinary.SetBarycenter", "referenceBody = " + sbBarycenter.Orbit.ReferenceBody + ", semiMajorAxis = " + sbBarycenter.GeneratedBody.orbitDriver.orbit.semiMajorAxis);
161161

162-
if (periodFixerList.ContainsKey(sbPrimary.GeneratedBody.name))
163-
{
164-
periodFixerList.Add(sbBarycenter.GeneratedBody.name, periodFixerList[sbPrimary.GeneratedBody.name]);
165-
Debug.Log("SigmaBinary.SetBarycenter", "Added barycenter " + sbBarycenter.GeneratedBody.name + " to 'periodFixerList', used primary orbital period = " + periodFixerList[sbBarycenter.GeneratedBody.name]);
166-
}
167-
else
168-
{
169-
periodFixerList.Add(sbBarycenter.GeneratedBody.name, 2 * Math.PI * Math.Sqrt(Math.Pow(sbPrimary.GeneratedBody.orbitDriver.orbit.semiMajorAxis, 3) / 6.67408E-11 / cbReference.GetMass()));
170-
Debug.Log("SigmaBinary.SetBarycenter", "Added barycenter " + sbBarycenter.GeneratedBody.name + " to 'periodFixerList', calculated orbital period = " + periodFixerList[sbBarycenter.GeneratedBody.name]);
171-
}
162+
sbBarycenter.GeneratedBody.celestialBody.Set("customOrbitalPeriod", sbPrimary.GetOrbitalPeriod(cbReference));
163+
Debug.Log("SigmaBinary.SetBarycenter", "Changed orbital period of barycenter " + sbBarycenter?.GeneratedBody?.name + ", new orbital period = " + sbBarycenter.GetOrbitalPeriod());
172164

173165
// Orbit Color
174166
if (sigmabinaryOrbitColor.ContainsKey(sbSecondary))
@@ -265,25 +257,20 @@ void ProcessBinaries(Loader ldr, ConfigNode cfgn)
265257
Debug.Log("SigmaBinary.SetPrimary", "Calculated new orbital parameters for primary " + sbPrimary.GeneratedBody.name);
266258
Debug.Log("SigmaBinary.SetPrimary", "referenceBody = " + sbPrimary.Orbit.ReferenceBody + ", semiMajorAxis = " + sbPrimary.GeneratedBody.orbitDriver.orbit.semiMajorAxis + ", ratio = " + (sbSecondary.GeneratedBody.orbitDriver.orbit.semiMajorAxis / sbPrimary.GeneratedBody.orbitDriver.orbit.semiMajorAxis));
267259

268-
if (periodFixerList.ContainsKey(sbPrimary.GeneratedBody.name))
269-
{
270-
periodFixerList.Remove(sbPrimary.GeneratedBody.name);
271-
Debug.Log("SigmaBinary.SetPrimary", "Primary " + sbPrimary.GeneratedBody.name + " removed from 'periodFixerList'.");
272-
}
273-
periodFixerList.Add(sbPrimary.GeneratedBody.name, 2 * Math.PI * Math.Sqrt(Math.Pow(sbSecondary.GeneratedBody.orbitDriver.orbit.semiMajorAxis, 3) / 6.67408E-11 / cbPrimary.GetMass()));
274-
Debug.Log("SigmaBinary.SetPrimary", "Primary " + sbPrimary.GeneratedBody.name + " added to 'periodFixerList'. calculated orbital period = " + periodFixerList[sbPrimary.GeneratedBody.name]);
260+
sbPrimary.GeneratedBody.celestialBody.Set("customOrbitalPeriod", sbSecondary.GetOrbitalPeriod(cbPrimary));
261+
Debug.Log("SigmaBinary.SetPrimary", "New Orbital Period for Primary " + sbPrimary.GeneratedBody.name + " = " + sbPrimary.GetOrbitalPeriod());
275262

276263
// Primary Locked
277264
if (cbPrimary.solarRotationPeriod)
278265
{
279266
cbPrimary.solarRotationPeriod = false;
280-
cbPrimary.rotationPeriod = (periodFixerList[sbBarycenter.GeneratedBody.name] * cbPrimary.rotationPeriod) / (periodFixerList[sbBarycenter.GeneratedBody.name] + cbPrimary.rotationPeriod);
267+
cbPrimary.rotationPeriod = (sbBarycenter.GetOrbitalPeriod() * cbPrimary.rotationPeriod) / (sbBarycenter.GetOrbitalPeriod() + cbPrimary.rotationPeriod);
281268
Debug.Log("SigmaBinary.SetPrimary", "Primary " + sbPrimary.GeneratedBody.name + " 'solarRotationPeriod' set to 'false'. recalculated rotation period = " + cbPrimary.rotationPeriod);
282269
}
283270
if (sigmabinaryPrimaryLocked.Contains(sbSecondary))
284271
{
285272
cbPrimary.solarRotationPeriod = false;
286-
cbPrimary.rotationPeriod = periodFixerList[sbPrimary.GeneratedBody.name];
273+
cbPrimary.rotationPeriod = sbPrimary.GetOrbitalPeriod();
287274
Debug.Log("SigmaBinary.SetPrimary", "Primary " + sbPrimary.GeneratedBody.name + " is locked to reference " + sbReference.GeneratedBody.name + ".");
288275
Debug.Log("SigmaBinary.SetPrimary", "Primary " + sbPrimary.GeneratedBody.name + " 'solarRotationPeriod' set to 'false'. recalculated rotation period = " + cbPrimary.rotationPeriod);
289276
}
@@ -324,8 +311,8 @@ void ProcessBinaries(Loader ldr, ConfigNode cfgn)
324311
sbOrbit.GeneratedBody.orbitRenderer.orbitColor = sbSecondary.GeneratedBody.orbitRenderer.orbitColor;
325312
Debug.Log("SigmaBinary.SetMarker", "Orbit marker " + sbOrbit.GeneratedBody.name + " orbit line color set from secondary " + sbSecondary.GeneratedBody.name + ". color = " + sbOrbit.GeneratedBody.orbitRenderer.orbitColor);
326313

327-
periodFixerList.Add(sbOrbit.GeneratedBody.name, 2 * Math.PI * Math.Sqrt(Math.Pow(sbSecondary.GeneratedBody.orbitDriver.orbit.semiMajorAxis, 3) / 6.67408E-11 / cbPrimary.GetMass()));
328-
Debug.Log("SigmaBinary.SetMarker", "Orbit marker " + sbOrbit.GeneratedBody.name + " added to 'periodFixerList'. calculated orbital period = " + periodFixerList[sbOrbit.GeneratedBody.name]);
314+
sbOrbit.GeneratedBody.celestialBody.Set("customOrbitalPeriod", sbSecondary.GetOrbitalPeriod(cbPrimary));
315+
Debug.Log("SigmaBinary.SetMarker", "Orbit marker " + sbOrbit.GeneratedBody.name + " orbital period = " + sbOrbit.GetOrbitalPeriod());
329316

330317
cbSecondary.Set("drawMode", DrawMode.OFF);
331318
Debug.Log("SigmaBinary.SetMarker", "Secondary " + sbSecondary.GeneratedBody.name + " orbit 'drawMode' automatically set. drawMode = " + DrawMode.OFF);
@@ -409,32 +396,32 @@ string nameof(Body body)
409396
/// </summary>
410397
Body OrbitPatcher(Body body)
411398
{
412-
Debug.Log("SigmaBinary.OrbitPatcher", "");
399+
Debug.Log("SigmaBinary.OrbitPatcher", "celestialBody = " + body?.GeneratedBody?.celestialBody);
413400
if (body?.GeneratedBody?.celestialBody?.Has("sbPatched") == false)
414401
{
415-
if (body.GeneratedBody?.orbitDriver?.orbit == null)
402+
if (body?.GeneratedBody?.orbitDriver?.orbit == null)
416403
{
417404
Debug.Log("OrbitPatcher", "Body " + body.GeneratedBody.name + " does not have an orbit.");
418405
return null;
419406
}
420407

421408
// This 'if' is here to make sure stars don't give us trouble
422-
if (body.GeneratedBody?.orbitDriver?.orbit?.referenceBody == null)
409+
if (body?.GeneratedBody?.orbitDriver?.orbit?.referenceBody == null)
423410
{
424411
body.GeneratedBody.orbitDriver.orbit.referenceBody = ListOfBodies.Find(rb => rb.GeneratedBody.name == body.Orbit.ReferenceBody).GeneratedBody.celestialBody;
425412
Debug.Log("SigmaBinary.OrbitPatcher", "Body " + body.GeneratedBody.name + " 'referenceBody' set to " + body.GeneratedBody.orbitDriver.orbit.referenceBody);
426413
}
427414

428415
// If the body has a Kerbin Template, save the original referenceBody for later
429-
if (body.Template.OriginalBody.celestialBody.name == "Kerbin")
416+
if (body?.Template?.OriginalBody?.celestialBody?.name == "Kerbin")
430417
{
431418
Debug.Log("SigmaBinary.OrbitPatcher", "Body " + body.GeneratedBody.name + " uses Kerbin as Template.");
432419

433420
kerbinFixer.Add(body.GeneratedBody.name, body.Orbit.ReferenceBody);
434421
Debug.Log("SigmaBinary.OrbitPatcher", "Store original 'referenceBody' " + body.Orbit.ReferenceBody + " of body " + body.GeneratedBody.name + " in 'kerbinFixer'.");
435422
}
436423

437-
if (body.GeneratedBody.Has("orbitPatches"))
424+
if (body?.GeneratedBody?.Has("orbitPatches") == true)
438425
{
439426
ConfigNode patch = body.GeneratedBody.Get<ConfigNode>("orbitPatches");
440427
Debug.Log("SigmaBinary.OrbitPatcher", "Body " + body.GeneratedBody.name + " has a 'PostSpawnOrbit' node.");

0 commit comments

Comments
 (0)