public void Init(IShipconstruct v, CelestialBody body)
        {
            FARHook.UpdateCurrentBody(body);

            int threads = Threading.ThreadPool.ThreadCount;

            simulators.Clear();
            for (int i = 0; i < threads; i++)
            {
                simulators.Add(new InstantConditionSimulationWrapper()); //(InstantConditionSimulationWrapper.Borrow());
            }
            List <Part> oParts = v.Parts;
            int         count  = oParts.Count;

            bool lgWarning = false;
            int  stage     = 0;

            for (int i = 0; i < count; i++)
            {
                if (!lgWarning)
                {
                    ModuleWheels.ModuleWheelDeployment gear = oParts[i].FindModuleImplementing <ModuleWheels.ModuleWheelDeployment>();
                    bool forcedRetract = !oParts[i].ShieldedFromAirstream && gear != null && gear.Position > 0;

                    if (forcedRetract)
                    {
                        lgWarning = true;
                    }
                }

                totalMass += oParts[i].mass + oParts[i].GetResourceMass();
                dryMass   += oParts[i].mass;
                CoM       += (oParts[i].mass + oParts[i].GetResourceMass()) * oParts[i].transform.TransformPoint(oParts[i].CoMOffset);
                CoM_dry   += (oParts[i].mass) * oParts[i].transform.TransformPoint(oParts[i].CoMOffset);

                if (oParts[i].inverseStage > stage)
                {
                    VesselCache.SimulatedEngine.Release(engines);
                    engines.Clear();
                    stage = oParts[i].inverseStage;
                }
                if (oParts[i].inverseStage >= stage)
                {
                    MultiModeEngine multiMode = oParts[i].FindModuleImplementing <MultiModeEngine>();
                    if (multiMode != null)
                    {
                        engines.Add(VesselCache.SimulatedEngine.Borrow(oParts[i].FindModulesImplementing <ModuleEngines>().Find(engine => engine.engineID == multiMode.mode), this));
                    }
                    else
                    {
                        ModuleEngines engine = oParts[i].FindModulesImplementing <ModuleEngines>().FirstOrDefault();
                        if (engine != null)
                        {
                            engines.Add(VesselCache.SimulatedEngine.Borrow(engine, this));
                        }
                    }
                }
            }
        }
 public InstantConditionSimOutputWrapper(object trueObject)
 {
     FARHook.Initiate();
     this.trueObject = trueObject;
 }