예제 #1
0
        /*public override void onPartDestroy()
         * {
         *  this.VPI.scanVessel();
         * }*/

        public void init()
        {
            if (PowSys == null)
            {
                PowSys = new LCARS_PowerSystem();
                PowSys.SetShip(this.CurrentMotherShip);
                PT1 = this.PowSys.setPowerTaker("TransporterSystem", "SubSystem", 1250, 2500, 500);
            }

            if (planetScanner == null)
            {
                planetScanner = new LCARS_PlanetScanner();
                LCARS_Utilities.SetLoadDistance(100000, 100000);
            }

            /*
             */


            if (TransporterSound == null)
            {
                TransporterSound = new FXGroup("TransporterSound");
                GameObject audioObj = new GameObject();
                audioObj.transform.position         = FlightGlobals.ActiveVessel.transform.position;
                audioObj.transform.parent           = FlightGlobals.ActiveVessel.transform; // add to parent
                TransporterSound.audio              = audioObj.AddComponent <AudioSource>();
                TransporterSound.audio.dopplerLevel = 0f;
                TransporterSound.audio.Stop();
                TransporterSound.audio.clip = GameDatabase.Instance.GetAudioClip(TransporterSoundFile);
                TransporterSound.audio.loop = false;
                TransporterSound.audio.Play();
                TransporterSound.audio.enabled = false;
                TransporterSound.audio.time    = 0;
            }
        }
예제 #2
0
        private void OnGUI()
        {
            if (HighLogic.LoadedSceneIsEditor)
            {
                return;
            }

            if (!TriCorderEnabled)
            {
                return;
            }

            if (this.vessel == FlightGlobals.ActiveVessel)
            {
                myStyle                     = new GUIStyle();
                myStyle.margin              = new RectOffset(0, 0, 0, 0);
                myStyle.padding             = new RectOffset(0, 0, -11, 0);
                myStyle.normal.background   = GameDatabase.Instance.GetTexture("SciFi/StarTrekImpulseDrive/Icons/v3/blind", false);
                myStyle.onNormal.background = GameDatabase.Instance.GetTexture("SciFi/StarTrekImpulseDrive/Icons/v3/blind", false);
                myStyle.onHover.background  = GameDatabase.Instance.GetTexture("SciFi/StarTrekImpulseDrive/Icons/v3/blind", false);
                myStyle.normal.background   = GameDatabase.Instance.GetTexture("SciFi/StarTrekImpulseDrive/Icons/v3/blind", false);

                TricorderwindowPosition = LCARS_Utilities.ClampToScreen(GUILayout.Window(windowID, TricorderwindowPosition, TriCorderWindow, "", myStyle));
            }
        }
예제 #3
0
        public static void AdditionalPowerConsumption(Vessel thisVessel, float vSliderValue, float hSliderValue, float zSliderValue)
        {
            charge = 200;
            float x = (vSliderValue < 0) ? vSliderValue * -1 : vSliderValue;
            float y = (hSliderValue < 0) ? hSliderValue * -1 : hSliderValue;
            float z = (zSliderValue < 0) ? zSliderValue * -1 : zSliderValue;

            total_force = x + y + z;
            charge     += total_force * 12;
            if (charge > 0)
            {
                LCARS_Utilities.usePower(charge, thisVessel);
            }
        }
예제 #4
0
        private void Info_Subsystem()
        {
            GUILayout.Label("");
            GUILayout.Label("Tricorder Mainscreen");



            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Identification: ");
            GUILayout.Label("" + vessel.vesselName);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Clearance Code: ");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            string[] nameszz = vessel.vesselName.Split(' ');
            GUILayout.FlexibleSpace();
            GUILayout.Label(LCARS_Utilities.AlphaCharlyTango(nameszz[0], vessel.id.ToString(), 4));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Clearance Level: ");
            GUILayout.Label("5");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Location: ");
            GUILayout.Label("" + vessel.RevealSituationString() + "");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Away Team Report: ");
            if (GUILayout.Button("Run TricorderAwayTeamStatus"))
            {
                ModuleScienceExperimentList["TricorderAwayTeamStatus"].DeployExperiment();
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
예제 #5
0
        /// <summary>
        /// Takes a Vessel as argument and tryes to calculate the power consumption at current accelleration
        /// will call usePower(float eCharge, Vessel thisVessel)
        /// </summary>
        public static Dictionary <string, float> CalculatePowerConsumption(Dictionary <string, float> Powerstats, Vessel thisVessel, bool gravityEnabled, bool UseFullImpulse, bool UseReservePower, float UseFullImpulse_multiplier, float UseReservePower_multiplier, float vSliderValue, float hSliderValue, float zSliderValue)
        {
            /*
             * Powerstats.Add("charge", 0);
             * Powerstats.Add("total_force", 0);
             * Powerstats.Add("force_x", 0);
             * Powerstats.Add("force_y", 0);
             * Powerstats.Add("force_z", 0);
             */
            if (!gravityEnabled)
            {
                return(Powerstats);
            }
            charge = 200;
            float x = (vSliderValue < 0) ? vSliderValue * -1 : vSliderValue;
            float y = (hSliderValue < 0) ? hSliderValue * -1 : hSliderValue;
            float z = (zSliderValue < 0) ? zSliderValue * -1 : zSliderValue;

            Powerstats["force_x"] = x;
            Powerstats["force_y"] = y;
            Powerstats["force_z"] = z;

            total_force = x + y + z;
            total_force = (UseFullImpulse) ? total_force * UseFullImpulse_multiplier : total_force;
            total_force = (UseReservePower) ? total_force * UseReservePower_multiplier : total_force;

            charge += total_force * 12;
            charge  = (UseFullImpulse) ? charge * UseFullImpulse_multiplier : charge;
            charge  = (UseReservePower) ? charge * UseReservePower_multiplier : charge;

            if (charge > 0)
            {
                LCARS_Utilities.usePower(charge, thisVessel);
            }
            Powerstats["charge"]      = charge;
            Powerstats["total_force"] = total_force;

            return(Powerstats);
        }
예제 #6
0
        /// <summary>
        /// prevents the mother ship from loosing antigrav after beam down
        /// </summary>
        private void DontFallOnMyHead()
        {
            if (FlightGlobals.ActiveVessel.id != this.vessel.id)
            {
                // only one instance should run this code..
                return;
            }
            //////////////////////////////////
            //// START keep impulse vessels floating
            //////////////////////////////////
            foreach (KeyValuePair <string, LCARS_ImpulseVesselType> pair in man.getImpulseVesselList())
            {
                man.ImpulseVesselList[pair.Value.pid].is_active_vessel = false;

                if (pair.Value.is_gravity_enabled && !man.ImpulseVesselList[pair.Value.pid].is_active_vessel)
                {
                    Vector3 geeVector = FlightGlobals.getGeeForceAtPosition(pair.Value.v.findWorldCenterOfMass());
                    grav.CancelG2(pair.Value.v, geeVector, man);

                    if (man.ImpulseVesselList[pair.Value.pid].is_fullHalt_enabled)
                    {
                        grav.FullHalt(pair.Value.v, true);
                        man.ImpulseVesselList[pair.Value.pid].is_holdspeed_enabled = false;
                        man.ImpulseVesselList[pair.Value.pid].is_pilotMode_enabled = false;
                    }

                    // Freeze in place if requested
                    if (man.ImpulseVesselList[pair.Value.pid].is_MakeSlowToSave_enabled && man.ImpulseVesselList[pair.Value.pid].is_fullHalt_enabled)
                    {
                        grav.makeSlowToSave(pair.Value.v, true, makeStationarySpeedClamp);
                    }

                    LCARS_Utilities.CalculatePowerConsumption(Powerstats, pair.Value.v, true, false, false, 1, 1, 0, 0, 0);
                }
            }
            //////////////////////////////////
            //// END keep impulse vessels floating
            //////////////////////////////////
        }
예제 #7
0
        // //////////////////////////////////////////////////////////////////////////////////////////////////



        // //////////////////////////////////////////////////////////////////////////////////////////////////
        internal void transportKerbal_ShipToGround(ProtoCrewMember kerbalToMove)
        {
            if (kerbalToMove != null)
            {
                //UnityEngine.Debug.Log("ImpulseDrive Transporter ShipToGround Button begin " + kerbalToMove.name);
                //Kerbal kerbal = new Kerbal();
                Guid MotherShipGuid = this.CurrentMotherShip.id;

                foreach (Part p in this.CurrentMotherShip.parts)
                {
                    if (p.protoModuleCrew.Count == 0)
                    {
                        //UnityEngine.Debug.Log("nobody inside");
                        continue;
                    }


                    kerbal = null;
                    foreach (ProtoCrewMember availableKerbal in p.protoModuleCrew)
                    {
                        if (kerbalToMove.name == availableKerbal.name)
                        {
                            kerbal = availableKerbal;
                        }
                    }
                    if (kerbal == null) //Probably not necessary
                    {
                        continue;
                    }
                    //this.CurrentMotherShip.save();
                    //this.CurrentMotherShip.GoOffRails();
                    LCARS_Utilities.SetLoadDistance(fixed_height * 2, fixed_height * 2);

                    TransportMode = null;

                    FlightEVA.fetch.spawnEVA(kerbal, p, p.airlock);

                    for (int i = FlightGlobals.Vessels.Count - 1; i >= 0; i--)
                    {
                        if (kerbal.name == FlightGlobals.Vessels[i].vesselName)
                        {
                            //UnityEngine.Debug.Log("adding force");

                            Vessel v = FlightGlobals.Vessels[i];
                            //FlightGlobals.Vessels[i].distancePackThreshold = fixed_height * 2;

                            //StarTrekTricorder f = new StarTrekTricorder();

                            //FlightGlobals.Vessels[i].rootPart.AddModule("LCARS_Tricorder");
                            if (!FlightGlobals.Vessels[i].rootPart.Modules.Contains("LCARS_Tricorder"))
                            {
                                v.rootPart.AddModule("LCARS_Tricorder");
                            }

                            //FlightGlobals.Vessels[i].rootPart.Rigidbody.AddForce(FlightGlobals.Vessels[i].rootPart.transform.up * ejectionForce);
                            FlightGlobals.Vessels[i].transform.position = transporter_target.transform.position;
                            continue;
                        }
                    }
                    for (int i = FlightGlobals.Vessels.Count - 1; i >= 0; i--)
                    {
                        if (MotherShipGuid == FlightGlobals.Vessels[i].id)
                        {
                            FlightGlobals.Vessels[i].MakeActive();
                            return;
                        }
                    }
                }


                //Part.RemoveCrewmember(ProtoCrewMember)

                /*
                 * ProtoCrewMember protoCrewMember = new ProtoCrewMember();
                 * UnityEngine.Debug.Log("ImpulseDrive Transporter EVA Button 1 ");
                 *
                 * Kerbal kerbal = new Kerbal();
                 * UnityEngine.Debug.Log("ImpulseDrive Transporter EVA Button 2 ");
                 *
                 * kerbal = protoCrewMember.Spawn();
                 * UnityEngine.Debug.Log("ImpulseDrive Transporter EVA Button 3 ");
                 *
                 * FlightEVA.SpawnEVA(kerbal);
                 * UnityEngine.Debug.Log("ImpulseDrive Transporter EVA Button 4 ");
                 */

                /*
                 * KerbalEVA.GetEjectPoint(UnityEngine.Vector3, float, float, float)
                 * KerbalEVA.BoardPart(Part)
                 * KerbalEVA.BoardSeat(KerbalSeat)
                 */
                //UnityEngine.Debug.Log("ImpulseDrive Transporter ShipToGround Button end:");
            }
            float power = PT1.L2_usage;

            this.PowSys.draw(PT1.takerName, power);
        }