Esempio n. 1
0
        //only run the following block in the editor; it updates the crew-assignment GUI
        private void UpdateCrewManifest()
        {
            Log.dbg("UpdateCrewManifest {0}", this.InstanceID);

#if !CREW_SCALE_UP
            // Small safety guard.
            if (part.CrewCapacity >= this.scaler.prefab.CrewCapacity)
            {
                return;
            }
#endif

            try // Preventing this thing triggering an eternal loop on the event handling!
            {
                VesselCrewManifest vcm = ShipConstruction.ShipManifest;
                if (vcm == null)
                {
                    return;
                }
                PartCrewManifest pcm = vcm.GetPartCrewManifest(part.craftID);
                if (pcm == null)
                {
                    return;
                }

                int len = pcm.partCrew.Length;
                //int newLen = Math.Min(part.CrewCapacity, _prefabPart.CrewCapacity);
                int newLen = part.CrewCapacity;
                if (len == newLen)
                {
                    return;
                }

                Log.dbg("UpdateCrewManifest current {0}; new {1}", len, newLen);

                this.scaler.part.CrewCapacity = newLen;
#if CREW_SCALE_UP
    #if PREFAB_SCALE_HACK
                // Workaround to try to force KSP to accept bigger crew manifests at editting time, as apparently it only respects the prefab's value, bluntly ignoring the part's data!
                this.scaler.prefab.CrewCapacity = Math.Max(this.scaler.prefab.CrewCapacity, this.scaler.part.CrewCapacity);
    #endif
#else
                this.scaler.part.CrewCapacity = Math.Min(this.scaler.part.CrewCapacity, this.scaler.prefab.CrewCapacity);
#endif
                if (EditorLogic.fetch.editorScreen == EditorScreen.Crew)
                {
                    EditorLogic.fetch.SelectPanelParts();
                }

                this.SetCrewManifestSize(pcm, newLen);

                ShipConstruction.ShipManifest.SetPartManifest(part.craftID, pcm);
            }
            catch (Exception e)
            {
                Log.error(e, this);
            }
        }
Esempio n. 2
0
        private void UpdateCrewManifest()
        {
            if (!HighLogic.LoadedSceneIsEditor)
            {
                return;
            }                                               //only run the following block in the editor; it updates the crew-assignment GUI

            VesselCrewManifest vcm = ShipConstruction.ShipManifest;

            if (vcm == null)
            {
                return;
            }
            PartCrewManifest pcm = vcm.GetPartCrewManifest(part.craftID);

            if (pcm == null)
            {
                return;
            }

            int len    = pcm.partCrew.Length;
            int newLen = Math.Min(part.CrewCapacity, _prefabPart.CrewCapacity);

            if (len == newLen)
            {
                return;
            }

            if (EditorLogic.fetch.editorScreen == EditorScreen.Crew)
            {
                EditorLogic.fetch.SelectPanelParts();
            }

            for (int i = 0; i < len; i++)
            {
                pcm.RemoveCrewFromSeat(i);
            }

            pcm.partCrew = new string[newLen];
            for (int i = 0; i < newLen; i++)
            {
                pcm.partCrew[i] = string.Empty;
            }

            ShipConstruction.ShipManifest.SetPartManifest(part.craftID, pcm);
        }
Esempio n. 3
0
        private void SetupCrewManifest()
        {
            // Restores the original Crew Capacity, as the Pregab is mangled.
            this.scaler.part.CrewCapacity = this.OriginalCrewCapacity;

            VesselCrewManifest vcm = ShipConstruction.ShipManifest;

            if (vcm == null)
            {
                return;
            }
            PartCrewManifest pcm = vcm.GetPartCrewManifest(part.craftID);

            if (pcm == null)
            {
                return;
            }

            if (pcm.partCrew.Length != this.scaler.part.CrewCapacity)
            {
                this.SetCrewManifestSize(pcm, this.scaler.part.CrewCapacity);
            }
        }