-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6af0734
commit bf05851
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters