Skip to content

Commit

Permalink
New Condition: GeeForce
Browse files Browse the repository at this point in the history
  • Loading branch information
jwvanderbeck committed Mar 28, 2015
1 parent 6af0734 commit bf05851
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
Binary file modified GameData/RealScience/Plugins/RealScience.dll
Binary file not shown.
81 changes: 81 additions & 0 deletions source/Conditions/RealScienceCondition_GeeForce.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
using System;

using UnityEngine;

namespace RealScience.Conditions
{
class RealScienceCondition_GeeForce : RealScienceCondition
{
// common properties
public string conditionType = "GeeForce";
public bool restriction = false;
public string exclusion = "";
public float dataRateModifier = 1f;
// specific properties
public float gMin = 0f;
public float gMax = float.MaxValue;

public override float DataRateModifier
{
get { return dataRateModifier; }
}
public override bool IsRestriction
{
get { return restriction; }
}
public override string Exclusion
{
get { return exclusion; }
}

public override bool Evaluate(Part part, float deltaTime)
{
return FlightGlobals.ship_geeForce >= gMin && FlightGlobals.ship_geeForce <= gMax;
}
public override void Load(ConfigNode node)
{
// Load common properties
if (node.HasValue("conditionType"))
conditionType = node.GetValue("conditionType");
if (node.HasValue("exclusion"))
exclusion = node.GetValue("exclusion");
if (node.HasValue("restriction"))
{
try
{
restriction = bool.Parse(node.GetValue("restriction"));
}
catch (FormatException)
{
restriction = false;
}
}
if (node.HasValue("dataRateModifier"))
{
try
{
dataRateModifier = float.Parse(node.GetValue("dataRateModifier"));
}
catch (FormatException)
{
dataRateModifier = 1f;
}
}
// Load specific properties
if (node.HasValue("gMin"))
gMin = float.Parse(node.GetValue("gMin"));
if (node.HasValue("gMax"))
gMax = float.Parse(node.GetValue("gMax"));
}
public override void Save(ConfigNode node)
{
// Save common properties
node.AddValue("conditionType", conditionType);
node.AddValue("restriction", restriction);
node.AddValue("exclusion", exclusion);
node.AddValue("dataRateModifier", dataRateModifier);
node.AddValue("gMin", gMin);
node.AddValue("gMax", gMax);
}
}
}
1 change: 1 addition & 0 deletions source/RealScience.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<Compile Include="Conditions\RealScienceCondition_Altitude.cs" />
<Compile Include="Conditions\RealScienceCondition_Biome.cs" />
<Compile Include="Conditions\RealScienceCondition_Body.cs" />
<Compile Include="Conditions\RealScienceCondition_GeeForce.cs" />
<Compile Include="Conditions\RealScienceCondition_Orbit.cs" />
<Compile Include="Conditions\RealScienceCondition_Part.cs" />
<Compile Include="Conditions\RealScienceCondition_Resource.cs" />
Expand Down

0 comments on commit bf05851

Please sign in to comment.