Use ConfigParser library.
This commit is contained in:
parent
c75159f706
commit
9dcf923a49
|
@ -20,7 +20,11 @@ namespace IngameScript
|
||||||
{
|
{
|
||||||
_p = p;
|
_p = p;
|
||||||
_hinge = hinge;
|
_hinge = hinge;
|
||||||
parseConfig();
|
|
||||||
|
ConfigParser config = new ConfigParser(_hinge);
|
||||||
|
_openAngle = config.GetValue("OpenAngle", 90F);
|
||||||
|
_closedAngle = config.GetValue("ClosedAngle", 0F);
|
||||||
|
_velocity = config.GetValue("Velocity", 5F);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For these two functions, IMyMotorStator.Angle reports radians, but
|
// For these two functions, IMyMotorStator.Angle reports radians, but
|
||||||
|
@ -52,28 +56,6 @@ namespace IngameScript
|
||||||
return Locked;
|
return Locked;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseConfig()
|
|
||||||
{
|
|
||||||
string[] lines = _hinge.CustomData.Split('\n');
|
|
||||||
foreach (string line in lines)
|
|
||||||
{
|
|
||||||
string[] tokens = line.Split('=');
|
|
||||||
if (tokens.Length != 2) continue;
|
|
||||||
switch (tokens[0])
|
|
||||||
{
|
|
||||||
case "OpenAngle":
|
|
||||||
_openAngle = float.Parse(tokens[1]);
|
|
||||||
break;
|
|
||||||
case "ClosedAngle":
|
|
||||||
_closedAngle = float.Parse(tokens[1]);
|
|
||||||
break;
|
|
||||||
case "Velocity":
|
|
||||||
_velocity = float.Parse(tokens[1]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private float degToRad(float degrees)
|
private float degToRad(float degrees)
|
||||||
{
|
{
|
||||||
return degrees * ((float)Math.PI / 180F);
|
return degrees * ((float)Math.PI / 180F);
|
||||||
|
|
|
@ -23,4 +23,6 @@
|
||||||
<AdditionalFiles Include="Instructions.readme" />
|
<AdditionalFiles Include="Instructions.readme" />
|
||||||
<AdditionalFiles Include="thumb.png" />
|
<AdditionalFiles Include="thumb.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<Import Project="..\Mixins\Console\Console.projitems" Label="shared" />
|
||||||
|
<Import Project="..\Mixins\ConfigParser\ConfigParser.projitems" Label="shared" />
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue
Block a user