Skip to content

Commit

Permalink
Add camera door only option for recon scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
DMagic1 committed Apr 19, 2016
1 parent 4581dbc commit 7a1a0fa
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions Source/Part Modules/DMReconScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class DMReconScope : DMModuleScienceAnimate, IDMSurvey
public string loopingAnimName = "";
[KSPField]
public string filmCannisterName = "cannister";
[KSPField]
public bool openDoorsOnly = false;

private Animation loopingAnim;
private bool windingDown;
Expand All @@ -60,6 +62,15 @@ public override void OnStart(PartModule.StartState state)
startLoopingAnimation(1f);

setCannisterObjects();

if (openDoorsOnly)
{
DMUtils.Logging("Setting Door Only Status...");
Events["openDoors"].active = !IsDeployed;
Events["closeDoors"].active = IsDeployed;
Actions["openDoorsAction"].active = true;
Actions["closeDoorsAction"].active = true;
}
}

private void setCannisterObjects()
Expand Down Expand Up @@ -180,17 +191,69 @@ protected override void onLabReset()
}
}

[KSPEvent(guiActive = true, guiName = "Open Camera Doors", active = false)]
public void openDoors()
{
base.deployEvent();

Events["openDoors"].active = false;
Events["closeDoors"].active = true;
}

[KSPAction("Open Camera Doors")]
public void openDoorsAction()
{
openDoors();
}

[KSPEvent(guiActive = true, guiName = "Close Camera Doors", active = false)]
public void closeDoors()
{
if (loopingAnim != null)
{
if (loopingAnim.IsPlaying(loopingAnimName))
{
if (windingUp)
return;

if (windingDown)
return;

StartCoroutine(stopLooping());

return;
}
}

base.retractEvent();

Events["openDoors"].active = true;
Events["closeDoors"].active = false;
}

[KSPAction("Close Camera Doors")]
public void closeDoorsAction()
{
closeDoors();
}

public override void deployEvent()
{
if (windingDown)
return;

if (windingUp)
return;

base.deployEvent();

if (HighLogic.LoadedSceneIsEditor)
return;

StartCoroutine(startLooping(waitForAnimationTime));

Events["openDoors"].active = false;
Events["closeDoors"].active = openDoorsOnly;
}

private IEnumerator startLooping(float time)
Expand Down Expand Up @@ -220,6 +283,9 @@ public override void retractEvent()
if (windingUp)
return;

if (windingDown)
return;

StartCoroutine(stopLooping());
}

Expand All @@ -233,6 +299,9 @@ private IEnumerator stopLooping()

yield return new WaitForSeconds(time);

Events["openDoors"].active = openDoorsOnly;
Events["closeDoors"].active = false;

windingDown = false;

base.retractEvent();
Expand Down

0 comments on commit 7a1a0fa

Please sign in to comment.