Example #1
0
        public void Awake()
        {
            if (!(HighLogic.CurrentGame.Mode == Game.Modes.CAREER ||
                  HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX ||
                  HighLogic.CurrentGame.Mode == Game.Modes.SANDBOX))
            {
                Log(HighLogic.CurrentGame.Mode + " mode is not supported.");
                Destroy(gameObject); return;
            }

            settingsSim   = HighLogic.CurrentGame.Parameters.CustomParams <KVASSSimSettings>();
            settingsPlan  = HighLogic.CurrentGame.Parameters.CustomParams <KVASSPlanSettings>();
            settingsPlan2 = HighLogic.CurrentGame.Parameters.CustomParams <KVASSPlanSettings2>();
            //  settingsGame = HighLogic.CurrentGame.Parameters.Difficulty;
        }
Example #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);
            }
        }
Example #3
0
        /// <summary>
        /// Create Alarms on GUI and write ID into alarm
        /// </summary>
        public void CreateonGUI()
        {
            KVASSPlanSettings settings = HighLogic.CurrentGame.Parameters.CustomParams <KVASSPlanSettings>();

            if (settings.KACEnable)
            {
                if (KACWrapper.APIReady)
                {
                    ID = KACWrapper.KAC.CreateAlarm(
                        KACWrapper.KACAPI.AlarmTypeEnum.Raw,
                        Title,
                        UT);


                    if (!String.IsNullOrEmpty(ID))
                    {
                        // a.Remaining doesn't work in the VAB/SPH

                        var alarm = KACWrapper.KAC.Alarms.First(z => z.ID == ID);
                        alarm.Notes       = Description;
                        alarm.AlarmMargin = 0;

                        if (Warp == WarpType.KillWarp)
                        {
                            alarm.AlarmAction = KACWrapper.KACAPI.AlarmActionEnum.KillWarpOnly;
                        }
                        else
                        {
                            alarm.AlarmAction = KACWrapper.KACAPI.AlarmActionEnum.DoNothing;
                        }
                    }
                }
            }
            else
            {
                AlarmTypeRaw alarm = new AlarmTypeRaw();
                alarm.title       = Title;
                alarm.ut          = UT;
                alarm.description = Description;
                alarm.timeEntry   = Time;

                //Log(String.Format("CreateonGUI ACA title:{0}, UT:{1:F0}, timeEntry:{2:F0}", alarm.title, alarm.ut, alarm.timeEntry));

                if (settings.KillTimeWarp)
                {
                    alarm.actions.warp = AlarmActions.WarpEnum.KillWarp;
                }
                else
                {
                    alarm.actions.warp = AlarmActions.WarpEnum.DoNothing;
                }

                alarm.actions.message = AlarmActions.MessageEnum.No;

                if (alarm.CanSetAlarm(KSP.UI.AlarmUIDisplayMode.Add))
                {
                    AlarmClockScenario.AddAlarm(alarm);
                    alarm.OnScenarioUpdate();
                    alarm.UIInputPanelUpdate();

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

                        if (enumerator.Current.ut == UT && enumerator.Current.title == Title)
                        {
                            ID = enumerator.Current.Id.ToString();
                        }
                    }
                }
            }
        }