public void FormationFlight(Vessel thisVessel, bool bool_FormationMode, ImpulseVessel_manager man)
        {
            if (bool_FormationMode)
            {
                //thisVessel.GetTransform();
                ////////////////////////////
                // BEGINN THIS IS WORKING but cheaty!!!!!
                ////////////////////////////
                //direction in which the ship currently points:
                //UnityEngine.Debug.Log("ImpulseDrive: FormationFlight  begin ");
                Vessel leader_v = FlightGlobals.ActiveVessel;
                //UnityEngine.Debug.Log("ImpulseDrive: FormationFlight  1 ");
                Vector3 LeaderHeading = (Vector3)leader_v.transform.forward;

                //UnityEngine.Debug.Log("ImpulseDrive: FormationFlight  2 leader_v.id=" + leader_v.id + "  thisVessel.id=" + thisVessel.id + " bool_FormationMode=" + bool_FormationMode);

                Quaternion newRotation = new Quaternion();
                //UnityEngine.Debug.Log("ImpulseDrive: FormationFlight  3 ");
                newRotation.SetLookRotation(LeaderHeading, leader_v.transform.up);
                //UnityEngine.Debug.Log("ImpulseDrive: FormationFlight  4 ");
                thisVessel.SetRotation(newRotation);
                //UnityEngine.Debug.Log("ImpulseDrive: FormationFlight  done ");
                ////////////////////////////
                // END THIS IS WORKING but cheaty!!!!!
                ////////////////////////////



                /*
                 * int scalingFactor = 1;
                 * //Transform rotateTo;
                 * //Transform rotateFrom;
                 * Vessel leader_v = man.GetFormationLeaderVessel();
                 * Vector3 LeaderHeading = (Vector3)leader_v.transform.up;
                 * Quaternion LeaderHeadingRotation = new Quaternion();
                 * LeaderHeadingRotation = Quaternion.LookRotation(LeaderHeading);
                 *
                 * Vector3 heading = (Vector3)thisVessel.transform.right;
                 * Quaternion HeadingRotation = new Quaternion();
                 * HeadingRotation = Quaternion.LookRotation(heading);
                 *
                 *  //thisVessel.transform.rotation = Quaternion.Slerp(HeadingRotation, LeaderHeadingRotation, Time.deltaTime / scalingFactor);
                 *  thisVessel.SetRotation(Quaternion.Slerp(HeadingRotation, LeaderHeadingRotation, Time.deltaTime / scalingFactor));
                 *
                 * //Quaternion newRotation = new Quaternion();
                 * //float step = 1.0F * Time.deltaTime;
                 *  //newRotation = Quaternion.RotateTowards(HeadingRotation, LeaderHeadingRotation, step);
                 *  //thisVessel.SetRotation(newRotation);
                 *
                 * if(thisVessel.Landed == false) {
                 * }
                 */
            }
        }
 /// <summary>
 /// Takes a Vessel and a GeeVector as argument and tries to cancel out the gee with counter forces
 /// problem - seems to be called several times per vessel somehow..
 /// </summary>
 public void CancelG2(Vessel thisVessel, Vector3d thisGeeVector, ImpulseVessel_manager man)
 {
     if (thisVessel.IsControllable)
     {
         var antiGeeVector = thisGeeVector * -1;
         //var antiGeeVector = thisGeeVector * -1 / man.Count();
         //UnityEngine.Debug.Log("ImpulseDrive: CancelG2  thisVessel.id=" + thisVessel.id + ": gravityEnabledShips.Count=" + man.Count());
         foreach (var vesselPart in thisVessel.parts.Where(p => p.rigidbody != null))
         {
             //UnityEngine.Debug.Log("ImpulseDrive: CancelG2 thisVessel.vesselName=" + thisVessel.vesselName + " vesselPart=" + vesselPart + " antiGeeVector=" + antiGeeVector.ToString());
             vesselPart.rigidbody.AddForce(antiGeeVector, ForceMode.Acceleration);
         }
     }
 }
Ejemplo n.º 3
0
 public override void OnAwake()
 {
     man  = ImpulseVessel_manager.Instance;
     grav = new GravityTools();
 }
Ejemplo n.º 4
0
        public override void OnStart(StartState state)
        {
            man  = ImpulseVessel_manager.Instance;
            grav = new GravityTools();
            try
            {
                //Debris
                GameObject go_Transporter = new GameObject("emitter_Transporter");
                emitter_Transporter = go_Transporter.AddComponent("EllipsoidParticleEmitter") as ParticleEmitter;
                ParticleAnimator animator_debris = go_Transporter.AddComponent <ParticleAnimator>();
                go_Transporter.AddComponent <ParticleRenderer>();
                (go_Transporter.renderer as ParticleRenderer).uvAnimationXTile = 7;
                (go_Transporter.renderer as ParticleRenderer).uvAnimationYTile = 7;
                Material mat = new Material(Shader.Find("Particles/Additive"));
                mat.mainTexture = GameDatabase.Instance.GetTexture("SciFi/StarTrekImpulseDrive/particles/transporter_7x7_optimized2", false);
                go_Transporter.renderer.material       = mat;
                emitter_Transporter.emit               = false;
                emitter_Transporter.minSize            = 10f; //radius * 0.05f;  //4    3 +
                emitter_Transporter.maxSize            = 10f; //radius * 0.1f;  //8
                emitter_Transporter.minEnergy          = 1;
                emitter_Transporter.maxEnergy          = 2;
                emitter_Transporter.rndVelocity        = Vector3.zero; //1.6f * radius; //150
                emitter_Transporter.useWorldSpace      = false;
                emitter_Transporter.rndAngularVelocity = 0;
                animator_debris.rndForce               = new Vector3(0, 0, 0);
                animator_debris.sizeGrow               = 0f;

                emitter_Transporter.transform.position = FlightGlobals.ActiveVessel.transform.position;
                emitter_Transporter.Emit(1);



                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;
                if (TransporterSound != null && TransporterSound.audio != null)
                {
                    TransporterSound.audio.time = 0;
                    float soundVolume = GameSettings.SHIP_VOLUME * TransporterSoundVolume;
                    TransporterSound.audio.enabled = true;
                    TransporterSound.audio.volume  = soundVolume;
                }
            }
            catch (Exception ex)
            {
                Debug.LogError("TransporterSound Error : " + ex.Message);
            }

            if (TS == null)
            {
                TS = new LCARS_TransporterSystem();
            }

            try
            {
                ConfigNode newMSE = null;
                newMSE = new ConfigNode("MODULE");
                newMSE.AddValue("name", "ModuleScienceExperiment");
                newMSE.AddValue("experimentID", "TricorderAwayTeamStatus");
                newMSE.AddValue("experimentActionName", "AwayTeam's Log");
                newMSE.AddValue("resetActionName", "Delete Log");
                newMSE.AddValue("useStaging", "False");
                newMSE.AddValue("useActionGroups", "True");
                newMSE.AddValue("hideUIwhenUnavailable", "True");
                newMSE.AddValue("resettable", "True");
                newMSE.AddValue("xmitDataScalar", "10.0");
                newMSE.AddValue("FxModules", "0");
                this.vessel.rootPart.AddModule(newMSE);

                newMSE = new ConfigNode("MODULE");
                newMSE.AddValue("name", "ModuleScienceExperiment");
                newMSE.AddValue("experimentID", "TricorderAwayTeamSurfacescan");
                newMSE.AddValue("experimentActionName", "Surface Scan");
                newMSE.AddValue("resetActionName", "Delete Surface Scan");
                newMSE.AddValue("useStaging", "False");
                newMSE.AddValue("useActionGroups", "True");
                newMSE.AddValue("hideUIwhenUnavailable", "True");
                newMSE.AddValue("resettable", "True");
                newMSE.AddValue("xmitDataScalar", "10.0");
                newMSE.AddValue("FxModules", "0");
                this.vessel.rootPart.AddModule(newMSE);

                newMSE = new ConfigNode("MODULE");
                newMSE.AddValue("name", "ModuleScienceExperiment");
                newMSE.AddValue("experimentID", "TricorderAwayTeamAtmosphereScan");
                newMSE.AddValue("experimentActionName", "Atmosphere Scan");
                newMSE.AddValue("resetActionName", "Delete Atmosphere Scan");
                newMSE.AddValue("useStaging", "False");
                newMSE.AddValue("useActionGroups", "True");
                newMSE.AddValue("hideUIwhenUnavailable", "True");
                newMSE.AddValue("resettable", "True");
                newMSE.AddValue("xmitDataScalar", "10.0");
                newMSE.AddValue("FxModules", "0");
                this.vessel.rootPart.AddModule(newMSE);

                newMSE = new ConfigNode("MODULE");
                newMSE.AddValue("name", "ModuleScienceExperiment");
                newMSE.AddValue("experimentID", "TricorderAwayTeamLiquidScan");
                newMSE.AddValue("experimentActionName", "Liquid Scan");
                newMSE.AddValue("resetActionName", "Delete Liquid Scan");
                newMSE.AddValue("useStaging", "False");
                newMSE.AddValue("useActionGroups", "True");
                newMSE.AddValue("hideUIwhenUnavailable", "True");
                newMSE.AddValue("resettable", "True");
                newMSE.AddValue("xmitDataScalar", "10.0");
                newMSE.AddValue("FxModules", "0");
                this.vessel.rootPart.AddModule(newMSE);


                ModuleScienceExperimentList = new Dictionary <string, ModuleScienceExperiment>()
                {
                };
                foreach (PartModule PM in this.vessel.rootPart.Modules)
                {
                    if (PM.moduleName == "ModuleScienceExperiment")
                    {
                        ModuleScienceExperiment foo = PM as ModuleScienceExperiment;
                        ModuleScienceExperimentList.Add(foo.experimentID, foo);
                    }
                    //Debug.LogError("ModuleScienceExperiment rootPart.Module=" + PM.name);
                }

                /*
                 * MODULE
                 *  {
                 *          name = ModuleScienceExperiment
                 *          experimentID = enterprisestatus
                 *
                 *          experimentActionName = Captain's Log
                 *          resetActionName = Delete Log
                 *
                 *          useStaging = False
                 *          useActionGroups = True
                 *          hideUIwhenUnavailable = True
                 *          resettable = True
                 *
                 *          xmitDataScalar = 10.0
                 *
                 *          FxModules = 0
                 *  }
                 *
                 *  MODULE
                 *  {
                 *          name = ModuleScienceContainer
                 *
                 *          reviewActionName = Review Mission Data
                 *          storeActionName = Log Data
                 *          evaOnlyStorage = False
                 *          storageRange = 1000.0
                 *  }
                 *
                 *  MODULE
                 *  {
                 *          name = ModuleDataTransmitter
                 *
                 *          packetInterval = 0.01
                 *          packetSize = 0.5
                 *
                 *          packetResourceCost = 1000.0
                 *          requiredResource = ElectricCharge
                 *
                 *          DeployFxModules = 0
                 *  }
                 */
            }
            catch (Exception ex)
            {
                Debug.LogError("ModuleScienceExperiment Error : " + ex.Message);
            }
        }