Example #1
0
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);

            if (Settings == null)
            {
                Settings = new CrewHandlerSettings();
                foreach (ConfigNode stg in GameDatabase.Instance.GetConfigNodes("CREWHANDLERSETTINGS"))
                {
                    Settings.Load(stg);
                }
            }

            KerbalRetireTimes.Clear();
            ConfigNode n = node.GetNode("RETIRETIMES");

            if (n != null)
            {
                _isFirstLoad = false;
                foreach (ConfigNode.Value v in n.values)
                {
                    KerbalRetireTimes[v.name] = double.Parse(v.value);
                }
            }

            KerbalRetireIncreases.Clear();
            n = node.GetNode("RETIREINCREASES");
            if (n != null)
            {
                foreach (ConfigNode.Value v in n.values)
                {
                    KerbalRetireIncreases[v.name] = double.Parse(v.value);
                }
            }

            _retirees.Clear();
            n = node.GetNode("RETIREES");
            if (n != null)
            {
                foreach (ConfigNode.Value v in n.values)
                {
                    _retirees.Add(v.value);
                }
            }

            _expireTimes.Clear();
            n = node.GetNode("EXPIRATIONS");
            if (n != null)
            {
                foreach (ConfigNode eN in n.nodes)
                {
                    _expireTimes.Add(new TrainingExpiration(eN));
                }
            }

            ConfigNode FSData = node.GetNode("FlightSchoolData");

            if (FSData != null)
            {
                //load all the active courses
                ActiveCourses.Clear();
                foreach (ConfigNode courseNode in FSData.GetNodes("ACTIVE_COURSE"))
                {
                    try
                    {
                        ActiveCourses.Add(new ActiveCourse(courseNode));
                    }
                    catch (Exception ex)
                    {
                        Debug.LogException(ex);
                    }
                }
            }

            TrainingDatabase.EnsureInitialized();
            KACWrapper.InitKACWrapper();
        }