コード例 #1
0
        public void TryRestoreVessel(StoredVessel stored_vessel)
        {
            if (!can_restore())
            {
                return;
            }
            ScreenMessager.showMessage(string.Format("Launching {0}...", stored_vessel.vessel.vesselName), 3);
            //clean up
            stored_vessels.Remove(stored_vessel.vessel.vesselID);
            //switch hangar state
            hangar_state = HangarState.Inactive;
            //transfer resources
            transferResources(stored_vessel);
            //set restored vessel orbit
            GetLaunchTransform();
            position_vessel(stored_vessel);
            //restore vessel
            stored_vessel.Load();
            //get restored vessel from the world
            launched_vessel = stored_vessel.vessel.vesselRef;
            //transfer crew back to the launched vessel
            List <ProtoCrewMember> crew_to_transfer = CrewTransfer.delCrew(vessel, stored_vessel.crew);

            //change volume and mass
            change_part_params(stored_vessel.metric, -1f);
            //switch to restored vessel
            FlightGlobals.ForceSetActiveVessel(launched_vessel);
            SetupVessel(new LaunchedVessel(stored_vessel, launched_vessel, crew_to_transfer, part.flightID));
        }
コード例 #2
0
        //store vessel
        void store_vessel(Vessel vsl, bool perform_checks = true)
        {
            StoredVessel stored_vessel = new StoredVessel();

            if (perform_checks)            //for normal operation
            {
                //check momentary states
                if (!can_store(vsl))
                {
                    return;
                }
                //check if the vessel can be stored, if unknown, try to store
                bool storable;
                if (!probed_ids.TryGetValue(vsl.id, out storable))
                {
                    stored_vessel = try_store(vsl);
                    storable      = stored_vessel != null;
                    probed_ids.Add(vsl.id, storable);
                }
                if (!storable)
                {
                    return;
                }
            }
            else             //for storing packed constructs upon hangar launch
            {
                stored_vessel = new StoredVessel(vsl);
                stored_vessels.ForceAdd(stored_vessel);
            }
            //get vessel crew on board
            List <ProtoCrewMember> _crew = new List <ProtoCrewMember>(stored_vessel.crew);

            CrewTransfer.delCrew(vsl, _crew);
            vsl.DespawnCrew();
            //first of, add crew to the hangar if there's a place
            CrewTransfer.addCrew(part, _crew);
            //then add to other vessel parts if needed
            CrewTransfer.addCrew(vessel, _crew);
            //recalculate volume and mass
            change_part_params(stored_vessel.metric);
            //switch to hangar vessel before storing
            if (FlightGlobals.ActiveVessel.id == vsl.id)
            {
                FlightGlobals.ForceSetActiveVessel(vessel);
            }
            //destroy vessel
            vsl.Die();
            ScreenMessager.showMessage("Vessel has been docked inside the hangar", 3);
        }
コード例 #3
0
ファイル: VesselWrappers.cs プロジェクト: kevin-ye/hangar
 public void transferCrew()
 {
     CrewTransfer.addCrew(vessel, crew);
 }