Skip to content

Commit

Permalink
Consistently use properties in CC parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
siimav committed Dec 10, 2023
1 parent df4b2f5 commit 055c0f7
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 31 deletions.
9 changes: 4 additions & 5 deletions Source/CC_RP0/Parameter/AvionicsCheckVesselParam.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using ContractConfigurator.Parameters;
using Contracts;

namespace ContractConfigurator.RP0
{
public class AvionicsCheckParameter : VesselParameter
{
protected bool parameterIsSatisified = true;
protected bool controlHasLapsed = false;
protected bool continuousControlRequired = false;
protected bool parameterIsSatisified { get; set; } = true;
protected bool controlHasLapsed { get; set; }
protected bool continuousControlRequired { get; set; }

public AvionicsCheckParameter() : base(null) { }

Expand All @@ -30,7 +29,7 @@ protected override void OnParameterLoad(ConfigNode node)
base.OnParameterLoad(node);

// Save parameter options on a per-vessel basis
node.TryGetValue("continuousControlRequired", ref continuousControlRequired);
continuousControlRequired = ConfigNodeUtil.ParseValue<bool>(node, "continuousControlRequired");
}
protected override void OnRegister()
{
Expand Down
17 changes: 9 additions & 8 deletions Source/CC_RP0/Parameter/DownrangeDistanceVesselParam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ public class DownrangeDistance : VesselParameter
{
protected static Dictionary<string, DownrangeDistance> CompletedParams;

protected bool triggered = false;
protected double distance = 0;
protected double curDist = 0;
protected double markLatitude, markLongitude;
protected bool triggered { get; set; }
protected double distance { get; set; }
protected double curDist { get; set; }
protected double markLatitude { get; set; }
protected double markLongitude { get; set; }
protected float updateFrequency { get; set; }

private float lastUpdate = 0.0f;
Expand Down Expand Up @@ -46,10 +47,10 @@ protected override void OnParameterLoad(ConfigNode node)
base.OnParameterLoad(node);

updateFrequency = ConfigNodeUtil.ParseValue<float>(node, "updateFrequency", DEFAULT_UPDATE_FREQUENCY);
node.TryGetValue("distance", ref distance);
node.TryGetValue("markLatitude", ref markLatitude);
node.TryGetValue("markLongitude", ref markLongitude);
node.TryGetValue("triggered", ref triggered);
distance = ConfigNodeUtil.ParseValue<double>(node, "distance");
markLatitude = ConfigNodeUtil.ParseValue<double>(node, "markLatitude");
markLongitude = ConfigNodeUtil.ParseValue<double>(node, "markLongitude");
triggered = ConfigNodeUtil.ParseValue<bool>(node, "triggered");
}

protected override string GetParameterTitle()
Expand Down
4 changes: 2 additions & 2 deletions Source/CC_RP0/Parameter/HasCompleted.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace ContractConfigurator.RP0
public class HasCompleted : VesselParameter
{
protected List<string> ContractTags { get; set; }
protected bool InvertParameter = false;
protected bool InvertParameter { get; set; }

public HasCompleted()
: base(null)
Expand Down Expand Up @@ -48,7 +48,7 @@ protected override void OnParameterLoad(ConfigNode node)
{
base.OnParameterLoad(node);
ContractTags = ConfigNodeUtil.ParseValue<List<string>>(node, "contractTag", new List<string>());
InvertParameter = Convert.ToBoolean(node.GetValue("invertParameter"));
InvertParameter = ConfigNodeUtil.ParseValue<bool>(node, "invertParameter");
}

protected override void OnRegister()
Expand Down
8 changes: 4 additions & 4 deletions Source/CC_RP0/Parameter/HorizontalLandingVesselParam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace ContractConfigurator.RP0
{
public class HorizontalLanding : VesselParameter
{
protected double glideRatio;
protected bool wasPreviouslyMet = false;
protected double glideRatio { get; set; }
protected bool wasPreviouslyMet { get; set; }
protected float updateFrequency { get; set; }

private float lastUpdate = 0.0f;
Expand Down Expand Up @@ -39,8 +39,8 @@ protected override void OnParameterLoad(ConfigNode node)
base.OnParameterLoad(node);

updateFrequency = ConfigNodeUtil.ParseValue<float>(node, "updateFrequency", DEFAULT_UPDATE_FREQUENCY);
node.TryGetValue("glideRatio", ref glideRatio);
node.TryGetValue("wasPreviouslyMet", ref wasPreviouslyMet);
glideRatio = ConfigNodeUtil.ParseValue<double>(node, "glideRatio");
wasPreviouslyMet = ConfigNodeUtil.ParseValue<bool>(node, "wasPreviouslyMet");
}

protected override bool VesselMeetsCondition(Vessel vessel)
Expand Down
4 changes: 2 additions & 2 deletions Source/CC_RP0/Parameter/ImpactCBParam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class ImpactCB : VesselParameter
{
private const int VelQueueSize = 50;

protected double minSrfVel = 0;
protected double minSrfVel { get; set; }

private Queue<double> srfVelQueue = new Queue<double>(VelQueueSize);
private Dictionary<Vessel, bool> destroyedVessels = new Dictionary<Vessel, bool>();
Expand Down Expand Up @@ -47,7 +47,7 @@ protected override void OnParameterLoad(ConfigNode node)
{
base.OnParameterLoad(node);

node.TryGetValue("minSrfVel", ref minSrfVel);
minSrfVel = ConfigNodeUtil.ParseNode<double>(node, "minSrfVel");
targetBody = ConfigNodeUtil.ParseValue<CelestialBody>(node, "targetBody", null);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/CC_RP0/Parameter/RP1NoDocking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace ContractConfigurator.RP0
/// </summary>
public class RP1NoDocking : VesselParameter
{
protected HashSet<string> dockedVesselIDs = new HashSet<string>();
protected HashSet<string> dockedVesselIDs { get; set; } = new HashSet<string>();
protected List<string> vessels { get; set; }

public RP1NoDocking()
Expand Down
10 changes: 5 additions & 5 deletions Source/CC_RP0/Parameter/RP1ReturnHome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ namespace ContractConfigurator.RP0
public class RP1ReturnHome : VesselParameter
{
public const double DefaultMaxSpeed = 5;
internal const float DEFAULT_UPDATE_FREQUENCY = 0.5f;

protected string landAtFacility = string.Empty;
protected double maxSpeed = DefaultMaxSpeed;
protected string landAtFacility { get; set; }
protected double maxSpeed { get; set; }
protected float updateFrequency { get; set; }

private float lastUpdate = 0.0f;
internal const float DEFAULT_UPDATE_FREQUENCY = 0.5f;

public RP1ReturnHome()
: this(null, string.Empty, DefaultMaxSpeed, DEFAULT_UPDATE_FREQUENCY)
Expand Down Expand Up @@ -49,8 +49,8 @@ protected override void OnParameterLoad(ConfigNode node)
base.OnParameterLoad(node);

updateFrequency = ConfigNodeUtil.ParseValue<float>(node, "updateFrequency", DEFAULT_UPDATE_FREQUENCY);
node.TryGetValue("landAtFacility", ref landAtFacility);
node.TryGetValue("maxSpeed", ref maxSpeed);
landAtFacility = ConfigNodeUtil.ParseValue<string>(node, "landAtFacility", string.Empty);
maxSpeed = ConfigNodeUtil.ParseValue<double>(node, "maxSpeed", DefaultMaxSpeed);
}

protected override void OnUpdate()
Expand Down
5 changes: 2 additions & 3 deletions Source/CC_RP0/Parameter/ReachMachVesselParam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace ContractConfigurator.RP0
{
public class ReachMach : VesselParameter
{
protected double mach;
protected double mach { get; set; }
protected float updateFrequency { get; set; }

private float lastUpdate = 0.0f;
Expand All @@ -25,7 +25,6 @@ protected override void OnParameterSave(ConfigNode node)
{
base.OnParameterSave(node);

node.AddValue("updateFrequency", updateFrequency);
node.AddValue("updateFrequency", updateFrequency);
node.AddValue("mach", mach);
}
Expand All @@ -35,7 +34,7 @@ protected override void OnParameterLoad(ConfigNode node)
base.OnParameterLoad(node);

updateFrequency = ConfigNodeUtil.ParseValue<float>(node, "updateFrequency", DEFAULT_UPDATE_FREQUENCY);
node.TryGetValue("mach", ref mach);
mach = ConfigNodeUtil.ParseValue<double>(node, "mach");
}

protected override string GetParameterTitle()
Expand Down
2 changes: 1 addition & 1 deletion Source/CC_RP0/Parameter/VesselBuiltAt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace ContractConfigurator.RP0
{
public class VesselBuiltAtParameter : VesselParameter
{
private EditorFacility builtAt;
private EditorFacility builtAt { get; set; }

public VesselBuiltAtParameter()
: base(null)
Expand Down

0 comments on commit 055c0f7

Please sign in to comment.