예제 #1
0
        public void Start()
        {
            alarmutils = new AlarmUtils(settingsPlan.KACEnable);

            if (settingsPlan.KACEnable)
            {
                KACWrapper.InitKACWrapper();
            }

            if (HighLogic.LoadedScene == GameScenes.EDITOR)
            {
                CreateTopBarButtons();

                GameEvents.onEditorStarted.Add(OnEditorStarted);
            }

            // remove alarm
            else if (HighLogic.LoadedScene == GameScenes.FLIGHT)
            {
                string vesselName = Utils.GetVesselName();

                if (settingsPlan.Enable && settingsPlan.AutoRemoveFinishedTimers)
                {
                    var alarm = alarmutils.GetAlarm(Utils.AlarmTitle(vesselName));

                    if (alarm?.Finished() ?? false)
                    {
                        bool success = alarmutils.RemoveAlarm(alarm.ID);
                    }
                }
                Destroy(this); return;
            }
        }
예제 #2
0
        public void Start()
        {
            //Log("Start1======");

            //var enumerator = AlarmClockScenario.Instance.alarms.GetListEnumerator();
            //while (enumerator.MoveNext())
            //{
            //    Log("id: {0}, {1}, ut: {2:F0}, tta: {3:F0}, te: {4:F0}",
            //        enumerator.Current.Id, enumerator.Current.title, enumerator.Current.ut, enumerator.Current.TimeToAlarm,
            //    (enumerator.Current as AlarmTypeRaw).timeEntry);
            //}

            //Log("Start2=======");

            //var als = ACAUtils.GetSortedPlanningActiveAlarms();
            //foreach (var a in als)
            //{
            //    Log("id: {0}, {1}, ut: {2:F0}, tta: {3:F0}, te: {4:F0}",
            //        a.Id, a.title, a.ut, a.TimeToAlarm,
            //    a.timeEntry);
            //}
            //Log("Start3=======");

            KVASSPlanSettings settingsPlan = HighLogic.CurrentGame.Parameters.CustomParams <KVASSPlanSettings>();

            if (settingsPlan.Enable && settingsPlan.Queue)
            {
                if (settingsPlan.KACEnable)
                {
                    KACWrapper.InitKACWrapper();

                    if (KACWrapper.APIReady)
                    {
                        KACWrapper.KAC.onAlarmStateChanged += KAC_onAlarmStateChanged;
                    }
                }
                else
                {
                    //GameEvents.onAlarmAdded.Add(OnAlarmAdded);
                    GameEvents.onAlarmRemoving.Add(OnAlarmRemoving);
                }
            }
            else
            {
                Destroy(gameObject);
            }
        }