コード例 #1
0
        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();
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        protected override bool VesselMeetsCondition(Vessel vessel)
        {
            if (!ExperimentStateTracker.HasValue(vessel.id, experimentId))
            {
                return(false);
            }

            return(ExperimentStateTracker.GetValue(vessel.id, experimentId) == ExperimentState.running);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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); });
            }
        }
コード例 #6
0
 protected override void OnUnregister()
 {
     base.OnUnregister();
     ExperimentStateTracker.RemoveListener(RunCheck);
 }
コード例 #7
0
 protected override void OnRegister()
 {
     base.OnRegister();
     ExperimentStateTracker.AddListener(RunCheck);
 }
コード例 #8
0
 internal override bool CouldBeCandiate(Vessel vessel, EvaluationContext context)
 {
     return(ExperimentStateTracker.HasValue(vessel.id, experimentId));
 }