Beispiel #1
0
        public FuelNode(Part part, FuelFlowAnalyzer.Environment enviro)
        {
            this.part = part;

            if (part is FuelTank)
            {
                fuel = ((FuelTank)part).fuel;
            }

            if (part is SolidRocket)
            {
                if (!part.ActivatesEvenIfDisconnected) //if ActivatesEvenIfDisconnected, this is probably a separatron, not a motor.
                {
                    fuel = ((SolidRocket)part).internalFuel;
                    thrust = ((SolidRocket)part).thrust;
                    fuelConsumption = ((SolidRocket)part).fuelConsumption;
                }
            }

            if (part is LiquidEngine)
            {
                thrust = ((LiquidEngine)part).maxThrust;
                fuelConsumption = ((LiquidEngine)part).fuelConsumption;
            }

            if (part is LiquidFuelEngine)
            {
                thrust = ((LiquidFuelEngine)part).maxThrust;
                //Fuel flow == (Thrust * 200)/(Isp * 9.81)
                if (enviro == FuelFlowAnalyzer.Environment.ATMOSPHERE)
                {
                    fuelConsumption = thrust * 200 / (((LiquidFuelEngine)part).Isp * 9.81f);
                }
                else //enviro == FuelFlowAnalyzer.Environment.VACUUM
                {
                    fuelConsumption = thrust * 200 / (((LiquidFuelEngine)part).vacIsp * 9.81f);
                }
            }

            //figure out when this part gets decoupled
            Part p = part;
            while (p != null)
            {
                if (p is Decoupler || p is DecouplerGUI || p is RadialDecoupler)
                {
                    decoupledInStage = p.inverseStage;
                    break;
                }
                else if (p.parent == null)
                {
                    decoupledInStage = -1; //the root part is never decoupled.
                    break;
                }
                else
                {
                    p = p.parent;
                }
            }
        }