internal static void Update(Vessel vessel, bool inner_belt, bool outer_belt, bool magnetosphere)
        {
            if (!Utils.IsVessel(vessel))
            {
                return;
            }

            if (!states.ContainsKey(vessel.id))
            {
                states.Add(vessel.id, new List <VesselRadiationFieldStatus>());
            }

            // also update the global radiation field status
            GlobalRadiationFieldStatus bd = KerbalismContracts.Instance.BodyData(vessel.mainBody);

            var statesForVessel = states[vessel.id];
            VesselRadiationFieldStatus state = statesForVessel.Find(s => s.bodyIndex == vessel.mainBody.flightGlobalsIndex);

            if (state == null)
            {
                statesForVessel.Add(new VesselRadiationFieldStatus(vessel.mainBody, inner_belt, outer_belt, magnetosphere));
            }
            else
            {
                if (state.inner_belt != inner_belt)
                {
                    state.inner_crossings++;
                    bd.inner_crossings++;
                }

                if (state.outer_belt != outer_belt)
                {
                    state.outer_crossings++;
                    bd.outer_crossings++;
                }

                if (state.magnetosphere != magnetosphere)
                {
                    state.magneto_crossings++;
                    bd.magneto_crossings++;
                }

                state.inner_belt    = inner_belt;
                state.outer_belt    = outer_belt;
                state.magnetosphere = magnetosphere;
            }

            for (int i = listeners.Count - 1; i >= 0; i--)
            {
                listeners[i](vessel, state);
            }
        }
        internal static bool InField(RadiationFieldType f, VesselRadiationFieldStatus state)
        {
            switch (f)
            {
            case RadiationFieldType.INNER_BELT: return(state.inner_belt);

            case RadiationFieldType.OUTER_BELT: return(state.outer_belt);

            case RadiationFieldType.MAGNETOPAUSE: return(state.magnetosphere);

            case RadiationFieldType.ANY:
                return(state.inner_belt || state.outer_belt || state.magnetosphere);
            }
            return(false);
        }
        private void RunCheck(Vessel v, VesselRadiationFieldStatus state)
        {
            if (state == null ||  targetBody == null || state.bodyIndex != targetBody.flightGlobalsIndex)
            {
                return;
            }

            var bd = KerbalismContracts.Instance.BodyData(targetBody);

            if (bd == null)
            {
                return;
            }

            switch (field)
            {
            case RadiationFieldType.INNER_BELT: crossed_count = bd.inner_crossings; break;

            case RadiationFieldType.OUTER_BELT: crossed_count = bd.outer_crossings; break;

            case RadiationFieldType.MAGNETOPAUSE: crossed_count = bd.magneto_crossings; break;
            }

            var result = ParameterState.Incomplete;

            if (crossings_min > 0 && crossed_count >= crossings_min)
            {
                result = ParameterState.Complete;
            }
            if (crossings_max > 0 && crossed_count > crossings_max)
            {
                result = ParameterState.Failed;
            }

            GetTitle();

            SetState(result);
        }
 private void RunCheck(Vessel v, VesselRadiationFieldStatus state)
 {
     CheckVessel(v);
 }