//private bool showMenu = false;
        //private Rect windowRect = new Rect(500f, 250f, 250f, 50f);
        //private FSGUIPopup popup;

        public override void OnStart(PartModule.StartState state)
        {
            debug.debugMode = debugMode;
            engine          = new FSengineWrapper(part);
            if (engine.type != FSengineWrapper.EngineType.NONE)
            {
                //Debug.Log("FSswitchEngineThrustTransform: Engine module found");
                thrustTransform         = part.FindModelTransform(defaultTTName);
                defaultTT               = new GameObject().transform;
                defaultTT.localPosition = thrustTransform.localPosition;
                defaultTT.localRotation = thrustTransform.localRotation;
                //defaultTT = part.FindModelTransform(defaultTTName);
                if (useNamedAlternate == 1)
                {
                    debug.debugMessage("Finding alternate TT");
                    alternateTT = part.FindModelTransform(alternateTTName);
                    if (alternateTT == null)
                    {
                        debug.debugMessage("Did not find alternate TT " + alternateTTName);
                    }
                }
                else
                {
                    debug.debugMessage("Using flipped default TT as reverse");
                    alternateTT = new GameObject().transform;
                    alternateTT.localPosition = defaultTT.localPosition;
                    alternateTT.localRotation = defaultTT.localRotation;
                    alternateTT.Rotate(alternateTT.right, 180f);
                }
                if (defaultTT == null || alternateTT == null)
                {
                    valid = false;
                }

                if (isReversed)
                {
                    setTTReverseState(true);
                }
                else
                {
                    setTTReverseState(false);
                }
            }
            else
            {
                valid = false;
                Debug.Log("FSswitchEngineThrustTransform: no engine module found");
            }

            animateThrottle = part.Modules.OfType <FSanimateThrottle>().FirstOrDefault();
            if (animateThrottle != null)
            {
                animateThrottle.modeList.Add(new mode(animateThrottleRange.x, animateThrottleRange.y));
                animateThrottleMode = animateThrottle.modeList.Count - 1;
            }
        }
        void Start()
        {
            if (!HighLogic.LoadedSceneIsFlight)
            {
                return;
            }

            engine = new FSengineWrapper(part);

            // Create the mesh disc. Particles spawn inside this mesh on the ground
            washDisc.transform.parent = transform;
            meshFilter      = washDisc.AddComponent <MeshFilter>();
            meshFilter.mesh = MeshCreator.createDisc(emissionDiscSize, 100);


            //KSP 1.8
            // fetch the particle texture from KSP's Game Database
            //particleTexture = GameDatabase.Instance.GetTexture(particleTextureName, false);

            //if (particleTexture == null)
            //{
            //    Debug.Log("FSgroundParticles: particle texture loading error");
            //    // it should use the default particle in this case, or just some pink crap maybe
            //}
            //else
            //{
            //    //Setting the values for the particle system. the animator is never doing anything exciting, all particle motion is handled in the late update code
            //    particleFX = new FSparticleFX(washDisc, particleTexture);

            //    // particles change color and alpha over time.
            //    particleFX.AnimatorColor0 = getColorFromV4(particleColor0);
            //    particleFX.AnimatorColor1 = getColorFromV4(particleColor1);
            //    particleFX.AnimatorColor2 = getColorFromV4(particleColor2);
            //    particleFX.AnimatorColor3 = getColorFromV4(particleColor3);
            //    particleFX.AnimatorColor4 = getColorFromV4(particleColor4);

            //    particleFX.EmitterMinSize = particleSize.x;
            //    particleFX.EmitterMaxSize = particleSize.y;
            //    particleFX.EmitterMinEnergy = particleEnergy.x;
            //    particleFX.EmitterMaxEnergy = particleEnergy.y;
            //    particleFX.EmitterMinEmission = 0f;
            //    particleFX.EmitterMaxEmission = 0f;
            //    particleFX.AnimatorSizeGrow = particleSizeGrow;

            //    particleFX.EmitterLocalVelocity = new Vector3(0f, 0f, 0f);
            //    particleFX.EmitterRndVelocity = new Vector3(0f, 0f, 0f);
            //    // creates the emitters etc and assigns the above values
            //    particleFX.setupFXValues();

            //    //particleFX.pEmitter.rndRotation = true;

            //    // Can't turn on Interpolate Triangles on the emitter, casue it's not exposed to code. REALLY?!? WHY?
            //}
            //KSP 1.8
            thrustTransform = part.FindModelTransform(thrustTransformName);
        }
        /*[KSPEvent(name = "toggleDirection", active = true, guiActive = true, guiName = "toggle direction")]
         * public void toggleDirectionEvent()
         * {
         *  directionInt++;
         *  if (directionInt > 5) directionInt = 0;
         *  switch (directionInt)
         *  {
         *      case 0:
         *          direction = Vector3.up;
         *          vectorName = "up";
         *          break;
         *      case 1:
         *          direction = -Vector3.up;
         *          vectorName = "-up";
         *          break;
         *      case 2:
         *          direction = Vector3.right;
         *          vectorName = "right";
         *          break;
         *      case 3:
         *          direction = -Vector3.right;
         *          vectorName = "-right";
         *          break;
         *      case 4:
         *          direction = Vector3.forward;
         *          vectorName = "forward";
         *          break;
         *      case 5:
         *          direction = -Vector3.forward;
         *          vectorName = "-forward";
         *          break;
         *      default:
         *          direction = Vector3.forward;
         *          vectorName = "default";
         *          break;
         *  }
         * }*/

        public override void OnStart(PartModule.StartState state)
        {
            engine           = new FSengineWrapper(part);
            defaultMaxThrust = engine.maxThrust;
            if (useAtmospehricNerfModule == 1)
            {
                atmosphericNerf = part.Modules.OfType <FSpropellerAtmosphericNerf>().FirstOrDefault();
            }
            thrustTransform = part.FindModelTransform("thrustTransform");
        }
示例#4
0
        public override void OnStart(PartModule.StartState state)
        {
            if (!HighLogic.LoadedSceneIsFlight) return;

            engine = new FSengineWrapper(part);
            resourceID = resourceName.GetHashCode();
            propTweak = part.Modules.OfType<FSpropellerTweak>().FirstOrDefault();
            if (propTweak != null)
            {
                engineScaleMultiplier = Mathf.Max(0.1f, propTweak.engineLengthSlider); // engine scale can be 0 or negative. That would be a bad multiplier.
            }
        }
        void Start()
        {
            if (!HighLogic.LoadedSceneIsFlight) return;

            engine = new FSengineWrapper(part);

            // Create the mesh disc. Particles spawn inside this mesh on the ground
            washDisc.transform.parent = transform;
            meshFilter = washDisc.AddComponent<MeshFilter>();            
            meshFilter.mesh = MeshCreator.createDisc(emissionDiscSize, 100);

            // fetch the particle texture from KSP's Game Database
            particleTexture = GameDatabase.Instance.GetTexture(particleTextureName, false);            
                                      
            if (particleTexture == null)
            {
                Debug.Log("FSgroundParticles: particle texture loading error");
                // it should use the default particle in this case, or just some pink crap maybe
            }
            else
            {
                //Setting the values for the particle system. the animator is never doing anything exciting, all particle motion is handled in the late update code
                particleFX = new FSparticleFX(washDisc, particleTexture);  
           
                // particles change color and alpha over time.
                particleFX.AnimatorColor0 = getColorFromV4(particleColor0);
                particleFX.AnimatorColor1 = getColorFromV4(particleColor1);
                particleFX.AnimatorColor2 = getColorFromV4(particleColor2);
                particleFX.AnimatorColor3 = getColorFromV4(particleColor3);
                particleFX.AnimatorColor4 = getColorFromV4(particleColor4);                

                particleFX.EmitterMinSize = particleSize.x;
                particleFX.EmitterMaxSize = particleSize.y;
                particleFX.EmitterMinEnergy = particleEnergy.x;
                particleFX.EmitterMaxEnergy = particleEnergy.y;
                particleFX.EmitterMinEmission = 0f;
                particleFX.EmitterMaxEmission = 0f;
                particleFX.AnimatorSizeGrow = particleSizeGrow;

                particleFX.EmitterLocalVelocity = new Vector3(0f, 0f, 0f);
                particleFX.EmitterRndVelocity = new Vector3(0f, 0f, 0f);                
                // creates the emitters etc and assigns the above values
                particleFX.setupFXValues();

                //particleFX.pEmitter.rndRotation = true;

                // Can't turn on Interpolate Triangles on the emitter, casue it's not exposed to code. REALLY?!? WHY?
            }

            thrustTransform = part.FindModelTransform(thrustTransformName);
        }
        //private bool showMenu = false;
        //private Rect windowRect = new Rect(500f, 250f, 250f, 50f);
        //private FSGUIPopup popup;

        public override void OnStart(PartModule.StartState state)
        {
            debug.debugMode = debugMode;
            engine = new FSengineWrapper(part);
            if (engine.type != FSengineWrapper.EngineType.NONE)
            {
                //Debug.Log("FSswitchEngineThrustTransform: Engine module found");
                thrustTransform = part.FindModelTransform(defaultTTName);
                defaultTT = new GameObject().transform;
                defaultTT.localPosition = thrustTransform.localPosition;
                defaultTT.localRotation = thrustTransform.localRotation;
                //defaultTT = part.FindModelTransform(defaultTTName);
                if (useNamedAlternate == 1)
                {
                    debug.debugMessage("Finding alternate TT");
                    alternateTT = part.FindModelTransform(alternateTTName);
                    if (alternateTT == null) debug.debugMessage("Did not find alternate TT " + alternateTTName);
                }
                else
                {
                    debug.debugMessage("Using flipped default TT as reverse");
                    alternateTT = new GameObject().transform;
                    alternateTT.localPosition = defaultTT.localPosition;
                    alternateTT.localRotation = defaultTT.localRotation;
                    alternateTT.Rotate(alternateTT.right, 180f);
                }
                if (defaultTT == null || alternateTT == null) valid = false;

                if (isReversed)
                {
                    setTTReverseState(true);
                }
                else
                {
                    setTTReverseState(false);
                }
            }
            else
            {
                valid = false;
                Debug.Log("FSswitchEngineThrustTransform: no engine module found");
            }

            animateThrottle = part.Modules.OfType<FSanimateThrottle>().FirstOrDefault();
            if (animateThrottle != null)
            {
                animateThrottle.modeList.Add(new mode(animateThrottleRange.x, animateThrottleRange.y));
                animateThrottleMode = animateThrottle.modeList.Count - 1;
            }
        }
        public override void OnStart(PartModule.StartState state)
        {
            if (!HighLogic.LoadedSceneIsFlight)
            {
                return;
            }

            engine     = new FSengineWrapper(part);
            resourceID = resourceName.GetHashCode();
            propTweak  = part.Modules.OfType <FSpropellerTweak>().FirstOrDefault();
            if (propTweak != null)
            {
                engineScaleMultiplier = Mathf.Max(0.1f, propTweak.engineLengthSlider); // engine scale can be 0 or negative. That would be a bad multiplier.
            }
        }
示例#8
0
        public override void OnStart(PartModule.StartState state)
        {
            engine = new FSengineWrapper(part);
            if (usesDeployAnimation == 1)
            {
                deployAnimation = part.Modules.OfType <FSanimateGeneric>().FirstOrDefault();
            }

            atmosphericNerf = part.Modules.OfType <FSpropellerAtmosphericNerf>().FirstOrDefault();
            if (rotorparent != "")
            {
                RotorParent     = part.FindModelTransform(rotorparent);
                spinRotorObject = true;
            }
            else
            {
                spinRotorObject = false;
            }
        }
示例#9
0
 public override void OnStart(PartModule.StartState state)
 {
     //Debug.Log("KTengineHover OnStart");
     base.OnStart(state);
     if (HighLogic.LoadedSceneIsFlight)
     {
         engine = new FSengineWrapper(part);
         if (engine != null)
         {
             if (maxThrustFetched && maxThrust > 0f)
             {
                 engine.maxThrust = maxThrust;
             }
             else
             {
                 maxThrust        = engine.maxThrust;
                 maxThrustFetched = true;
             }
             minThrust = engine.minThrust;
         }
     }
 }
示例#10
0
 public override void OnStart(PartModule.StartState state)
 {
     //Debug.Log("KTengineHover OnStart");
     base.OnStart(state);
     if (HighLogic.LoadedSceneIsFlight)
     {
         engine = new FSengineWrapper(part);
         if (engine != null)
         {
             if (maxThrustFetched && maxThrust > 0f)
             {
                 engine.maxThrust = maxThrust;
             }
             else
             {
                 maxThrust = engine.maxThrust;
                 maxThrustFetched = true;
             }
             minThrust = engine.minThrust;
         }
     }
 }
示例#11
0
        public override void OnStart(PartModule.StartState state)
        {
            base.OnStart(state);
            if (pitchObject != "none")
            {
                pitchTransform = part.FindModelTransform(pitchObject);
                if (pitchTransform != null)
                {
                    usePitch = true;
                }
            }
            if (rollObject != "none")
            {
                rollTransform = part.FindModelTransform(rollObject);
                if (rollTransform != null)
                {
                    useRoll = true;
                }
            }
            if (yawObject != "none")
            {
                yawTransform = part.FindModelTransform(yawObject);
                if (yawTransform != null)
                {
                    useYaw = true;
                }
            }

            if (useReferenceGimbal)
            {
                if (gimbalTransformName == string.Empty)
                {
                    useReferenceGimbal = false;
                    Debug.Log("FSmultiAxisEngine: gimbal transform name empty");
                }
                else
                {
                    gimbalTransform = part.FindModelTransform(gimbalTransformName);
                    if (gimbalTransform != null)
                    {
                        pitchGimbalExtreme = part.FindModelTransform(pitchGimbalExtremeTransformName);
                        //rollGimbalExtreme = part.FindModelTransform(rollGimbalExtremeTransformName);
                        yawGimbalExtreme = part.FindModelTransform(yawGimbalExtremeTransformName);

                        if (pitchGimbalExtreme == null)
                        {
                            usePitch = false;
                            Debug.Log("FSmultiAxisEngine: pitch gimbal extreme not found");
                        }

                        if (yawGimbalExtreme == null)
                        {
                            usePitch = false;
                            Debug.Log("FSmultiAxisEngine: yaw gimbal extreme not found");
                        }

                        gimbalDefaultRotation = gimbalTransform.rotation;
                    }
                    else
                    {
                        useReferenceGimbal = false;
                        Debug.Log("FSmultiAxisEngine: gimbal transform not found: " + gimbalTransformName);
                    }
                }
            }

            if (lockWhenEngineIdle)
            {
                engine = new FSengineWrapper(part);
                if (engine == null)
                {
                    lockWhenEngineIdle = false;
                }
            }
        }
示例#12
0
 public override void OnStart(PartModule.StartState state)
 {
     engine       = new FSengineWrapper(part);
     fullThrottle = engine.maxThrust;
 }
 public override void OnStart(PartModule.StartState state)
 {            
     engine = new FSengineWrapper(part);
     fullThrottle = engine.maxThrust;
 }
示例#14
0
        public override void OnStart(PartModule.StartState state)
        {
            base.OnStart(state);
            if (pitchObject != "none")
            {
                pitchTransform = part.FindModelTransform(pitchObject);
                if (pitchTransform != null)
                    usePitch = true;
            }
            if (rollObject != "none")
            {
                rollTransform = part.FindModelTransform(rollObject);
                if (rollTransform != null)
                    useRoll = true;
            }
            if (yawObject != "none")
            {
                yawTransform = part.FindModelTransform(yawObject);
                if (yawTransform != null)
                    useYaw = true;
            }

            if (useReferenceGimbal)
            {
                if (gimbalTransformName == string.Empty)
                {
                    useReferenceGimbal = false;
                    Debug.Log("FSmultiAxisEngine: gimbal transform name empty");
                }
                else
                {
                    gimbalTransform = part.FindModelTransform(gimbalTransformName);
                    if (gimbalTransform != null)
                    {
                        pitchGimbalExtreme = part.FindModelTransform(pitchGimbalExtremeTransformName);
                        //rollGimbalExtreme = part.FindModelTransform(rollGimbalExtremeTransformName);
                        yawGimbalExtreme = part.FindModelTransform(yawGimbalExtremeTransformName);

                        if (pitchGimbalExtreme == null)
                        {
                            usePitch = false;
                            Debug.Log("FSmultiAxisEngine: pitch gimbal extreme not found");
                        }

                        if (yawGimbalExtreme == null)
                        {
                            usePitch = false;
                            Debug.Log("FSmultiAxisEngine: yaw gimbal extreme not found");
                        }

                        gimbalDefaultRotation = gimbalTransform.rotation;
                    }
                    else
                    {
                        useReferenceGimbal = false;
                        Debug.Log("FSmultiAxisEngine: gimbal transform not found: " + gimbalTransformName);
                    }
                }
            }

            if (lockWhenEngineIdle)
            {
                engine = new FSengineWrapper(part);
                if (engine == null)
                    lockWhenEngineIdle = false;
            }
        }
示例#15
0
        /*[KSPEvent(name = "toggleDirection", active = true, guiActive = true, guiName = "toggle direction")]
        public void toggleDirectionEvent()
        {
            directionInt++;
            if (directionInt > 5) directionInt = 0;
            switch (directionInt)
            {
                case 0:
                    direction = Vector3.up;
                    vectorName = "up";
                    break;
                case 1:
                    direction = -Vector3.up;
                    vectorName = "-up";
                    break;
                case 2:
                    direction = Vector3.right;
                    vectorName = "right";
                    break;
                case 3:
                    direction = -Vector3.right;
                    vectorName = "-right";
                    break;
                case 4:
                    direction = Vector3.forward;
                    vectorName = "forward";
                    break;
                case 5:
                    direction = -Vector3.forward;
                    vectorName = "-forward";
                    break;
                default:
                    direction = Vector3.forward;
                    vectorName = "default";
                    break;        
            }
        }*/

        public override void OnStart(PartModule.StartState state)
        {
            engine = new FSengineWrapper(part);
            defaultMaxThrust = engine.maxThrust;
            if (useAtmospehricNerfModule == 1)
                atmosphericNerf = part.Modules.OfType<FSpropellerAtmosphericNerf>().FirstOrDefault();
            thrustTransform = part.FindModelTransform("thrustTransform");
        }
示例#16
0
 public override void OnStart(PartModule.StartState state)
 {
     engine = new FSengineWrapper(part);
     if (usesDeployAnimation == 1)
     {
         deployAnimation = part.Modules.OfType<FSanimateGeneric>().FirstOrDefault();
     }
     
     atmosphericNerf = part.Modules.OfType<FSpropellerAtmosphericNerf>().FirstOrDefault();
     if (rotorparent != "")
     {
         RotorParent = part.FindModelTransform(rotorparent);
         spinRotorObject = true;
     }
     else
     {
         spinRotorObject = false;
     }
 }