public override void OnLoad(ConfigNode node)
        {
            KerbalismContractsMain.fieldVisibilityInitialized = false;
            KerbalismContractsMain.KerbalismInitialized       = false;

            bodyData.Clear();
            EvaluationContext.Clear();

            if (node.HasNode("BodyData"))
            {
                foreach (var body_node in node.GetNode("BodyData").GetNodes())
                {
                    var bd = new GlobalRadiationFieldStatus(body_node);
                    if (bd != null && bd.index >= 0)
                    {
                        bodyData.Add(bd.index, bd);
                    }
                }
            }

            RadiationFieldTracker.Load(node);
            ExperimentStateTracker.Load(node);
            EquipmentStates.Load(node);
            Imaging.ClearImagers();
        }
        internal override SubRequirementState VesselMeetsCondition(Vessel vessel, EvaluationContext context)
        {
            ExperimentRunningState state = new ExperimentRunningState();

            state.experimentState = ExperimentStateTracker.GetValue(vessel.id, experimentId);
            state.requirementMet  = state.experimentState == ExperimentState.running;
            return(state);
        }
        protected override bool VesselMeetsCondition(Vessel vessel)
        {
            if (!ExperimentStateTracker.HasValue(vessel.id, experimentId))
            {
                return(false);
            }

            return(ExperimentStateTracker.GetValue(vessel.id, experimentId) == ExperimentState.running);
        }
        public override void OnSave(ConfigNode node)
        {
            var bodies_node = node.AddNode("BodyData");

            foreach (var p in bodyData)
            {
                p.Value.Save(bodies_node.AddNode("GlobalBodyData"));
            }

            RadiationFieldTracker.Save(node);
            ExperimentStateTracker.Save(node);
            EquipmentState.Save(node);
        }
        public void Start()
        {
            if (firstStart)
            {
                firstStart = false;

                // this needs to be called to initialize all derivates of KsmPartModule in this plugin
                ModuleData.Init(Assembly.GetExecutingAssembly());

                Configuration.Load();

                API.OnRadiationFieldChanged.Add(RadiationFieldTracker.Update);
                API.OnExperimentStateChanged.Add(ExperimentStateTracker.Update);
                GameEvents.onVesselChange.Add((vessel) => { ExperimentStateTracker.Remove(vessel.id); });
            }
        }
 protected override void OnUnregister()
 {
     base.OnUnregister();
     ExperimentStateTracker.RemoveListener(RunCheck);
 }
 protected override void OnRegister()
 {
     base.OnRegister();
     ExperimentStateTracker.AddListener(RunCheck);
 }
 internal override bool CouldBeCandiate(Vessel vessel, EvaluationContext context)
 {
     return(ExperimentStateTracker.HasValue(vessel.id, experimentId));
 }