Skip to content

Commit bf05851

Browse files
committed
New Condition: GeeForce
1 parent 6af0734 commit bf05851

3 files changed

Lines changed: 82 additions & 0 deletions

File tree

1 KB
Binary file not shown.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
using System;
2+
3+
using UnityEngine;
4+
5+
namespace RealScience.Conditions
6+
{
7+
class RealScienceCondition_GeeForce : RealScienceCondition
8+
{
9+
// common properties
10+
public string conditionType = "GeeForce";
11+
public bool restriction = false;
12+
public string exclusion = "";
13+
public float dataRateModifier = 1f;
14+
// specific properties
15+
public float gMin = 0f;
16+
public float gMax = float.MaxValue;
17+
18+
public override float DataRateModifier
19+
{
20+
get { return dataRateModifier; }
21+
}
22+
public override bool IsRestriction
23+
{
24+
get { return restriction; }
25+
}
26+
public override string Exclusion
27+
{
28+
get { return exclusion; }
29+
}
30+
31+
public override bool Evaluate(Part part, float deltaTime)
32+
{
33+
return FlightGlobals.ship_geeForce >= gMin && FlightGlobals.ship_geeForce <= gMax;
34+
}
35+
public override void Load(ConfigNode node)
36+
{
37+
// Load common properties
38+
if (node.HasValue("conditionType"))
39+
conditionType = node.GetValue("conditionType");
40+
if (node.HasValue("exclusion"))
41+
exclusion = node.GetValue("exclusion");
42+
if (node.HasValue("restriction"))
43+
{
44+
try
45+
{
46+
restriction = bool.Parse(node.GetValue("restriction"));
47+
}
48+
catch (FormatException)
49+
{
50+
restriction = false;
51+
}
52+
}
53+
if (node.HasValue("dataRateModifier"))
54+
{
55+
try
56+
{
57+
dataRateModifier = float.Parse(node.GetValue("dataRateModifier"));
58+
}
59+
catch (FormatException)
60+
{
61+
dataRateModifier = 1f;
62+
}
63+
}
64+
// Load specific properties
65+
if (node.HasValue("gMin"))
66+
gMin = float.Parse(node.GetValue("gMin"));
67+
if (node.HasValue("gMax"))
68+
gMax = float.Parse(node.GetValue("gMax"));
69+
}
70+
public override void Save(ConfigNode node)
71+
{
72+
// Save common properties
73+
node.AddValue("conditionType", conditionType);
74+
node.AddValue("restriction", restriction);
75+
node.AddValue("exclusion", exclusion);
76+
node.AddValue("dataRateModifier", dataRateModifier);
77+
node.AddValue("gMin", gMin);
78+
node.AddValue("gMax", gMax);
79+
}
80+
}
81+
}

source/RealScience.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
<Compile Include="Conditions\RealScienceCondition_Altitude.cs" />
5555
<Compile Include="Conditions\RealScienceCondition_Biome.cs" />
5656
<Compile Include="Conditions\RealScienceCondition_Body.cs" />
57+
<Compile Include="Conditions\RealScienceCondition_GeeForce.cs" />
5758
<Compile Include="Conditions\RealScienceCondition_Orbit.cs" />
5859
<Compile Include="Conditions\RealScienceCondition_Part.cs" />
5960
<Compile Include="Conditions\RealScienceCondition_Resource.cs" />

0 commit comments

Comments
 (0)