Example #1
0
        //Takes a list of parts so that the simulation can be run in the editor as well as the flight scene
        public void Init(List <Part> parts, bool dVLinearThrust)
        {
            KpaToAtmospheres = PhysicsGlobals.KpaToAtmospheres;

            // Create FuelNodes corresponding to each Part
            nodes.Clear();
            nodeLookup.Clear();
            //Dictionary<Part, FuelNode> nodeLookup = parts.ToDictionary(p => p, p => FuelNode.Borrow(p, dVLinearThrust));
            for (int index = 0; index < parts.Count; index++)
            {
                Part     part = parts[index];
                FuelNode node = FuelNode.Borrow(part, dVLinearThrust);
                nodeLookup[part] = node;
                nodes.Add(node);
            }
            // Determine when each part will be decoupled
            Part rootPart = parts[0]; // hopefully always correct

            nodeLookup[rootPart].AssignDecoupledInStage(rootPart, nodeLookup, -1);

            // Set up the fuel flow graph
            if (HighLogic.LoadedSceneIsFlight)
            {
                for (int i = 0; i < parts.Count; i++)
                {
                    Part p = parts[i];
                    nodeLookup[p].SetupFuelLineSourcesFlight(p, nodeLookup);
                }
            }
            else
            {
                for (int i = 0; i < parts.Count; i++)
                {
                    Part p = parts[i];
                    nodeLookup[p].SetupFuelLineSourcesFlight(p, nodeLookup);
                    nodeLookup[p].SetupFuelLineSourcesEditor(p, nodeLookup);
                }
            }
            for (int i = 0; i < parts.Count; i++)
            {
                Part p = parts[i];
                nodeLookup[p].SetupRegularSources(p, nodeLookup);
                nodeLookup[p].SetupSurfaceMountSources(p, nodeLookup);
            }


            simStage = Staging.lastStage + 1;

            // Add a fake stage if we are beyond the first one
            // Mostly usefull for the Node Executor who use the last stage info
            // and fail to get proper info when the ship was never staged and
            // some engine were activated manually
            if (Staging.CurrentStage > Staging.lastStage)
            {
                simStage++;
            }
        }
Example #2
0
        //Takes a list of parts so that the simulation can be run in the editor as well as the flight scene
        public void Init(List <Part> parts, bool dVLinearThrust)
        {
            KpaToAtmospheres = PhysicsGlobals.KpaToAtmospheres;

            // Create FuelNodes corresponding to each Part
            nodes.Clear();
            nodeLookup.Clear();

            for (int index = 0; index < parts.Count; index++)
            {
                Part     part = parts[index];
                FuelNode node = FuelNode.Borrow(part, dVLinearThrust);
                nodeLookup[part] = node;
                nodes.Add(node);
            }
            // Determine when each part will be decoupled
            Part rootPart = parts[0]; // hopefully always correct

            nodeLookup[rootPart].AssignDecoupledInStage(rootPart, nodeLookup, -1);

            // Set up the fuel flow graph
            for (int i = 0; i < parts.Count; i++)
            {
                Part p = parts[i];
                nodeLookup[p].AddCrossfeedSouces(p.crossfeedPartSet.GetParts(), nodeLookup);
            }

            simStage = StageManager.LastStage + 1;

            // Add a fake stage if we are beyond the first one
            // Mostly usefull for the Node Executor who use the last stage info
            // and fail to get proper info when the ship was never staged and
            // some engine were activated manually
            if (StageManager.CurrentStage > StageManager.LastStage)
            {
                simStage++;
            }
        }