コード例 #1
0
        private void onEditorVariantApplied(Part part, PartVariant variant)
        {
            // This should never be called in flight, but somehow it was, so just
            // have a check to be safe
            if (HighLogic.LoadedSceneIsFlight)
            {
                return;
            }
            if (part != base.part || part == null)
            {
                return;
            }

            if (variant == null || variant.DisplayName == null)
            {
                return;
            }
            ModSegSRBs.GetExtraInfo(variant, ref this.part.segmentHeight, ref this.part.segmentWidth);

            RecalculateFuelAndMass();
            var f = GetMaxThrust();

            if (baseEngine != null)
            {
                baseEngine.ScheduleSegmentUpdate("MSSRB_Fuel_Segment.onEditorVariantApplied", 5);
            }
#if true
            MonoUtilities.RefreshContextWindows(part);
#else
            MonoUtilities.RefreshPartContextWindow(part);
#endif
        }
コード例 #2
0
        public void Start()
        {
            Log.Info("Start");
            part.RestoreVariant();

            if (HighLogic.LoadedSceneIsEditor)
            {
                RecalculateFuelAndMass();

                GameEvents.onVariantApplied.Add(onEditorVariantApplied);
                if (baseEngine != null)
                {
                    baseEngine.ScheduleSegmentUpdate("MSSRB_Fuel_Segment.Start");
                }
            }
            else
            {
                propAmt = burnablePropAmt = 0;
                Events["TriggerSegmentFailureEvent"].active   = HighLogic.CurrentGame.Parameters.CustomParams <MSSRB_1>().devMode;
                Actions["TriggerSegmentFailureAction"].active = HighLogic.CurrentGame.Parameters.CustomParams <MSSRB_1>().devMode;
            }

            if (part != null)
            {
                ModSegSRBs.GetExtraInfo(this.part.baseVariant, ref part.segmentHeight, ref part.segmentWidth);
            }
        }
コード例 #3
0
        public string GetSelectedVariant()
        {
            ModulePartVariants mpv = Modules.GetModule <ModulePartVariants>();

            ModSegSRBs.GetExtraInfo(mpv.SelectedVariant, ref segmentHeight, ref segmentWidth);
            Log.Info("Variant height, width: " + segmentHeight + ", " + segmentWidth);

            return(mpv.SelectedVariant.Name);
        }
コード例 #4
0
        private void onEditorVariantApplied(Part part, PartVariant variant)
        {
            if (part != base.part)
            {
                return;
            }
            ModSegSRBs.GetExtraInfo(variant, ref this.part.segmentHeight, ref this.part.segmentWidth);

            ScheduleSegmentUpdate("onEditorVariantApplied");
#if true
            MonoUtilities.RefreshContextWindows(part);
#else
            MonoUtilities.RefreshPartContextWindow(part);
#endif
        }
コード例 #5
0
        public void Start()
        {
            Log.Info("Start");
            part.RestoreVariant();
#if false
            SetThrustCurve(grainName, null);
#endif

            Events["TriggerEngineFailureEvent"].active   = HighLogic.CurrentGame.Parameters.CustomParams <MSSRB_1>().devMode;
            Actions["TriggerEngineFailureAction"].active = HighLogic.CurrentGame.Parameters.CustomParams <MSSRB_1>().devMode;

#if false
            foreach (var e in Events)
            {
                Log.Info("Event: " + e.name + ", guiName = " + e.guiName);
            }
            foreach (var a in Actions)
            {
                Log.Info("Action: " + a.name + ", guiName: " + a.guiName);
            }
            foreach (var f in Fields)
            {
                Log.Info("Field: " + f.name + ", guiName: " + f.guiName);
            }
#endif

            Fields["independentThrottle"].guiActive           =
                Fields["independentThrottle"].guiActiveEditor = false;
            Fields["thrustPercentage"].guiActive           =
                Fields["thrustPercentage"].guiActiveEditor = false;



            origAtmosphereCurve = atmosphereCurve;

            PartResourceDefinition prd = PartResourceLibrary.Instance.GetDefinition(ModSegSRBs.Propellant);
            density            = prd.density;
            densityInverse     = 1.0 / prd.density;
            fuelFlowMultiplier = densityInverse * Planetarium.fetch.fixedDeltaTime;

            phl = PartHighlighter.CreatePartHighlighter();
            if (phl)
            {
                highlightID = phl.CreateHighlightList();
            }
            if (highlightID >= 0)
            {
                UpdateHighlightColors();
            }

            PartModuleList pml = part.Modules;
            if (pml.Contains("MSSRB_Fuel_Segment"))
            {
                MSSRB_Fuel_Segment moduleFuelSegment = pml["MSSRB_Fuel_Segment"] as MSSRB_Fuel_Segment;
                part.segmentWidth = moduleFuelSegment.part.segmentWidth;
            }
            else
            {
                Log.Info("MSSRB_Engine, missing MSSRB_Fuel_Segment");
            }

            foreach (var p in propellants)
            {
                if (p.name == ModSegSRBs.BurnablePropellant)
                {
                    break;
                }
                burnablePropIndx++;
            }
            foreach (var p in propellants)
            {
                if (p.name == ModSegSRBs.Propellant)
                {
                    break;
                }
                propIndx++;
            }
            ModSegSRBs.GetExtraInfo(part.baseVariant, ref part.segmentHeight, ref part.segmentWidth);

            switch (HighLogic.LoadedScene)
            {
            case GameScenes.EDITOR:
                GameEvents.onEditorPartPicked.Add(onEditorPartPicked);
                GameEvents.onEditorPartPlaced.Add(onEditorPartPlaced);
                GameEvents.onEditorPartDeleted.Add(onEditorPartDeleted);
                GameEvents.onVariantApplied.Add(onEditorVariantApplied);
                ScheduleSegmentUpdate("Start");
                break;

            case GameScenes.FLIGHT:
                failureChance = HighLogic.CurrentGame.Parameters.CustomParams <MSSRB_1>().failureChance;
                if (this.vessel.situation <= Vessel.Situations.PRELAUNCH)
                {
                    UpdateSegments();
                    foreach (var s in segments)
                    {
                        /* PartModuleList */
                        pml = s.part.Modules;
                        MSSRB_Fuel_Segment moduleFuelSegment = pml["MSSRB_Fuel_Segment"] as MSSRB_Fuel_Segment;

                        PartResourceList prl = s.part.Resources;
                        if (prl.Contains(ModSegSRBs.Propellant))
                        {
                            //Log.Info("Segment: " + s.part.partInfo.title + " contains Propellant");
                            prl[ModSegSRBs.Propellant].amount = moduleFuelSegment.MaxSolidFuel();
                        }
                        if (prl.Contains(ModSegSRBs.BurnablePropellant))
                        {
                            prl[ModSegSRBs.BurnablePropellant].amount = 0;
                            //prl[ModSegSRBs.BurnablePropellant].amount = moduleFuelSegment.MaxSolidFuel();

                            //Log.Info("Segment: " + s.part.partInfo.title + " contains BurnablePropellant");
                        }
                    }
                }
                break;
            } // switch
        }