Skip to content

Commit

Permalink
Add contractWeight option
Browse files Browse the repository at this point in the history
If this does what it looks like, planet makers can kill contracts for their bodies with it.
  • Loading branch information
Dorian Stoll committed Aug 27, 2017
1 parent 57d252d commit 640b777
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Kopernicus/Kopernicus/Configuration/Body.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class Body : IParserEventSubscriber
public string cacheFile { get; set; }

[ParserTarget("barycenter")]
public NumericParser<bool> barycenter = new NumericParser<bool>(false);
public NumericParser<bool> barycenter = false;

[ParserTarget("cbNameLater")]
public string cbNameLater
Expand Down Expand Up @@ -103,6 +103,14 @@ public NumericParser<bool> canBeMainMenuBody
set { if (value) Loader.Instance.randomMainMenuBodies.Add(name); }
}

// Describes how often contracts should be generated for a body
[ParserTarget("contractWeight")]
public NumericParser<int> contractWeight
{
get { return generatedBody.Has("contractWeight") ? generatedBody.Get<int>("contractWeight") : 30; }
set { generatedBody.Set("contractWeight", value); }
}

// Template property of a body - responsible for generating a PSystemBody from an existing one
[PreApply]
[ParserTarget("Template")]
Expand Down
17 changes: 17 additions & 0 deletions Kopernicus/Kopernicus/RuntimeUtility/RuntimeUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
using KSP.UI.Screens.Mapview;
using KSP.UI.Screens.Mapview.MapContextMenuOptions;
using ModularFI;
using Contracts;

namespace Kopernicus
{
Expand Down Expand Up @@ -82,6 +83,22 @@ void Awake ()
body.scaledBody.GetComponent<MaterialSetDirection>().target = star_.transform;
foreach (PQSMod_MaterialSetDirection msd in body.GetComponentsInChildren<PQSMod_MaterialSetDirection>(true))
msd.target = star_.transform;

// Contract Weight
if (ContractSystem.ContractWeights != null)
{
if (body.Has("contractWeight"))
{
if (ContractSystem.ContractWeights.ContainsKey(body.name))
{
ContractSystem.ContractWeights[body.name] = body.Get<int>("contractWeight");
}
else
{
ContractSystem.ContractWeights.Add(body.name, body.Get<int>("contractWeight"));
}
}
}
}
foreach (TimeOfDayAnimation anim in Resources.FindObjectsOfTypeAll<TimeOfDayAnimation>())
anim.target = KopernicusStar.GetNearest(FlightGlobals.GetHomeBody()).gameObject.transform;
Expand Down

0 comments on commit 640b777

Please sign in to comment.