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();
        }
        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);
        }
        protected override bool VesselMeetsCondition(Vessel vessel)
        {
            var states = RadiationFieldTracker.RadiationFieldStates(vessel);

            if (states == null)
            {
                return(false);
            }

            var body  = targetBody != null ? targetBody : vessel.mainBody;
            var state = states.Find(s => s.bodyIndex == body.flightGlobalsIndex);

            if (state == null)
            {
                return(false);
            }

            bool in_field = InField(field, state);

            if (stay_in && !in_field)
            {
                return(false);
            }
            if (stay_out && in_field)
            {
                return(false);
            }
            if (stay_in || stay_out)
            {
                return(true);
            }

            // Utils.LogDebug($"VesselRadiationFieldParameter {field} / {vessel}: in_field { in_field} currently {currently_in_field} crossed {crossed_count}");

            if (in_field != currently_in_field)
            {
                crossed_count++;
                GetTitle();
            }
            currently_in_field = in_field;

            if (crossings_min >= 0 && crossed_count < crossings_min)
            {
                return(false);
            }
            if (crossings_max >= 0 && crossed_count > crossings_max)
            {
                return(false);
            }
            return(true);
        }
 protected override void OnUnregister()
 {
     base.OnUnregister();
     RadiationFieldTracker.RemoveListener(RunCheck);
 }
 protected override void OnRegister()
 {
     base.OnRegister();
     RadiationFieldTracker.AddListener(RunCheck);
 }