Ejemplo n.º 1
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);

            if (HighLogic.LoadedSceneIsFlight == false)
            {
                setupExperimentGUI();
                return;
            }

            //Get drill animation
            drillAnimation = this.part.FindModuleImplementing <ModuleAnimationGroup>();

            //Harvester
            harvester = this.part.FindModuleImplementing <ModuleResourceHarvester>();

            //Core sample state
            coreSampleState = CoreSampleStates.Ready;

            //If the biome has been unlocked yet then get the samples left
            if (situationIsValid() && Utils.IsBiomeUnlocked(this.part.vessel))
            {
                coreSampleStatus = getSamplesLeft().ToString();
            }
            else
            {
                coreSampleStatus = kUnknown;
            }

            //Setup the gui
            setupGUI();
        }
Ejemplo n.º 2
0
        /*[KSPEvent(active = false, guiActive = false, guiActiveEditor = false, guiName = "Deploy")]
         * public void ModuleAnimationGroupEvent()
         * {
         *  float AnimLength;
         *
         #region tests
         *  //Debug.Log("ModuleAnimationGroupEvent fired");
         *
         *  //Debug.Log("Anim.isPlaying " + Anim.isPlaying.ToString());
         #endregion
         *
         *  try { AnimLength = Anim.clip.length; } catch { AnimLength = 1f; }
         *
         *  BaseField chooseField = Fields[nameof(ChooseOption)];
         *  try  //We only handle the  first module
         *  {
         *      if (MAG.isDeployed)
         *      {
         *          MAG.RetractModule();
         *          chooseField.guiActive = false;
         *          chooseField.guiActiveEditor = false;
         *
         *          this.Events["ModuleAnimationGroupEvent"].guiName = txtDeploy;
         *          this.Events["ModuleAnimationGroupEvent"].guiActive = false;
         *          //StartCoroutine(ModuleAnimationGroupEventCoroutine(AnimLength, 0.001f, Deploying: false));
         *      }
         *      else
         *      {
         *          MAG.DeployModule();
         *
         *          //Update UI
         *          //chooseField.guiActiveEditor = availableInEditor;
         *          //chooseField.guiActive = availableInFlight;
         *
         *          //Debug.Log("updateConverter in 'ModuleAnimationGroupEvent'");
         *          this.Events["ModuleAnimationGroupEvent"].guiName = txtRetract;
         *          this.Events["ModuleAnimationGroupEvent"].guiActive = false;
         *          //StartCoroutine(ModuleAnimationGroupEventCoroutine(AnimLength, 0.001f, Deploying: true));
         *      }
         *  }
         *  catch
         *  {
         *      //... do nothing
         *      GTIDebug.LogError(this.GetType().Name  + " -- ModuleAnimationGroup --- Error when handling animations");
         *  }
         * }*/

        /*protected virtual IEnumerator ModuleAnimationGroupEventCoroutine(float starttime, float waitingtime, bool Deploying)
         * {
         *  GTIDebug.Log("Start of ModuleAnimationGroupEventCoroutine()", iDebugLevel.High);
         *  yield return new WaitForSeconds(starttime);
         *  int _InvokeCounter = 0;
         *  while (_InvokeCounter++ < 600)
         *  {
         *      GTIDebug.Log("Coroutine Looping while animation is playing: " + _InvokeCounter, iDebugLevel.DebugInfo);
         *      if (Anim.isPlaying == false)
         *      {
         *          GTIDebug.Log("'Animation finished playing' --> update Mode");
         *          if (Deploying)
         *          {
         *              this.Fields["ChooseOption"].guiActiveEditor = availableInEditor;
         *              this.Fields["ChooseOption"].guiActive = availableInFlight;
         *              updateMultiMode(silentUpdate: true);
         *          }
         *          else
         *          {
         *              ModuleAnimationGroupEvent_DisableModules();
         *          }
         *
         *          //Reactivate the gui button
         *          this.Events["ModuleAnimationGroupEvent"].guiActive = true;
         *          GTIDebug.Log("Coroutine should stop here", iDebugLevel.DebugInfo);
         *          break;
         *      }
         *      else
         *      {
         *          GTIDebug.Log("Coroutine will wait for " + waitingtime + " sec and run again", iDebugLevel.DebugInfo);
         *          yield return new WaitForSeconds(waitingtime);
         *          GTIDebug.Log(this.GetType().Name + " -- Coroutine have waited for " + waitingtime + " sec and continue", iDebugLevel.DebugInfo);
         *      }
         *  }
         *  //Reactivate the gui button if waiting failed
         *  if (_InvokeCounter >= 600)
         *  {
         *      this.Fields["ChooseOption"].guiActive = true;
         *      this.Events["ModuleAnimationGroupEvent"].guiActive = true;
         *      GTIDebug.LogError("ModuleAnimationGroupEventCoroutine failed to finish successfully");
         *  }
         * }*/

        protected virtual void OnModuleAnimationGroupStateChanged(ModuleAnimationGroup module, bool Deploying)
        {
            GTIDebug.Log("Animation finished 'OnAnimationGroupStateChanged' --> update Mode", iDebugLevel.High);

            if (module != null && module.part != part)
            {
                GTIDebug.Log("triggering part is not this part", iDebugLevel.DebugInfo); return;
            }

            if (Deploying)
            {
                this.Fields["ChooseOption"].guiActiveEditor = availableInEditor;
                this.Fields["ChooseOption"].guiActive       = availableInFlight;
                //updateMultiMode(silentUpdate: true);
                OnUpdateMultiMode(silentUpdate: true);
            }
            else
            {
                this.Fields["ChooseOption"].guiActiveEditor = false;
                this.Fields["ChooseOption"].guiActive       = false;
                //externalToEVAOnly
                ModuleAnimationGroupEvent_DisableModules();
            }

            //Reactivate the gui button
            //this.Events["ModuleAnimationGroupEvent"].guiActive = true;
            GTIDebug.Log("OnAnimationGroupStateChanged executed", iDebugLevel.DebugInfo);
        }
Ejemplo n.º 3
0
 public override void ctrl(double value)
 {
   if (drill.AlwaysActive) return;
   ModuleAnimationGroup deploy = drill.part.FindModuleImplementing<ModuleAnimationGroup>();
   if (deploy != null && !deploy.isDeployed) deploy.DeployModule();
   if (value > double.Epsilon) drill.StartResourceConverter();
   else drill.StopResourceConverter();
 }
Ejemplo n.º 4
0
 public override string info()
 {
   if (drill.AlwaysActive) return "<color=green>always on</color>";
   ModuleAnimationGroup deploy = drill.part.FindModuleImplementing<ModuleAnimationGroup>();
   return deploy == null || deploy.isDeployed
     ? (drill.IsActivated ? "<color=green>on</color>" : "<color=red>off</color>")
     : "<color=red>not deployed</color>";
 }
 //Event when the state of the animation changed
 private void OnAnimationGroupStateChanged(ModuleAnimationGroup module, bool enabled)
 {
     if ((module == null) || (module.part != part))
     {
         return;
     }
     changable = !enabled;
     updateMenuVisibility(!enabled);
     updateHarvester();
 }
Ejemplo n.º 6
0
 internal ResourceHarvester(Part part)
 {
     this.part = part;
     harvester = part.InternalPart.Module <ModuleResourceHarvester> ();
     animator  = part.InternalPart.Module <ModuleAnimationGroup> ();
     if (harvester == null || animator == null)
     {
         throw new ArgumentException("Part is not a resource harvester");
     }
 }
        private void SetModuleState(ModuleAnimationGroup module, bool enable)
        {
            if (module != null && module.part != part)
            {
                return;
            }

            if (HighLogic.LoadedSceneIsFlight)
            {
                EnableMenus(enable);
            }
        }
Ejemplo n.º 8
0
        //Comment: Using "OnAnimationGroupStateChanged" event, I could probably further simplify the logics and remove
        //the overriding of the "ModuleAnimationGroup" functionality
        protected virtual void initializeModuleAnimationGroup()
        {
            //Debug.Log("useModuleAnimationGroup: " + useModuleAnimationGroup);
            if (!_MAGsettingsInitialized && useModuleAnimationGroup == true)
            {
                GTIDebug.Log("useModuleAnimationGroup: Evaluated as true", iDebugLevel.DebugInfo);
                //Animation Anim = new Animation();
                //ModuleAnimationGroup MAG = new ModuleAnimationGroup();

                MAG = part.FindModuleImplementing <ModuleAnimationGroup>();

                //Anim = part.FindModelAnimator(MAG.deployAnimationName);

                //foreach (BaseEvent e in MAG.Events)
                //{
                //    e.active = false;
                //    e.guiActive = false;
                //    e.guiActiveEditor = false;
                //}
                //foreach (BaseAction a in MAG.Actions)
                //{
                //    a.active = false;
                //}

                //GTIDebug.Log("Activate 'ModuleAnimationGroupEvent'", iDebugLevel.DebugInfo);

                //Activate event in this module to trigger animations instead
                //this.Events["ModuleAnimationGroupEvent"].active = true;
                //this.Events["ModuleAnimationGroupEvent"].guiActive = true;
                //this.Events["ModuleAnimationGroupEvent"].guiActiveEditor = true;
                //Patch 2018-03-14 to fix the button showing even when module is not deployed.
                GTIDebug.Log("initializeModuleAnimationGroup: !MAG.isDeployed " + !MAG.isDeployed, iDebugLevel.DebugInfo);
                if (!MAG.isDeployed)
                {
                    ModuleAnimationGroupEvent_DisableModules();
                }

                //Register the event of Animation Groups
                if (GameEvents.OnAnimationGroupStateChanged != null && MAG != null)
                {
                    GTIDebug.Log("Subscribing to OnAnimationGroupStateChanged", iDebugLevel.DebugInfo);
                    GameEvents.OnAnimationGroupStateChanged.Add(OnModuleAnimationGroupStateChanged);
                }

                //?? Add check if the MAG isDeployed? Adjust UI accordingly?

                _MAGsettingsInitialized = true;
            }
        }
Ejemplo n.º 9
0
        public override void OnStart(StartState state)
        {
            if (!Lib.IsFlight())
            {
                return;
            }

            // Kerbalism modules
            antenna    = part.FindModuleImplementing <Antenna>();
            customAnim = part.FindModuleImplementing <ModuleAnimationGroup>();
            // KSP modules
            // I'm using this.dist to save transmitter.antennaPower.
            //  CommNet - transmitter.canComm() = (isdeploy || moduleisActive)
            //    When the transmitter has no deploy(is fixed), isdeploy= True,
            //    Then the only way to disable the connection for this transmitter type is setting distance to 0 when no EC, forcing CommNet lost connection.
            //    When need enable back, take the information from this.dist
            transmitter = part.FindModuleImplementing <ModuleDataTransmitter>();
            stockAnim   = part.FindModuleImplementing <ModuleDeployableAntenna>();

            if (Features.Signal)
            {
                if (customAnim != null)
                {
                    pModule = customAnim;
                }
            }
            else if (Features.KCommNet)
            {
                if (stockAnim != null)
                {
                    pModule = stockAnim;
                }

                // Show transmissiter rate
                if (transmitter.antennaType != AntennaType.INTERNAL)
                {
                    Fields["actualECCost"].guiActive = true;
                }
            }
            base.OnStart(state);
        }
Ejemplo n.º 10
0
        private void SetModuleState(ModuleAnimationGroup module, bool enable)
        {
            if (module != null && module.part != part)
            {
                return;
            }

            if (enable)
            {
                EnableMenus(HighLogic.LoadedSceneIsEditor);
                SetupResourceCosts();
                SetupLoadouts();
                displayLoadout = currentLoadout;
                SetupMenus();
                NextSetup();
            }
            else
            {
                EnableMenus(false);
            }
        }
Ejemplo n.º 11
0
        public override void Start()
        {
            thisModule = "AntennaDeploy";
            if (Features.Signal)
            {
                antenna            = part.FindModuleImplementing <Antenna>();
                kerbalismAnimation = part.FindModuleImplementing <ModuleAnimationGroup>();
            }
            else
            {
                transmitter    = part.FindModuleImplementing <ModuleDataTransmitter>();
                StockAnimation = part.FindModuleImplementing <ModuleDeployableAntenna>();

                // I using the antennaModule & KerbalismDeploy to save distance & extend, this works for 2 purpose.
                //  First: When someone disable CommNet, Kerbalism antenna will work fine until extend is saved
                //  Second:	CommNet verify if transmitter.canComm == (isdeploy || moduleisActive)
                //    when the transmitter dosn't has deploy(is fixed), the only way to disable the connection is Setting distance to 0 when no EC, forcing CommNet lost connection.
                antenna            = part.FindModuleImplementing <Antenna>();
                kerbalismAnimation = part.FindModuleImplementing <ModuleAnimationGroup>();
            }
        }
Ejemplo n.º 12
0
        public override void OnStart(StartState state)
        {
            if (state == StartState.Editor && state == StartState.None && state == StartState.PreLaunch)
            {
                return;
            }
            mining = part.FindModuleImplementing <ModuleAnimationGroup>();
            foreach (PartModule pModule in part.FindModulesImplementing <Harvester>())
            {
                if (pModule.isEnabled)
                {
                    harvester = pModule as Harvester;
                }
            }

            if (mining != null)
            {
                pModule = mining;
            }
            base.OnStart(state);
        }
Ejemplo n.º 13
0
 public HarvesterDevice(Harvester module) : base(module)
 {
     animator = module.part.FindModuleImplementing <ModuleAnimationGroup>();
 }
Ejemplo n.º 14
0
        // this snippet returns true if the part is extended
        private bool IsDrillExtended()
        {
            ModuleAnimationGroup thisPartsAnimGroup = this.part.FindModuleImplementing <ModuleAnimationGroup>();

            return(thisPartsAnimGroup.isDeployed);
        }
Ejemplo n.º 15
0
 public override void OnStartFinished(StartState state)
 {
     base.OnStartFinished(state);
     _ani = part.FindModuleImplementing <ModuleAnimationGroup>();
 }
Ejemplo n.º 16
0
 public void EnqueueOnAnimation(ModuleAnimationGroup group, bool state)
 {
     EnqueueVessel(vessel);
 }
Ejemplo n.º 17
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);

            if (HighLogic.LoadedSceneIsFlight == false)
            {
                setupExperimentGUI();
                return;
            }

            //Get drill animation
            drillAnimation = this.part.FindModuleImplementing<ModuleAnimationGroup>();

            //Harvester
            harvester = this.part.FindModuleImplementing<ModuleResourceHarvester>();

            //Core sample state
            coreSampleState = CoreSampleStates.Ready;

            //If the biome has been unlocked yet then get the samples left
            if (situationIsValid() && Utils.IsBiomeUnlocked(this.part.vessel))
                coreSampleStatus = getSamplesLeft().ToString();
            else
                coreSampleStatus = kUnknown;

            //Setup the gui
            setupGUI();
        }
Ejemplo n.º 18
0
 public override void OnStartFinished(StartState state)
 {
     base.OnStartFinished(state);
     _ani = part.FindModuleImplementing<ModuleAnimationGroup>();
 }
 public AnimationGroupEC(ModuleAnimationGroup module, double extra_Cost, double extra_Deploy)
 {
     this.module       = module;
     this.extra_Deploy = extra_Deploy;
 }
        private void SetModuleState(ModuleAnimationGroup module, bool enable)
        {
            if (module != null && module.part != part)
                return;

            if (enable)
            {
                EnableMenus(HighLogic.LoadedSceneIsEditor);
                SetupResourceCosts();
                SetupLoadouts();
                displayLoadout = currentLoadout;
                SetupMenus();
                NextSetup();
            }
            else
            {
                EnableMenus(false);
            }
        }