internal void Update() { if (Time.timeSinceLevelLoad < 2.0f) // Check not loading level { return; } if (!DFWrapper.InstanceExists) // Check if DFWrapper has been initialized or not. If not try to initialize. { DFWrapper.InitDFWrapper(); } if (DFWrapper.APIReady) // If the DeepFreeze API is Ready we do stuff with it. { DFFrozenKerbals.Clear(); //Get the DeepFreeze Dictionary of all Frozen Kerbals in the current Game. DFFrozenKerbals = DFWrapper.DeepFreezeAPI.FrozenKerbals; //Go through the active vessel and get all the DeepFreezer partmodules. deepfreezers.Clear(); if (FlightGlobals.ActiveVessel != null) { //Get a List of all the PartModules that are DeepFreezer class and store in deepfreezers List. List <Part> cryofreezers = (from p in FlightGlobals.ActiveVessel.parts where p.Modules.Contains("DeepFreezer") select p).ToList(); foreach (Part part in cryofreezers) { PartModule deepFreezer = (from PartModule pm in part.Modules where pm.moduleName == "DeepFreezer" select pm).SingleOrDefault(); if (deepFreezer != null) { deepfreezers.Add(deepFreezer); } } //If we found any DeepFreezer partmodules if (deepfreezers.Count == 1) { foreach (PartModule module in deepfreezers) { //The DFWrapper.DeepFreezer class is a reflection class of the real DeepFreezer PartModule DFWrapper.DeepFreezer freezer = new DFWrapper.DeepFreezer(module); //Populate fields for GUI display - NB: This only works for ONE freezer module in active vessel //But is only for example purposes. If you want to do this for multiple modules then // you will have to create your own Lists, etc. seats = freezer.FreezerSize; isxferto = freezer.crewXferTOActive; isxferfrom = freezer.crewXferFROMActive; isfreezeact = freezer.IsFreezeActive; isthawact = freezer.IsThawActive; outofec = freezer.FreezerOutofEC; partfull = freezer.PartFull; freeseats = freezer.FreezerSpace; tmpsts = freezer.FrzrTmp; totfrozen = freezer.TotalFrozen; frzncrewlst = freezer.StoredCrewList; } } } } }
internal void Update() { if (Time.timeSinceLevelLoad < 2.0f) // Check not loading level return; if (!DFWrapper.InstanceExists) // Check if DFWrapper has been initialized or not. If not try to initialize. { DFWrapper.InitDFWrapper(); } if (DFWrapper.APIReady) // If the DeepFreeze API is Ready we do stuff with it. { DFFrozenKerbals.Clear(); //Get the DeepFreeze Dictionary of all Frozen Kerbals in the current Game. DFFrozenKerbals = DFWrapper.DeepFreezeAPI.FrozenKerbals; //Go through the active vessel and get all the DeepFreezer partmodules. deepfreezers.Clear(); if (FlightGlobals.ActiveVessel != null) { //Get a List of all the PartModules that are DeepFreezer class and store in deepfreezers List. List<Part> cryofreezers = (from p in FlightGlobals.ActiveVessel.parts where p.Modules.Contains("DeepFreezer") select p).ToList(); foreach (Part part in cryofreezers) { PartModule deepFreezer = (from PartModule pm in part.Modules where pm.moduleName == "DeepFreezer" select pm).SingleOrDefault(); if (deepFreezer != null) { deepfreezers.Add(deepFreezer); } } //If we found any DeepFreezer partmodules if (deepfreezers.Count == 1) { foreach (PartModule module in deepfreezers) { //The DFWrapper.DeepFreezer class is a reflection class of the real DeepFreezer PartModule DFWrapper.DeepFreezer freezer = new DFWrapper.DeepFreezer(module); //Populate fields for GUI display - NB: This only works for ONE freezer module in active vessel //But is only for example purposes. If you want to do this for multiple modules then // you will have to create your own Lists, etc. seats = freezer.FreezerSize; isxferto = freezer.crewXferTOActive; isxferfrom = freezer.crewXferFROMActive; isfreezeact = freezer.IsFreezeActive; isthawact = freezer.IsThawActive; outofec = freezer.FreezerOutofEC; partfull = freezer.PartFull; freeseats = freezer.FreezerSpace; tmpsts = freezer.FrzrTmp; totfrozen = freezer.TotalFrozen; frzncrewlst = freezer.StoredCrewList; } } } } }