示例#1
0
/*************************************************************************************************************************/
        public void crash_handler(EventReport report)
        {
            List <Guid> new_vessels = new List <Guid>();

#if DEBUG
            //if (Debug_Level_1_Active)
            Log.PushStackInfo("FMRS_Core.crash_handler", "enter crash_handler (EventReport report) " + report.sender);
            if (Debug_Active)
            {
                Log.Info("crash detected");
            }
#endif

            /*if (FlightGlobals.ActiveVessel.state == Vessel.State.DEAD && !lost_root_part)
             * {
             *  Log.Info("lost root part");
             *
             *  lost_root_part = true;
             *  anz_id = FlightGlobals.ActiveVessel.id;
             * }*/
#if DEBUG
            //if (Debug_Level_1_Active)
            Log.PopStackInfo("leave crash_handler (EventReport report)");
#endif
        }
示例#2
0
 public void onReportEvent(EventReport data)
 {
     using (PooledStringBuilder sb = this.getStringBuilder())
     {
         this.EventReportHelper(sb, data);
     }
 }
 public void OnCrash(EventReport Evt)
 {
     Log.Info("OnCrash, part: " + Evt.origin.partInfo.title);
     if (VesselHelper.PartHasModuleAlias(Evt.origin, "Command") || VesselHelper.PartHasModuleAlias(Evt.origin, "AutonomousCommand"))
     {
         ModuleStateFundingDisposable m = null;
         if (Evt.origin.Modules.Contains("ModuleStateFundingDisposable"))
         {
             m = Evt.origin.Modules["ModuleStateFundingDisposable"] as ModuleStateFundingDisposable;
         }
         if (m == null)
         {
             Log.Info("OnCrash, m is null");
         }
         else
         if (m.disposable)
         {
             Log.Warning("EXPENDABLE VESSEL DESTROYED");
         }
         else
         {
             Log.Warning("VESSEL DESTROYED");
             GameInstance.ActiveReview.variables.vesselsDestroyed++;
         }
         //InstanceConf.saveInstance (GameInstance);
     }
 }
        private void OnUndock(EventReport data)
        {
#if DEBUG
            Debug.Log("AGM : Vessel Undocked.");
#endif
            RebuildPartDatabase();
        }
示例#5
0
 protected void OnLaunch(EventReport er)
 {
     if (timerType == TimerType.NEXT_LAUNCH && endTime == 0.0)
     {
         SetEndTime();
     }
 }
示例#6
0
 private void UndockCallback(EventReport report)
 {
     if (JUtil.IsActiveVessel(vessel))
     {
         UpdateMethods();
     }
 }
示例#7
0
 public void onCrash(EventReport report)
 {
     if ((report.other != null) && BUILDING_NAMES.Contains(report.other))
     {
         crashStep = true;
     }
 }
        private void OnCollide(EventReport report)
        {
            Part crashPart = report.origin;

            Log("Something crashed into something" + crashPart + "->" + report.other);
            if (crashPart.vessel.srf_velocity.magnitude < 50)
            {
                return;
            }
            Vessel asteroid = null;

            foreach (Vessel v in FlightGlobals.Vessels)
            {
                Log(v.vesselName + " " + v.vesselType + " " + v.RevealName());
                if (v.vesselName == report.other && v.vesselType == VesselType.SpaceObject)
                {
                    asteroid = v;
                    break;
                }
            }
            if (report.other != "the surface" && asteroid == null)
            {
                return;
            }
            Log("collide data " + report.msg + "-" + report.eventType + "-" + report.other + "- " + report.sender + "-" + crashPart.vessel + "-" + crashPart.vessel.srf_velocity.magnitude);
            Vessel crashVessel = crashPart.vessel;

            doImpact(crashVessel, asteroid);
        }
 protected void OnLaunch(EventReport er)
 {
     if (startCriteria == StartCriteria.NEXT_LAUNCH)
     {
         triggered = true;
     }
 }
 private void OnCrewKilled(EventReport evt)
 {
     if (recovered.ContainsKey(evt.sender))
     {
         kerbalKilledCheck = Time.frameCount + 5;
     }
 }
        /// <summary>
        /// When a stage of ANY vessel is separated, try to get the update lock of that debris
        /// </summary>
        /// <param name="data"></param>
        public void OnStageSeparation(EventReport data)
        {
            if (!VesselCommon.IsSpectating)
            {
                var debrisVessel = FlightGlobals.FindVessel(data.origin.vessel.id);
                var missionId    = data.origin.missionID;

                if (!SystemsContainer.Get <LockSystem>().LockWithPrefixExists($"debris-{missionId}"))
                {
                    SystemsContainer.Get <LockSystem>().AcquireLock($"debris-{missionId}_{debrisVessel.id}");
                    SystemsContainer.Get <VesselPositionSystem>().MessageSender.SendVesselPositionUpdate(new VesselPositionUpdate(debrisVessel));
                }
                else
                {
                    var debrisLocks = SystemsContainer.Get <LockSystem>().ServerLocks.Where(l => l.Key.StartsWith($"debris-{missionId}"))
                                      .Select(l => l.Key.Substring(l.Key.IndexOf('_') + 1)).ToArray();

                    var otherVesselsWIthSameMissionId = FlightGlobals.Vessels
                                                        .Where(v => v.Parts.Any() && v.Parts.First().missionID == missionId && v.id != debrisVessel.id)
                                                        .Select(v => v.id.ToString()).ToArray();

                    if (debrisLocks.Length == otherVesselsWIthSameMissionId.Length)
                    {
                        debrisVessel.id = new Guid(debrisLocks.Except(otherVesselsWIthSameMissionId).First());
                    }
                    else
                    {
                        SystemsContainer.Get <LockSystem>().AcquireLock($"debris-{missionId}_{debrisVessel.id}");
                        SystemsContainer.Get <VesselPositionSystem>().MessageSender.SendVesselPositionUpdate(new VesselPositionUpdate(debrisVessel));
                    }
                }
            }
        }
示例#12
0
 void CrashSplashdown(EventReport data)
 {
     for (int i = 0; i < sortedManagerClasses.Count; i++)
     {
         managerDict[sortedManagerClasses[i]].CrashSplashdown(data);
     }
 }
示例#13
0
 public virtual void CrashSplashdown(EventReport data)
 {
     if (enabled)
     {
         OnCrashSplashdown(data);
     }
 }
示例#14
0
 public virtual void Crash(EventReport data)
 {
     if (enabled)
     {
         OnCrash(data);
     }
 }
示例#15
0
/*************************************************************************************************************************/
        void crew_killed_handler(EventReport report)
        {
#if DEBUG
            //if (Debug_Level_1_Active)
            Log.PushStackInfo("FMRS_Core.crew_killed_handler", "enter crew_killed_handler(EventReport report) " + report.sender);
            if (Debug_Active)
            {
                Log.Info("crew member killed: " + report.sender + " rep los: " + last_rep_change.ToString());
            }
#endif

            if (HighLogic.CurrentGame.Mode != Game.Modes.CAREER)
            {
                return;
            }

            if (Kerbal_dropped.ContainsKey(report.sender))
            {
                killed_kerbal_str killed;
                killed.name      = report.sender;
                killed.rep       = last_rep_change;
                killed.vessel_id = Kerbal_dropped[killed.name];
                killed_kerbals.Add(killed);
#if DEBUG
                if (Debug_Active)
                {
                    Log.Info("" + report.sender + " was in dropped stage");
                }
#endif
            }
#if DEBUG
            //if (Debug_Level_1_Active)
            Log.PopStackInfo("leave crew_killed_handler(EventReport report)");
#endif
        }
示例#16
0
文件: KSTS.cs 项目: panarchist/KSTS
        // Fired for each stage on separation:
        private void onStageSeparation(EventReport data)
        {
            string stageVesselId = data.origin.vessel.id.ToString();

            Debug.Log("[KSTS] detected stage separation (" + stageVesselId + " from " + lastActiveVesselId + ")");
            stageParentDictionary.Add(stageVesselId, lastActiveVesselId);
        }
示例#17
0
 /// <summary>
 /// Sometimes the probe core gets destroyed immediately when crashing. So we need also to check the collision
 /// event. If the collision was under 10 meters above surface, we probably crashed.
 /// </summary>
 /// <param name="report">Report.</param>
 private void onCollision(EventReport report)
 {
     if (activeVessel.mainBody.GetAltitude(activeVessel.CoM) - activeVessel.terrainAltitude < 10)
     {
         eventFlags = eventFlags.Add(EventFlags.CRASHED);
     }
 }
        internal void OnCrash(EventReport data)
        {
            LaunchEvent launch = null;

            foreach (var part in data.origin.attachNodes)
            {
                if (launch != null)
                {
                    break;
                }
                launch = GetLaunchByRootPartId(data.origin.flightID.ToString());
            }


            if (launch != null)
            {
                VesselDestroyedEvent destroyed = new VesselDestroyedEvent();
                launch.AddEvent(destroyed);

                EndFlightEvent endFlight = new EndFlightEvent();
                endFlight.finalMass   = 0;
                endFlight.crewMembers = new List <string>();
                launch.AddEvent(endFlight);
            }
        }
示例#19
0
        public int SP_EventReport_INUP_CMS(EventReport x)
        {
            try
            {
                var pars = new SqlParameter[17];
                pars[0]  = new SqlParameter("@LogID", x.LogID);
                pars[1]  = new SqlParameter("@EventID", x.EventID);
                pars[2]  = new SqlParameter("@Vender", x.Vender);
                pars[3]  = new SqlParameter("@DataControl", x.DataControl);
                pars[4]  = new SqlParameter("@Pay1400", x.Pay1400);
                pars[5]  = new SqlParameter("@PayCharit", x.PayCharit);
                pars[6]  = new SqlParameter("@Note", x.Note);
                pars[7]  = new SqlParameter("@DataReviewTime", x.DataReviewTime);
                pars[8]  = new SqlParameter("@Pay14ReviewTime", x.Pay14ReviewTime);
                pars[9]  = new SqlParameter("@PayCharReviewTime", x.PayCharReviewTime);
                pars[10] = new SqlParameter("@TimeAnswer", x.TimeAnswer);
                pars[11] = new SqlParameter("@TimeSignRecord", x.TimeSignRecord);
                pars[12] = new SqlParameter("@TimehsPay", x.TimehsPay);
                pars[13] = new SqlParameter("@TimeTelcoPay", x.TimeTelcoPay);
                pars[14] = new SqlParameter("@TimePay", x.TimePay);
                pars[15] = new SqlParameter("@CreateUser", x.CreateUser);
                pars[16] = new SqlParameter("@ResponseStatus", DbType.Int32)
                {
                    Direction = ParameterDirection.Output
                };

                new DBHelper(Config.Site1400ConnectionString).ExecuteNonQuerySP("SP_EventReport_INUP_CMS", pars);
                return(Convert.ToInt32(pars[16].Value));
            }
            catch (Exception ex)
            {
                NLogLogger.LogInfo("Error: " + ex.ToString());
                return(-99);
            }
        }
        protected virtual void OnVesselAboutToBeDestroyed(EventReport report)
        {
            LoggingUtil.LogVerbose(this, "OnVesselAboutToBeDestroyed: {0}", report.msg);
            Vessel v = report.origin.vessel;

            if (v == null)
            {
                return;
            }

            // Check if we hit the ground
            if (mustImpactTerrain)
            {
                if (!(
                        report.other.ToLower().Contains(string.Intern("surface")) ||
                        report.other.ToLower().Contains(string.Intern("terrain")) ||
                        report.other.ToLower().Contains(v.mainBody.name.ToLower())))
                {
                    return;
                }
            }

            destroyedVessels[v] = true;
            CheckVessel(v);
        }
示例#21
0
 protected void OnLaunch(EventReport er)
 {
     if (startCriteria == StartCriteria.NEXT_LAUNCH && startTime == 0.0)
     {
         SetStartTime();
     }
 }
示例#22
0
 /// <summary>
 /// 处理事件记录
 /// </summary>
 public void ProcessEventRecord(EventReport record)
 {
     this.Invoke(new MethodInvoker(delegate
     {
         ProcessEventRecordImpl(record);
     }));
 }
示例#23
0
 private void OnCrewKilled(EventReport data)
 {
     if (_active)
     {
         Speech("Dramatic mode on: NOOOOOOOOOO!");
     }
 }
示例#24
0
        private void onJointBreak(EventReport data)
        {
            log.debug("onJointBreak: " + data.origin.name + " on " + data.origin.vessel.vesselName);
            Part brokenPart = data.origin;

            if (!trackedJoints.ContainsKey(brokenPart.vessel))
            {
                return;
            }
            IList <FlightJointTracker> joints = trackedJoints[brokenPart.vessel];

            for (int i = joints.Count - 1; i >= 0; i--)
            {
                if (joints[i].parts.Contains(brokenPart))
                {
                    if (!joints[i].linkCreated)
                    {
                        joints[i].Destroy();
                        trackedJoints[brokenPart.vessel].Remove(joints[i]);
                    }
                    else
                    {
                        this.StartCoroutine(DelayedBreak(joints[i], brokenPart.vessel));
                    }
                }
            }
        }
示例#25
0
        private Channel MakeParsedDigital(EventReport report, int channelIndex)
        {
            Channel        channel        = new Channel();
            Series         series         = new Series();
            Channel <bool> digitalChannel = report.AnalogSection.DigitalChannels[channelIndex];

            channel.Name                           = digitalChannel.Name;
            channel.HarmonicGroup                  = 0;
            channel.MeasurementType                = new MeasurementType();
            channel.MeasurementType.Name           = "Digital";
            channel.MeasurementCharacteristic      = new MeasurementCharacteristic();
            channel.MeasurementCharacteristic.Name = "Instantaneous";
            channel.Phase                          = new Phase();
            channel.Phase.Name                     = "None";

            series.Channel         = channel;
            series.SeriesType      = new SeriesType();
            series.SeriesType.Name = "Values";
            series.SourceIndexes   = channelIndex.ToString();

            channel.MeasurementType.Description           = channel.MeasurementType.Name;
            channel.MeasurementCharacteristic.Description = channel.MeasurementCharacteristic.Name;
            channel.Phase.Description     = "No phase";
            series.SeriesType.Description = series.SeriesType.Name;

            return(channel);
        }
示例#26
0
        public void SaveEventReport(EventReport report)
        {
            var sql        = @"DELETE FROM EventReports WHERE EventId = (SELECT EventId FROM Events WHERE Guid = @EventGuid);			
					  INSERT INTO EventReports
                            (EventId, Report)
                      VALUES (		                    
		                    (SELECT EventId FROM Events WHERE Guid = @EventGuid),
		                    @ReportXml
	                    )"    ;
            var parameters = new DynamicParameters();

            parameters.Add("@EventGuid", report.EventId.ToString());
            parameters.Add("@ReportXml", report.Report);

            using (var connection = connectionFactory.Connect()) {
                connection.Open();
                using (var transaction = connection.BeginTransaction()) {
                    try {
                        connection.Execute(sql, parameters, transaction);
                        transaction.Commit();
                    } catch (Exception ex) {
                        transaction.Rollback();
                        throw ex;
                    }
                }
            }
        }
示例#27
0
        // Fired for each stage on separation:
        private void onStageSeparation(EventReport data)
        {
            var stageVesselId = data.origin.vessel.id.ToString();

            Log.Warning("detected stage separation (" + stageVesselId + " from " + lastActiveVesselId + ")");
            stageParentDictionary.Add(stageVesselId, lastActiveVesselId);
        }
示例#28
0
 public static void LogAchievement(Achievement achievement, EventReport report)
 {
     Debug.Log("FF: ribbon achievement (report)");
     LogAchievement(achievement);
     if (report != null)
     {
         Debug.Log("  - eventType:    " + report.eventType);
         Debug.Log("  - msg:          " + report.msg);
         Debug.Log("  - other:        " + report.other);
         if (report.origin != null)
         {
             Debug.Log("  - origin:        " + report.origin.name);
             LogVessel(report.origin.vessel);
         }
         else
         {
             Debug.Log("  -origin is <null>");
         }
     }
     else
     {
         Debug.Log("  - reoprt is <null>");
     }
     Debug.Log("+ - end -");
 }
示例#29
0
        // Used to find when decouplers fire
        public void onVesselStageSeparate(EventReport report)
        {
            //Debug.Log("handling separation");

            Part part = report.origin;

            if (part.vessel.vesselType == VesselType.Debris)
            {
                foreach (PartModule module in part.Modules)
                {
                    if (module.moduleName.Contains("ModuleDecouple"))
                    {
                        ModuleDecouple md = module as ModuleDecouple;
                        ejectionForceTotal += md.ejectionForce;
                    }
                    else if (module.moduleName.Contains("ModuleAnchoredDecoupler"))
                    {
                        ModuleAnchoredDecoupler md = module as ModuleAnchoredDecoupler;
                        ejectionForceTotal += md.ejectionForce;
                    }

                    ejectionForceTotal = Mathf.Clamp(ejectionForceTotal, 0, maxDecoupleForce);
                }
            }
        }
示例#30
0
        /// <summary>
        /// When a stage of ANY vessel is separated, try to get the update lock of that debris
        /// </summary>
        /// <param name="data"></param>
        public void OnStageSeparation(EventReport data)
        {
            if (!VesselCommon.IsSpectating && !VesselCommon.ActiveVesselIsInSafetyBubble())
            {
                var debrisVessel = FlightGlobals.FindVessel(data.origin.vessel.id);
                var missionId    = data.origin.missionID;

                if (!LockSystem.Singleton.LockWithPrefixExists("debris-" + missionId))
                {
                    LockSystem.Singleton.AcquireLock("debris-" + missionId + "_" + debrisVessel.id);
                    VesselPositionSystem.Singleton.MessageSender.SendVesselPositionUpdate(new VesselPositionUpdate(debrisVessel));
                }
                else
                {
                    var debrisLocks = LockSystem.Singleton.ServerLocks.Where(l => l.Key.StartsWith("debris-" + missionId))
                                      .Select(l => l.Key.Substring(l.Key.IndexOf('_') + 1)).ToArray();

                    var otherVesselsWIthSameMissionId = FlightGlobals.Vessels
                                                        .Where(v => v.Parts.Any() && v.Parts.First().missionID == missionId && v.id != debrisVessel.id)
                                                        .Select(v => v.id.ToString()).ToArray();

                    if (debrisLocks.Length == otherVesselsWIthSameMissionId.Length)
                    {
                        debrisVessel.id = new Guid(debrisLocks.Except(otherVesselsWIthSameMissionId).First());
                    }
                    else
                    {
                        LockSystem.Singleton.AcquireLock("debris-" + missionId + "_" + debrisVessel.id);
                        VesselPositionSystem.Singleton.MessageSender.SendVesselPositionUpdate(new VesselPositionUpdate(debrisVessel));
                    }
                }
            }
        }
示例#31
0
 private void OnJointBreak(EventReport report)
 {
     if (report.origin == null || report.origin == null || report.origin != FlightGlobals.ActiveVessel)
     {
         return;
     }
     VesselModified();
 }
        private void OnCrewKilled(EventReport data)
        {
            var kerbalName = data.sender;

            // If this kerbal was used by the player at any point, add the reputation penalty.
            if (usedKerbals.Contains(kerbalName) && !deadKerbals.Contains(kerbalName))
            {
                Reputation.Instance.AddReputation(GameVariables.Instance.reputationKerbalDeath * HighLogic.CurrentGame.Parameters.Career.RepLossMultiplier, TransactionReasons.Any);
                deadKerbals.Add(kerbalName);
            }
        }
示例#33
0
        public static bool Send(EventType eventType, string wfId, ulong taskId, string comment = "")
        {
            var eventing = Discovery.GetEventingService();

            try
            {
                WFStateUpdatedEvent wfEvent = new WFStateUpdatedEvent();
                wfEvent.WFStepCode = taskId.ToString();
                wfEvent.WFRunCode = wfId;
                wfEvent.Comment = comment;

                switch (eventType)
                {
                    case EventType.TaskStarted:
                        wfEvent.WFStateUpdatedType = WFStateUpdatedTypeEnum.WFStepStarted;
                        break;
                    case EventType.TaskCompleted:
                        wfEvent.WFStateUpdatedType = WFStateUpdatedTypeEnum.WFStepFinished;
                        break;
                    case EventType.TaskFailed:
                        wfEvent.WFStateUpdatedType = WFStateUpdatedTypeEnum.WFStepError;
                        break;
                    default:
                        throw new ArgumentOutOfRangeException("eventType");
                }

                EventReport eventArgs = new EventReport()
                {
                    Source = "Execution",
                    Body =  Easis.Eventing.EventReportSerializer.SerializeObject(wfEvent, typeof(WFStateUpdatedEvent)),
                    SchemeUri = "http://escience.ifmo.ru/easis/eventing/schemes/WFStateUpdatedEvent.xsd",
                    Timestamp = DateTime.Now,
                    Topic = "WFStateUpdatedEvent"
                };

                eventing.FireEvent(eventArgs);
                eventing.Close();

                Log.Debug(String.Format("Event sent: {0}. WfId = {1}, TaskId = {2}", eventType.ToString(), wfId, taskId));
                return true;
            }
            catch (Exception e)
            {
                eventing.Abort();

                Log.Warn(String.Format("Event was NOT sent: {0}, WfId = {1}, TaskId = {2}: {3}",
                    eventType.ToString(), wfId, taskId, e.ToString()
                ));
                return false;
            }
        }
示例#34
0
        public void StageSeperate(EventReport report)
        {
            this.part = report.origin;

            decoupleDSFX.audio.Play ();

            if (internalSoundsOnly && CameraManager.Instance.currentCameraMode != CameraManager.CameraMode.IVA) {
                if(decoupleDSFX.audio.isPlaying)
                    decoupleDSFX.audio.Stop();
            }
            if (externalSoundsOnly && CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.IVA) {
                if(decoupleDSFX.audio.isPlaying)
                    decoupleDSFX.audio.Stop();
            }
        }
        protected virtual void OnVesselAboutToBeDestroyed(EventReport report)
        {
            LoggingUtil.LogVerbose(this, "OnVesselAboutToBeDestroyed: " + report.msg);
            Vessel v = report.origin.vessel;
            if (v == null)
            {
                return;
            }

            // Check if we hit the ground
            if (mustImpactTerrain)
            {
                if (!(
                    report.other.ToLower().Contains(string.Intern("surface")) ||
                    report.other.ToLower().Contains(string.Intern("terrain")) ||
                    report.other.ToLower().Contains(v.mainBody.name.ToLower())))
                {
                    return;
                }
            }

            destroyedVessels[v] = true;
            CheckVessel(v);
        }
 protected void OnLaunch(EventReport er)
 {
     if (timerType == TimerType.NEXT_LAUNCH && endTime == 0.0)
     {
         SetEndTime();
     }
 }
示例#37
0
		private void CallbackEventReportHappened (EventReport evt)
		{
			Log.Info ("CallbackEventReportHappened");
			//this.newScene = true;
			//this.sceneReady = true;
			this.specialScene = true;
			lastSceneUpdate = Time.realtimeSinceStartup;
		}
示例#38
0
 private void OnUndock(EventReport eventReport)
 {
     //Debug.Log("CLSAddon::OnUndock");
 }
示例#39
0
 // Triggered on launch
 private void on_launch(EventReport data)
 {
     KDebug.Log("on_launch", KDebug.Type.CREATE);
     this.manage_photo_corutine(Entry.Situations.LAUNCH, FlightGlobals.ActiveVessel, "");
     //this.make_screenshot("Launch");
 }
示例#40
0
 private void on_killed(EventReport report)
 {
     // If Kerbin died outside the vessel we would not be able to find that.
     KDebug.Log("on_killed " + report.sender, KDebug.Type.EVENT);
     this.add_event(Entry.Situations.KILLED, report.sender);
 }
示例#41
0
        // I'm not sure when this event happens
        private void on_crash(EventReport data)
        {
            // Happens even before Launch
            if(data.origin != null)
            {
                KDebug.Log("explosionPotential  " + data.origin.explosionPotential.ToString(), KDebug.Type.EVENT);
                KDebug.Log("flightID  " + data.origin.flightID, KDebug.Type.EVENT);
                KDebug.Log("launchID  " + data.origin.launchID, KDebug.Type.EVENT);
                KDebug.Log("missionID  " + data.origin.missionID, KDebug.Type.EVENT);
            }

            KDebug.Log("on_crash", KDebug.Type.EVENT);
            this.add_event(Entry.Situations.CRASH,"");
        }
 private void CheckAchievementsForVessel(Vessel vessel, EventReport report=null)
 {
    // just delegate
    CheckAchievementsForVessel(new VesselState(vessel), report);
 }
 private void OnUndock(EventReport data)
 {
     #if DEBUG
     Debug.Log("AGM : Vessel Undocked.");
     #endif
     RebuildPartDatabase();
 }
示例#44
0
 private void OnStageSeparation(EventReport eventReport)
 {
     //Debug.Log("CLSAddon::OnStageSeparation");
 }
示例#45
0
 private void OnOverHeat(EventReport data)
 {
     if (_active)
     {
         Speech("Warning Overheat detected!");
     }
 }
示例#46
0
文件: KCT_Events.cs 项目: ntwest/KCT
 public void vesselLaunchEvent(EventReport e)
 {
     if (!KCT_GameStates.settings.enabledForSave) return;
     if (KCT_GameStates.flightSimulated && KCT_GameStates.settings.SimulationTimeLimit > 0)
     {
         KCT_GameStates.simulationEndTime = Planetarium.GetUniversalTime() + (KCT_GameStates.settings.SimulationTimeLimit);
     }
 }
示例#47
0
 public void OnCrashSplashdown(EventReport Evt)
 {
     if (VesselHelper.PartHasModuleAlias(Evt.origin, "Command") || VesselHelper.PartHasModuleAlias(Evt.origin, "AutonomousCommand")) {
     Debug.LogWarning ("VESSEL DESTROYED");
     GameInstance.ActiveReview.vesselsDestroyed++;
     //InstanceConf.saveInstance (GameInstance);
       }
 }
示例#48
0
 private void OnLaunch(EventReport data)
 {
     if (_active)
     {
         Speech("And " + FlightGlobals.ActiveVessel.GetName() + "starts his mission! Good luck brave Kerbals!");
     }
 }
        private static void onVesselLaunch(EventReport e)
        {
            Vessel v = FlightGlobals.ActiveVessel;

            if (v == null)
                return;

            IEnumerable<KeyValuePair<Guid, Notes_CheckListItem>> notes = launchNotes.Where(n => n.Value.Root.RootVessel.id == v.id);
            for (int i = 0; i < notes.Count(); i++)
            {
                Notes_CheckListItem n = notes.ElementAt(i).Value;

                if (n == null)
                    continue;

                n.setComplete();
            }
        }
示例#50
0
 void onCrewKilled(EventReport eventReport)
 {
     resetValues();
     gAudio.stopAllSounds();
 }
示例#51
0
 public void OnCrashSplashdown(EventReport Evt)
 {
     Debug.LogWarning ("VESSEL DESTROYED");
       GameInstance.ActiveReview.vesselsDestroyed++;
 }
示例#52
0
        public void onVesselAboutToBeDestroyed(EventReport report) 
        {
            Debug.Log("[KSP Interstellar] Handling Impactor");

            ConfigNode config;
            ConfigNode science_node;

            Vessel vessel = report.origin.vessel;
            float vesselMass;
            int science_experiment_number = 0;

            string vessel_impact_node_string = string.Concat("IMPACT_", vessel.id.ToString());
            string vessel_seismic_node_string = string.Concat("SEISMIC_SCIENCE_", vessel.mainBody.name.ToUpper());

            // Do nothing if we don't have a vessel.  This seems improbable, but who knows.
            if (vessel == null) 
            {
                Debug.Log("[KSP Interstellar] Impactor: Ignored because the vessel is undefined.");
                return;
            }

            // Do nothing if we have recorded an impact less than 10 physics updates ago.  This probably means this call
            // is a duplicate of a previous call.
            if (Planetarium.GetUniversalTime() - this.lastImpactTime < TimeWarp.fixedDeltaTime * 10f) 
            {
                Debug.Log("[KSP Interstellar] Impactor: Ignored because we've just recorded an impact.");
                return;
            }

            // Do nothing if we are a debris item less than ten physics-updates old.  That probably means we were
            // generated by a recently-recorded impact.
            if (vessel.vesselType == VesselType.Debris && vessel.missionTime < Time.fixedDeltaTime * 10f) 
            {
                Debug.Log("[KSP Interstellar] Impactor: Ignored due to vessel being brand-new debris.");
                return;
            }

            vesselMass = vessel.GetTotalMass();

            // Do nothing if we aren't very near the terrain.  Note that using heightFromTerrain probably allows
            // impactors against the ocean floor... good luck.
            float vesselDimension = vessel.MOI.magnitude / vesselMass;
            if (vessel.heightFromSurface > Mathf.Max(vesselDimension, 0.75f)) 
            {
                Debug.Log("[KSP Interstellar] Impactor: Ignored due to vessel altitude being too high.");
                return;
            }

            // Do nothing if we aren't impacting the surface.
            if (!(
                report.other.ToLower().Contains(string.Intern("surface")) ||
                report.other.ToLower().Contains(string.Intern("terrain")) ||
                report.other.ToLower().Contains(vessel.mainBody.name.ToLower())
            )) 
            {
                Debug.Log("[KSP Interstellar] Impactor: Ignored due to not impacting the surface.");
                return;
            }

            /* 
             * NOTE: This is a deviation from current KSPI behavior.  KSPI currently registers an impact over 40 m/s
             * regardless of its mass; this means that trivially light impactors (single instruments, even) could
             * trigger the experiment.
             * 
             * The guard below requires that the impactor have at least as much vertical impact energy as a 1 Mg
             * object traveling at 40 m/s.  This means that nearly-tangential impacts or very light impactors will need
             * to be much faster, but that heavier impactors may be slower.
             * 
             * */
            if ((Math.Pow(vessel.verticalSpeed, 2d) * vesselMass / 2d < 800d) && vessel.verticalSpeed > 20d) 
            {
                Debug.Log("[KSP Interstellar] Impactor: Ignored due to vessel imparting too little impact energy.");
                return;
            }

            config = PluginHelper.getPluginSaveFile();
            if (config.HasNode(vessel_seismic_node_string)) 
            {
                science_node = config.GetNode(vessel_seismic_node_string);
                science_experiment_number = science_node.nodes.Count;

                if (science_node.HasNode(vessel_impact_node_string)) 
                {
                    Debug.Log("[KSP Interstellar] Impactor: Ignored because this vessel's impact has already been recorded.");
                    return;
                }
            } 
            else 
            {
                science_node = config.AddNode(vessel_seismic_node_string);
                science_node.AddValue("name", "interstellarseismicarchive");
            }

            int body = vessel.mainBody.flightGlobalsIndex;
            Vector3d net_vector = Vector3d.zero;
            bool first = true;
            double net_science = 0;
            double initial_science = 0;

            foreach (Vessel conf_vess in FlightGlobals.Vessels) 
            {
                String vessel_probe_node_string = string.Concat("VESSEL_SEISMIC_PROBE_", conf_vess.id.ToString());

                if (config.HasNode(vessel_probe_node_string)) 
                {
                    ConfigNode probe_node = config.GetNode(vessel_probe_node_string);

                    // If the seismometer is inactive, skip it.
                    bool is_active = false;
                    if (probe_node.HasValue("is_active")) 
                    {
                        bool.TryParse(probe_node.GetValue("is_active"), out is_active);
                        if (!is_active) continue;
                    }

                    // If the seismometer is on another planet, skip it.
                    int planet = -1;
                    if (probe_node.HasValue("celestial_body")) 
                    {
                        int.TryParse(probe_node.GetValue("celestial_body"), out planet);
                        if (planet != body) continue;
                    }

                    // do sciency stuff
                    Vector3d surface_vector = (conf_vess.transform.position - FlightGlobals.Bodies[body].transform.position);
                    surface_vector = surface_vector.normalized;
                    if (first) 
                    {
                        first = false;
                        net_vector = surface_vector;
                        net_science = 50 * PluginHelper.getScienceMultiplier(vessel); //PluginHelper.getImpactorScienceMultiplier(body);
                        initial_science = net_science;
                    } 
                    else 
                    {
                        net_science += (1.0 - Vector3d.Dot(surface_vector, net_vector.normalized)) * 50 * PluginHelper.getScienceMultiplier(vessel);  //PluginHelper.getImpactorScienceMultiplier(body);
                        net_vector = net_vector + surface_vector;
                    }
                }
            }

            net_science = Math.Min(net_science, initial_science * 3.5); // no more than 3.5x boost to science by using multiple detectors
            if (net_science > 0 && !double.IsInfinity(net_science) && !double.IsNaN(net_science)) 
            {

                double science_coeff = -science_experiment_number / 2.0;
                net_science = net_science * Math.Exp(science_coeff);
                ScreenMessages.PostScreenMessage("Impact Recorded, science report can now be accessed from one of your accelerometers deployed on this body.", 5f, ScreenMessageStyle.UPPER_CENTER);
                this.lastImpactTime = Planetarium.GetUniversalTime();
                Debug.Log("[KSP Interstellar] Impactor: Impact registered!");

                ConfigNode impact_node = new ConfigNode(vessel_impact_node_string);
                impact_node.AddValue(string.Intern("transmitted"), bool.FalseString);
                impact_node.AddValue(string.Intern("vesselname"), vessel.vesselName);
                impact_node.AddValue(string.Intern("science"), net_science);
                impact_node.AddValue(string.Intern("number"), (science_experiment_number + 1).ToString("0"));
                science_node.AddNode(impact_node);

                config.Save(PluginHelper.PluginSaveFilePath);
            }
        }
示例#53
0
    private void OnUndock(EventReport eventReport)
    {
      //Debug.Log("[ShipManifest]:  ShipManifestAddon.OnUndock");
      try
      {

      }
      catch (Exception ex)
      {
        Utilities.LogMessage("Error in:  ShipManifestAddon.OnUndock.  " + ex.ToString(), "Error", true);
      }
    }
 private void UndockCallback(EventReport report)
 {
     if (JUtil.IsActiveVessel(vessel))
     {
         RasterPropMonitorComputer rpmComp = RasterPropMonitorComputer.Instantiate(internalProp, true);
         UpdateMethods(rpmComp);
     }
 }
示例#55
0
 // Events
 public void OnCrewKilled(EventReport Evt)
 {
     Debug.LogWarning ("CREW KILLED");
       GameInstance.ActiveReview.kerbalDeaths++;
 }
 private void OnUndock(EventReport data)
 {
     SetupRootModule();
 }
 private void OnCrewKilled(EventReport evt)
 {
     if (recovered.ContainsKey(evt.sender))
     {
         kerbalKilledCheck = Time.frameCount + 5;
     }
 }
 private void OnCrewKilled(EventReport evt)
 {
     if (recovered.ContainsKey(evt.sender))
     {
         MessageSystem.Instance.AddMessage(new MessageSystem.Message("Contract failed", evt.sender + " has been killed!",
             MessageSystemButton.MessageButtonColor.RED, MessageSystemButton.ButtonIcons.MESSAGE));
         SetState(ParameterState.Failed);
     }
 }
 protected void OnLaunch(EventReport er)
 {
     Debug.Log("OnLaunch");
     if (startCriteria == StartCriteria.NEXT_LAUNCH)
     {
         triggered = true;
     }
 }
 private void CheckAchievementsForVessel(VesselState currentVesselState, EventReport report = null)
 {
    Log.Detail("EventObserver:: checkArchivements for vessel state");
    Stopwatch sw = new Stopwatch();
    sw.Start();
    //
    CheckAchievementsForVessel(previousVesselState, currentVesselState, report);
    //
    sw.Stop();
    this.previousVesselState = currentVesselState;
    Log.Detail("EventObserver:: checkArchivements done in "+sw.ElapsedMilliseconds+" ms");
 }