Skip to content

Commit

Permalink
remove IR dependency, use action group
Browse files Browse the repository at this point in the history
  • Loading branch information
camlost2 committed Nov 26, 2014
1 parent f0bbdbc commit fc963ca
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
Binary file added GameData/AVTOL/Plugins/AVTOL.dll
Binary file not shown.
Binary file removed GameData/MagicSmokeIndustries/Plugins/AVTOL.dll
Binary file not shown.
63 changes: 35 additions & 28 deletions Source/AVTOL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,26 @@ namespace AVTOL
{
public class AVTOL:PartModule
{
[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Pitch Neutral%", guiFormat = "0"),
[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Pitch Neutral%"),
UI_FloatRange(minValue = 0f, maxValue = 100f, stepIncrement = 1f)]
public float pitchNeutral = 100f;
[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Pitch Range%", guiFormat = "0"),
[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Pitch Range%"),
UI_FloatRange(minValue = -100f, maxValue = 100f, stepIncrement = 1f)]
public float pitchRange = 0f;

[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Phase Angle"),
UI_FloatRange(minValue = 0f, maxValue = 180f, stepIncrement = 5f)]
public float phaseAngle = 90f;

[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "IR Sync:"),
UI_Toggle(disabledText = "Off", enabledText = "On")]
public bool usePhaseAngle = false;

[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Phase Angle", guiFormat = "0"),
UI_FloatRange(minValue = -180f, maxValue = 180f, stepIncrement = 5f)]
public float phaseAngle = 90f;
[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Max Angle"),
UI_FloatRange(minValue = 0f, maxValue = 180f, stepIncrement = 5f)]
public float maxAngle = 90f;

[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Vertical Cutoff", guiFormat = "0"),
[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Step Angle"),
UI_FloatRange(minValue = -90f, maxValue = 90f, stepIncrement = 0.5f)]
public float stepAngle = 22.5f;

[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Vertical Cutoff"),
UI_FloatRange(minValue = 1f, maxValue = 100f, stepIncrement = 1f)]
public float verticalspeed = 100f;

Expand All @@ -47,10 +51,22 @@ public void toggleSystem(KSPActionParam param)
SetThrustPercentage(100f);
}
}

[KSPAction("Increase Phase Angle")]
public void increasePhaseAngle(KSPActionParam param)
{
phaseAngle += stepAngle;
if (phaseAngle > maxAngle)
phaseAngle = maxAngle;
}
[KSPAction("Decrease Phase Angle")]
public void DecreasePhaseAngle(KSPActionParam param)
{
phaseAngle -= stepAngle;
if (phaseAngle < 0f)
phaseAngle = 0f;
}
private ModuleEngines engine;
private ModuleEnginesFX engineFX;
private MuMech.MuMechToggle muMechToggle;
public override void OnStart(StartState state)
{
if (state == StartState.Editor)
Expand All @@ -60,14 +76,6 @@ public override void OnStart(StartState state)
engine = (ModuleEngines)part.Modules["ModuleEngines"];
if (part.Modules.Contains("ModuleEnginesFX"))
engineFX = (ModuleEnginesFX)part.Modules["ModuleEnginesFX"];
foreach (Part p in vessel.parts)
{
if (p.Modules.Contains("MuMechToggle"))
{
muMechToggle = (MuMech.MuMechToggle)p.Modules["MuMechToggle"];
return;
}
}
}

public void FixedUpdate()
Expand All @@ -76,10 +84,13 @@ public void FixedUpdate()
this.Fields["pitchNeutral"].guiActiveEditor = showMenu;
this.Fields["pitchRange"].guiActive = showMenu;
this.Fields["pitchRange"].guiActiveEditor = showMenu;
this.Fields["usePhaseAngle"].guiActive = showMenu;
this.Fields["usePhaseAngle"].guiActiveEditor = showMenu;
this.Fields["phaseAngle"].guiActive = showMenu;
this.Fields["phaseAngle"].guiActiveEditor = showMenu;
this.Fields["phaseAngle"].guiActive = showMenu;
this.Fields["maxAngle"].guiActive = showMenu;
this.Fields["maxAngle"].guiActiveEditor = showMenu;
this.Fields["stepAngle"].guiActive = showMenu;
this.Fields["stepAngle"].guiActiveEditor = showMenu;

this.Fields["verticalspeed"].guiActive = showMenu;
this.Fields["verticalspeed"].guiActiveEditor = showMenu;

Expand All @@ -93,12 +104,8 @@ public void FixedUpdate()

float T = pitchNeutral;
T *= (1f - (float)vessel.verticalSpeed / verticalspeed);
T *= Mathf.Sin(phaseAngle / 57.259f);
T = Mathf.Clamp(T, 0f, 100f);
if(muMechToggle!=null && usePhaseAngle)
{
T *= Mathf.Cos((muMechToggle.rotation - phaseAngle)/57.259f);
}

T += pitchRange * vessel.ctrlState.pitch;
SetThrustPercentage(T);

Expand Down
7 changes: 0 additions & 7 deletions Source/AVTOL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@
<Reference Include="Assembly-CSharp">
<HintPath>D:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="InfernalRobotics">
<HintPath>D:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\GameData\MagicSmokeIndustries\Plugins\InfernalRobotics.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand Down
Binary file modified Source/AVTOL.v12.suo
Binary file not shown.

0 comments on commit fc963ca

Please sign in to comment.