Advertisement
Guest User

SolarActionGroup Source Code

a guest
Jun 13th, 2015
998
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using UnityEngine;
  6.  
  7. namespace SolarActionGroup
  8. {
  9.     [KSPAddon(KSPAddon.Startup.Flight , false)]
  10.     public class SolarActionGroup : MonoBehaviour
  11.     {
  12.         public void Update(){
  13.             if (Input.GetKeyDown(KeyCode.P) && FlightGlobals.ActiveVessel.IsControllable){
  14.                 foreach (Part shipPart in FlightGlobals.ActiveVessel.parts){
  15.                     if(shipPart.gameObject.GetComponent<ModuleDeployableSolarPanel>() != null){
  16.                         ModuleDeployableSolarPanel panel = shipPart.gameObject.GetComponent<ModuleDeployableSolarPanel>();
  17.                         if (panel.status == "Retracted" && panel.sunTracking) {panel.Extend();}
  18.                         else if (panel.sunTracking && panel.retractable){panel.Retract();}
  19.                     }
  20.                 }
  21.             }
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement